mirror of
https://github.com/huggingface/lerobot.git
synced 2026-05-16 00:59:46 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 69f0b1d814 |
@@ -41,7 +41,7 @@ There are more complex methods that have more parameters. These are not yet supp
|
|||||||
if you want to see a specific PEFT method supported.
|
if you want to see a specific PEFT method supported.
|
||||||
|
|
||||||
By default, PEFT will target the `q_proj` and `v_proj` layers of the LM expert in SmolVLA. It will also target the
|
By default, PEFT will target the `q_proj` and `v_proj` layers of the LM expert in SmolVLA. It will also target the
|
||||||
state and action projection matrices as they are most likely taks-dependent. If you need to target different layers
|
state and action projection matrices as they are most likely task-dependent. If you need to target different layers
|
||||||
you can use `--peft.target_modules` to specify which layers to target. You can refer to the respective PEFT method's
|
you can use `--peft.target_modules` to specify which layers to target. You can refer to the respective PEFT method's
|
||||||
documentation to see what inputs are supported, (e.g., [LoRA's target_modules documentation](https://huggingface.co/docs/peft/main/en/package_reference/lora#peft.LoraConfig.target_modules)).
|
documentation to see what inputs are supported, (e.g., [LoRA's target_modules documentation](https://huggingface.co/docs/peft/main/en/package_reference/lora#peft.LoraConfig.target_modules)).
|
||||||
Usually a list of suffixes or a regex are supported. For example, to target the MLPs of the `lm_expert` instead of
|
Usually a list of suffixes or a regex are supported. For example, to target the MLPs of the `lm_expert` instead of
|
||||||
|
|||||||
@@ -129,6 +129,8 @@ class PreTrainedConfig(draccus.ChoiceRegistry, HubMixin, abc.ABC): # type: igno
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def robot_state_feature(self) -> PolicyFeature | None:
|
def robot_state_feature(self) -> PolicyFeature | None:
|
||||||
|
if self.input_features is None:
|
||||||
|
return None
|
||||||
for ft_name, ft in self.input_features.items():
|
for ft_name, ft in self.input_features.items():
|
||||||
if ft.type is FeatureType.STATE and ft_name == OBS_STATE:
|
if ft.type is FeatureType.STATE and ft_name == OBS_STATE:
|
||||||
return ft
|
return ft
|
||||||
@@ -136,6 +138,8 @@ class PreTrainedConfig(draccus.ChoiceRegistry, HubMixin, abc.ABC): # type: igno
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def env_state_feature(self) -> PolicyFeature | None:
|
def env_state_feature(self) -> PolicyFeature | None:
|
||||||
|
if self.input_features is None:
|
||||||
|
return None
|
||||||
for _, ft in self.input_features.items():
|
for _, ft in self.input_features.items():
|
||||||
if ft.type is FeatureType.ENV:
|
if ft.type is FeatureType.ENV:
|
||||||
return ft
|
return ft
|
||||||
@@ -143,10 +147,14 @@ class PreTrainedConfig(draccus.ChoiceRegistry, HubMixin, abc.ABC): # type: igno
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def image_features(self) -> dict[str, PolicyFeature]:
|
def image_features(self) -> dict[str, PolicyFeature]:
|
||||||
|
if self.input_features is None:
|
||||||
|
return {}
|
||||||
return {key: ft for key, ft in self.input_features.items() if ft.type is FeatureType.VISUAL}
|
return {key: ft for key, ft in self.input_features.items() if ft.type is FeatureType.VISUAL}
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def action_feature(self) -> PolicyFeature | None:
|
def action_feature(self) -> PolicyFeature | None:
|
||||||
|
if self.output_features is None:
|
||||||
|
return None
|
||||||
for ft_name, ft in self.output_features.items():
|
for ft_name, ft in self.output_features.items():
|
||||||
if ft.type is FeatureType.ACTION and ft_name == ACTION:
|
if ft.type is FeatureType.ACTION and ft_name == ACTION:
|
||||||
return ft
|
return ft
|
||||||
|
|||||||
@@ -474,7 +474,7 @@ def make_policy(
|
|||||||
if not cfg.pretrained_path and cfg.use_peft:
|
if not cfg.pretrained_path and cfg.use_peft:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
"Instantiating a policy with `use_peft=True` without a checkpoint is not supported since that requires "
|
"Instantiating a policy with `use_peft=True` without a checkpoint is not supported since that requires "
|
||||||
"the PEFT config parameters to be set. For traning with PEFT, see `lerobot_train.py` on how to do that."
|
"the PEFT config parameters to be set. For training with PEFT, see `lerobot_train.py` on how to do that."
|
||||||
)
|
)
|
||||||
|
|
||||||
if cfg.pretrained_path and not cfg.use_peft:
|
if cfg.pretrained_path and not cfg.use_peft:
|
||||||
|
|||||||
@@ -278,16 +278,17 @@ def eval_policy(
|
|||||||
raise ValueError("If max_episodes_rendered > 0, videos_dir must be provided.")
|
raise ValueError("If max_episodes_rendered > 0, videos_dir must be provided.")
|
||||||
|
|
||||||
if not isinstance(policy, PreTrainedPolicy):
|
if not isinstance(policy, PreTrainedPolicy):
|
||||||
exc = ValueError(
|
|
||||||
f"Policy of type 'PreTrainedPolicy' is expected, but type '{type(policy)}' was provided."
|
|
||||||
)
|
|
||||||
try:
|
try:
|
||||||
from peft import PeftModel
|
from peft import PeftModel
|
||||||
|
|
||||||
if not isinstance(policy, PeftModel):
|
if not isinstance(policy, PeftModel):
|
||||||
raise exc
|
raise ValueError(
|
||||||
|
f"Policy of type 'PreTrainedPolicy' is expected, but type '{type(policy)}' was provided."
|
||||||
|
)
|
||||||
except ImportError:
|
except ImportError:
|
||||||
raise exc
|
raise ValueError(
|
||||||
|
"PEFT is required to evaluate a PEFT-trained policy. Please install PEFT using `pip install peft`."
|
||||||
|
) from None
|
||||||
|
|
||||||
start = time.time()
|
start = time.time()
|
||||||
policy.eval()
|
policy.eval()
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ def wrap_policy_in_peft_model(cfg, policy):
|
|||||||
|
|
||||||
if cfg.policy.type == "smolvla" and not cfg.policy.load_vlm_weights:
|
if cfg.policy.type == "smolvla" and not cfg.policy.load_vlm_weights:
|
||||||
logging.warning(
|
logging.warning(
|
||||||
"Traning SmolVLA from scratch using PEFT. This is unlikely to yield good results. Set "
|
"Training SmolVLA from scratch using PEFT. This is unlikely to yield good results. Set "
|
||||||
"`load_vlm_weights=True` to fine-tune the existing policy."
|
"`load_vlm_weights=True` to fine-tune the existing policy."
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user