Skip to content

Fix: apply rename_map on fresh-built processor pipelines#3512

Open
wadeKeith wants to merge 3 commits intohuggingface:mainfrom
wadeKeith:fix/3428-updated
Open

Fix: apply rename_map on fresh-built processor pipelines#3512
wadeKeith wants to merge 3 commits intohuggingface:mainfrom
wadeKeith:fix/3428-updated

Conversation

@wadeKeith
Copy link
Copy Markdown
Contributor

Fix: apply rename_map on fresh-built processor pipelines (fix #3425)

Addresses the Copilot review comment on #3511 which noted that while rename_map was added to ProcessorConfigKwargs in factory.py, it was not being forwarded into the per-policy make_*_pre_post_processors() calls for PI0/PI05/SmolVLA/XVLA, nor into the fallback _make_processors_from_policy_config() path.

Changes

  1. factory.py: Pass rename_map to:

    • 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)
  2. _make_processors_from_policy_config: Add rename_map parameter and forward it to the dynamic factory function call.

This ensures rename_map is applied regardless of which code path builds the processors (direct factory call or fallback dynamic import).

Related

wadeKeith added 2 commits May 5, 2026 19:00
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
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_map through lerobot_train.pymake_pre_post_processors() so scratch-built processor pipelines can apply it.
  • Update PI0/PI05/PI0Fast/SmolVLA/XVLA processor factory functions to accept rename_map and wire it into RenameObservationsProcessorStep.
  • Extend _make_processors_from_policy_config() to accept rename_map and pass it into dynamically imported make_*_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.

Comment on lines +313 to +317
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

Comment on lines 613 to +617
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)
Comment on lines 223 to +227
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
@wadeKeith
Copy link
Copy Markdown
Contributor Author

All Copilot review concerns are now addressed in PR #3514, which supersedes #3512:

  1. dataset_stats rename: When rename_map is active in the fresh-build path, rename_stats() is called on dataset.meta.stats before passing to make_pre_post_processors. This ensures NormalizerProcessorStep finds stats by renamed keys.

  2. Plugin backward-compat: _make_processors_from_policy_config() now uses inspect.signature() to check if the target factory accepts rename_map. Falls back to (config, dataset_stats) for third-party factories that don't declare the parameter.

  3. Docstring: ProcessorConfigKwargs docstring now documents rename_map and explains its effect on stats.

wadeKeith added a commit to wadeKeith/lerobot that referenced this pull request May 5, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

policies Items related to robot policies

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--rename_map silently ignored for PI05 when use_relative_actions=true

2 participants