Fix: apply rename_map on fresh-built processor pipelines#3512
Fix: apply rename_map on fresh-built processor pipelines#3512wadeKeith wants to merge 3 commits intohuggingface:mainfrom
Conversation
When use_relative_actions=true with a pretrained model (pi05, pi0, pi0_fast, smolvla, xvla), the code sets processor_pretrained_path=None to force building processors from the current policy config rather than loading from the checkpoint. However, rename_map was only being passed via preprocessor_overrides which only applies when loading from pretrained. This meant rename_map was silently ignored when use_relative_actions=true. The fix: - Add rename_map to ProcessorConfigKwargs TypedDict - Always pass rename_map to make_pre_post_processors (when not reward model) - Update all affected processor factories to accept and use rename_map: - make_pi05_pre_post_processors - make_pi0_pre_post_processors - make_pi0_fast_pre_post_processors - make_smolvla_pre_post_processors - make_xvla_pre_post_processors This ensures the RenameObservationsProcessorStep uses the user-provided rename_map regardless of whether processors are loaded from pretrained or built from scratch. Fixes huggingface#3425
There was a problem hiding this comment.
Pull request overview
This PR fixes --rename_map being ignored when processor pipelines are built from scratch (not loaded from a pretrained processor config), ensuring feature key remapping is consistently applied across PI0/PI05/SmolVLA/XVLA and the dynamic (plugin/third-party) processor factory path.
Changes:
- Forward
rename_mapthroughlerobot_train.py→make_pre_post_processors()so scratch-built processor pipelines can apply it. - Update PI0/PI05/PI0Fast/SmolVLA/XVLA processor factory functions to accept
rename_mapand wire it intoRenameObservationsProcessorStep. - Extend
_make_processors_from_policy_config()to acceptrename_mapand pass it into dynamically importedmake_*_pre_post_processors()factories.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/lerobot/scripts/lerobot_train.py | Always forwards rename_map into processor factory kwargs for non-reward-model training. |
| src/lerobot/policies/factory.py | Adds rename_map to processor kwargs typing and forwards it into per-policy factories + dynamic fallback. |
| src/lerobot/policies/pi0/processor_pi0.py | Accepts rename_map and uses it in the rename processor step. |
| src/lerobot/policies/pi05/processor_pi05.py | Accepts rename_map and uses it in the rename processor step; updates processing-order comment. |
| src/lerobot/policies/pi0_fast/processor_pi0_fast.py | Accepts rename_map and uses it in the rename processor step. |
| src/lerobot/policies/smolvla/processor_smolvla.py | Accepts rename_map and uses it in the rename processor step. |
| src/lerobot/policies/xvla/processor_xvla.py | Accepts rename_map and uses it in the rename processor step. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if not cfg.is_reward_model_training: | ||
| # Always pass rename_map so it gets applied in the processor even when building | ||
| # processors from scratch (e.g., when use_relative_actions=True bypasses pretrained_path) | ||
| processor_kwargs["rename_map"] = cfg.rename_map | ||
|
|
| f"Instantiating pre/post processors using function '{function_name}' from module '{module_path}'" | ||
| ) | ||
| module = importlib.import_module(module_path) | ||
| function = getattr(module, function_name) | ||
| return function(config, dataset_stats=dataset_stats) | ||
| return function(config, dataset_stats=dataset_stats, rename_map=rename_map) |
| postprocessor_config_filename: str | None | ||
| preprocessor_overrides: dict[str, Any] | None | ||
| postprocessor_overrides: dict[str, Any] | None | ||
| dataset_stats: dict[str, dict[str, torch.Tensor]] | None | ||
| rename_map: dict[str, str] | None |
|
All Copilot review concerns are now addressed in PR #3514, which supersedes #3512:
|
…Copilot review comments 1. lerobot_train.py: remove unused 'inspect' import (was used in original fix but refactored away) 2. lerobot_train.py: call rename_stats() on dataset.meta.stats when both rename_map and fresh-build path are active, so NormalizerProcessorStep can locate stats for renamed keys. 3. factory.py _make_processors_from_policy_config: inspect signature before passing rename_map; fall back to (config, dataset_stats) for third-party factories that don't declare the parameter (backward-compatible). 4. factory.py ProcessorConfigKwargs: document rename_map in docstring.
Fix: apply rename_map on fresh-built processor pipelines (fix #3425)
Addresses the Copilot review comment on #3511 which noted that while
rename_mapwas added toProcessorConfigKwargsin factory.py, it was not being forwarded into the per-policymake_*_pre_post_processors()calls for PI0/PI05/SmolVLA/XVLA, nor into the fallback_make_processors_from_policy_config()path.Changes
factory.py: Pass
rename_mapto:make_pi0_pre_post_processors()make_pi05_pre_post_processors()make_smolvla_pre_post_processors()make_xvla_pre_post_processors()_make_processors_from_policy_config()(for plugin/third-party policies)_make_processors_from_policy_config: Add
rename_mapparameter and forward it to the dynamic factory function call.This ensures
rename_mapis applied regardless of which code path builds the processors (direct factory call or fallback dynamic import).Related