openpi icon indicating copy to clipboard operation
openpi copied to clipboard

question about lora fine-tuning for pi0.5

Open yanan1116 opened this issue 1 year ago • 17 comments

hi, i do not see any exisiting config about fine tune pi0.5 in src/openpi/training/config.py under lora mode, but there is pi0's demonstration.

is it fine to just replace pi0 with pi05 and set weights url to be gs://openpi-assets/checkpoints/pi05_base/params without any other changes ? thanks


    TrainConfig(
        name="pi05_fast_libero_low_mem_finetune",
        # Here is an example of loading a pi0-FAST model for LoRA finetuning.
        # For setting action_dim, action_horizon, and max_token_len, see the comments above.
        model=pi0_fast.Pi0FASTConfig(
            action_dim=7, action_horizon=10, max_token_len=180, paligemma_variant="gemma_2b_lora"
        ),
        data=LeRobotLiberoDataConfig(
            repo_id="physical-intelligence/libero",
            base_config=DataConfig(prompt_from_task=True),
            extra_delta_transform=True,
        ),
        weight_loader=weight_loaders.CheckpointWeightLoader("gs://openpi-assets/checkpoints/pi05_base/params"),
        num_train_steps=30_000,
        # Again, make sure to match the model config above when extracting the freeze filter
        # that specifies which parameters should be frozen during LoRA finetuning.
        freeze_filter=pi0_fast.Pi0FASTConfig(
            action_dim=7, action_horizon=10, max_token_len=180, paligemma_variant="gemma_2b_lora"
        ).get_freeze_filter(),
        # Turn off EMA for LoRA finetuning.
        ema_decay=None,
    ),

yanan1116 avatar Sep 17 '25 21:09 yanan1116

under this folder src/openpi/models there is only utils for pi0 , such as pi0_fast.py pi0_config.py

yanan1116 avatar Sep 17 '25 21:09 yanan1116

The same question, may I ask if you have tried it, and how did you solve it?

escapethetrap avatar Oct 11 '25 10:10 escapethetrap

same question

Shengqi77 avatar Oct 25 '25 01:10 Shengqi77

I do sft with pi05 in this way, similar to pi0, and based on the performance, it works fine.

    # fine-tune on the libero 
    TrainConfig(
        name="pi05_libero_yc",
        model=pi0_fast.Pi0FASTConfig(
            action_dim=7, action_horizon=10, max_token_len=180, paligemma_variant="gemma_2b_lora"
        ),
        data=LeRobotLiberoDataConfig(
            repo_id= "physical-intelligence/libero", 
            base_config=DataConfig(prompt_from_task=True),
            extra_delta_transform=False,
        ),
        weight_loader=weight_loaders.CheckpointWeightLoader("gs://openpi-assets/checkpoints/pi05_base/params"),
        num_train_steps=100_000,
        # Again, make sure to match the model config above when extracting the freeze filter
        # that specifies which parameters should be frozen during LoRA finetuning.
        freeze_filter=pi0_fast.Pi0FASTConfig(
            action_dim=7, action_horizon=10, max_token_len=180, paligemma_variant="gemma_2b_lora"
        ).get_freeze_filter(),
        # Turn off EMA for LoRA finetuning.
        ema_decay=None,
        wandb_enabled=False,
        batch_size=8, 
        optimizer=_optimizer.AdamW(clip_gradient_norm=1.0),
        lr_schedule=_optimizer.CosineDecaySchedule(
            warmup_steps=10_000,
            peak_lr=5e-5,
            decay_steps=1_000_000,
            decay_lr=5e-5,
        ),
    ),  

yanan1116 avatar Oct 27 '25 17:10 yanan1116

i also suggest turn extra_delta_transform to true or false to find which one is best for your case. this param is quite confusing.

yanan1116 avatar Dec 03 '25 16:12 yanan1116

@yanan1116 , Hi yanan, any idea about the function of extra_delta_transform? It is truly quite confusing.

haofuly avatar Dec 10 '25 07:12 haofuly

@haofuly it depends on your dataset. if it use delta ee action space, then set it to false as default. if it is of absolute ee action space, set it to true for first try.

yanan1116 avatar Dec 10 '25 14:12 yanan1116

@yanan1116 Thanks, your conclusion is suitable for our common sense.

Besides, I want to make sure that the raw lerobot rlds dataset in https://github.com/Physical-Intelligence/openpi/blob/main/README.md#L133 is delta eef action, so we don't need this extra_delta_transform. Am i right?

Quite thanks.

haofuly avatar Dec 10 '25 14:12 haofuly

@haofuly for libero dataset, yes, it is delta eef. so keep extra_delta_transform to false, for sure.

for droid, that is another story.

yanan1116 avatar Dec 10 '25 16:12 yanan1116

@yanan1116
Hello. Thank you for providing the excellent config. I'm curious about how many steps it takes for the LIBERO success rate to converge with this LoRA setting? Also, I'm wondering if everything works successfully without issues like action dimension mismatching (I've experienced action mismatch issues when doing inference with this setting before, which resulted in significantly lower success rates).

cykim05 avatar Dec 15 '25 11:12 cykim05

This config works for me

    TrainConfig(
        name="pi05_libero_lora_v1",

        model=pi0_config.Pi0Config(pi05=True, action_horizon=10, discrete_state_input=False,
                                   paligemma_variant="gemma_2b_lora", action_expert_variant="gemma_300m_lora"),

        data=LeRobotLiberoDataConfig(
            repo_id="physical-intelligence/libero",
            base_config=DataConfig(prompt_from_task=True),
            extra_delta_transform=False,
        ),
        weight_loader=weight_loaders.CheckpointWeightLoader("gs://openpi-assets/checkpoints/pi05_base/params"),
        num_train_steps=30_000,
        # Again, make sure to match the model config above when extracting the freeze filter
        # that specifies which parameters should be frozen during LoRA finetuning.
        freeze_filter=
        pi0_config.Pi0Config(pi05=True, action_horizon=10,
                             discrete_state_input=False,
                             paligemma_variant="gemma_2b_lora",
                             action_expert_variant="gemma_300m_lora"
                             ).get_freeze_filter(),
        # Turn off EMA for LoRA finetuning.
        ema_decay=None,
        wandb_enabled=True,
        # batch_size=32, #use fault 32
        optimizer=_optimizer.AdamW(clip_gradient_norm=1.0),
        lr_schedule=_optimizer.CosineDecaySchedule(
            warmup_steps=10_000,
            peak_lr=5e-5,
            decay_steps=1_000_000,
            decay_lr=5e-5,
        ),
    ),

ZhixuLi-the-Runner avatar Dec 24 '25 21:12 ZhixuLi-the-Runner

Hello, can the following configuration be used for the fine-tuning of a PyTorch-based PI0 model?

# fine-tune on the libero 
TrainConfig(
    name="pi05_libero_yc",
    model=pi0_fast.Pi0FASTConfig(
        action_dim=7, action_horizon=10, max_token_len=180, paligemma_variant="gemma_2b_lora"
    ),
    data=LeRobotLiberoDataConfig(
        repo_id= "physical-intelligence/libero", 
        base_config=DataConfig(prompt_from_task=True),
        extra_delta_transform=False,
    ),
    weight_loader=weight_loaders.CheckpointWeightLoader("gs://openpi-assets/checkpoints/pi05_base/params"),
    num_train_steps=100_000,
    # Again, make sure to match the model config above when extracting the freeze filter
    # that specifies which parameters should be frozen during LoRA finetuning.
    freeze_filter=pi0_fast.Pi0FASTConfig(
        action_dim=7, action_horizon=10, max_token_len=180, paligemma_variant="gemma_2b_lora"
    ).get_freeze_filter(),
    # Turn off EMA for LoRA finetuning.
    ema_decay=None,
    wandb_enabled=False,
    batch_size=8, 
    optimizer=_optimizer.AdamW(clip_gradient_norm=1.0),
    lr_schedule=_optimizer.CosineDecaySchedule(
        warmup_steps=10_000,
        peak_lr=5e-5,
        decay_steps=1_000_000,
        decay_lr=5e-5,
    ),
),  

zhaianbang avatar Jan 12 '26 04:01 zhaianbang

I use the following config for jax pi05 LORA finetune, and it works : )

  TrainConfig(
      name="pi05_libero_LORA",
      model=pi0_config.Pi0Config(pi05=True, action_horizon=10, discrete_state_input=False,
              paligemma_variant="gemma_2b_lora", action_expert_variant="gemma_300m_lora"),
      data=LeRobotLiberoDataConfig(
          repo_id="pick_and_place",
          base_config=DataConfig(prompt_from_task=True),
          # extra_delta_transform=False,
      ),
      weight_loader=weight_loaders.CheckpointWeightLoader("gs://openpi-assets/checkpoints/pi05_base/params"),
      optimizer=_optimizer.AdamW(clip_gradient_norm=1.0),
      lr_schedule=_optimizer.CosineDecaySchedule(
          warmup_steps=10_000,
          peak_lr=5e-5,
          decay_steps=1_000_000,
          decay_lr=5e-5,
      ),
      freeze_filter=pi0_config.Pi0Config(
          pi05=True, action_horizon=10, discrete_state_input=False,
          paligemma_variant="gemma_2b_lora", action_expert_variant="gemma_300m_lora"
      ).get_freeze_filter(),
      ema_decay=None,
      num_train_steps=60_000,
      batch_size=32,
  ),

chenxxh07 avatar Jan 15 '26 09:01 chenxxh07

@yanan1116 When action is delta_eef, is it the difference of action between the current time stamp and the initial time stamp, or the current time stamp and the previous time stamp?

I now have action defined as the difference of state between two time stamps, I am not sure if I need to convert it or not. Thank you!

XiaoweiLinXL avatar Jan 23 '26 23:01 XiaoweiLinXL

@XiaoweiLinXL it is the delta value in terms of action between t and t+1

yanan1116 avatar Jan 24 '26 02:01 yanan1116

Thank you for your response, @yanan1116! You mentioned that Libero use delta_ee in their dataset. Why, in their default setting of TrainingConfig, they set the extra_delta_transform to True?

XiaoweiLinXL avatar Jan 26 '26 20:01 XiaoweiLinXL

For anyone landing here from search: #1060 has a careful comparison where LoRA and full fine-tune match on loss and open-loop error but differ a lot in closed loop. Worth running a closed-loop check before trusting the LoRA path for a new task.

sattyamjjain avatar Oct 06 '26 09:10 sattyamjjain