question about lora fine-tuning for pi0.5
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,
),
under this folder src/openpi/models there is only utils for pi0 ,
such as pi0_fast.py pi0_config.py
The same question, may I ask if you have tried it, and how did you solve it?
same question
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,
),
),
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 , Hi yanan, any idea about the function of extra_delta_transform? It is truly quite confusing.
@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 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 for libero dataset, yes, it is delta eef. so keep extra_delta_transform to false, for sure.
for droid, that is another story.
@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).
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,
),
),
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,
),
),
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,
),
@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 it is the delta value in terms of action between t and t+1
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?
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.