Skip to content

Fix: apply rename_map on fresh-built processor pipelines (complete)#3514

Open
wadeKeith wants to merge 3 commits intohuggingface:mainfrom
wadeKeith:fix/3512-complete
Open

Fix: apply rename_map on fresh-built processor pipelines (complete)#3514
wadeKeith wants to merge 3 commits intohuggingface:mainfrom
wadeKeith:fix/3512-complete

Conversation

@wadeKeith
Copy link
Copy Markdown
Contributor

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

This supersedes #3512 and addresses all Copilot review comments:

Changes

1. lerobot_train.py — Rename stats alongside observation keys
When rename_map is provided in the fresh-build path, call rename_stats() on dataset.meta.stats before passing to make_pre_post_processors. This ensures NormalizerProcessorStep can locate stats for renamed keys.

2. factory.py — Backward-compat for third-party plugin factories
_make_processors_from_policy_config() now inspects the signature of the dynamically-imported factory function. If rename_map is not in its parameters, it falls back to calling with only (config, dataset_stats) — no breaking change for plugins.

3. factory.py — Document ProcessorConfigKwargs.rename_map
Updated the TypedDict docstring to mention rename_map and explain its interaction with dataset_stats.

Previous fixes (included from #3511 and #3512)

  • rename_map forwarded to make_pi0/pi05/smolvla/xvla_pre_post_processors()
  • rename_map forwarded to _make_processors_from_policy_config()
  • All 5 processor factories use rename_map in RenameObservationsProcessorStep

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 handling when building processor pipelines from scratch (not loading from a pretrained processor), ensuring observation-key renames are consistently applied alongside normalization statistics so processor steps (notably normalization) can resolve the correct stats keys. It also improves backward compatibility for third‑party policy processor factories by conditionally passing rename_map only when supported.

Changes:

  • In training (lerobot_train.py), pass rename_map into processor creation and rename dataset.meta.stats keys via rename_stats() in the fresh-build path.
  • In policy processor factories (PI0/PI05/PI0Fast/SmolVLA/XVLA), accept rename_map and wire it into RenameObservationsProcessorStep.
  • In policies/factory.py, extend processor factory kwargs to include rename_map, document it, and add signature-based backward-compat when calling dynamically imported (plugin) processor factories.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/lerobot/scripts/lerobot_train.py Passes rename_map into processor construction and renames dataset stats keys in the fresh-build path.
src/lerobot/policies/factory.py Adds rename_map to processor kwargs, forwards it to built-in factories, and adds backward-compatible dynamic factory invocation.
src/lerobot/policies/pi0/processor_pi0.py Adds rename_map param and applies it in RenameObservationsProcessorStep.
src/lerobot/policies/pi05/processor_pi05.py Adds rename_map param and applies it in RenameObservationsProcessorStep; updates pipeline order comment.
src/lerobot/policies/pi0_fast/processor_pi0_fast.py Adds rename_map param and applies it in RenameObservationsProcessorStep; updates pipeline order comment.
src/lerobot/policies/smolvla/processor_smolvla.py Adds rename_map param and applies it in RenameObservationsProcessorStep.
src/lerobot/policies/xvla/processor_xvla.py Adds rename_map param and applies it in RenameObservationsProcessorStep.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/lerobot/scripts/lerobot_train.py Outdated
"""

import dataclasses
import inspect
Comment on lines +318 to +323
processor_kwargs["rename_map"] = cfg.rename_map
# When rename_map is provided and stats are used (fresh-build path), rename stats keys
# so NormalizerProcessorStep can find them after observations are renamed.
if cfg.rename_map and ((processor_pretrained_path and not cfg.resume) or not processor_pretrained_path):
processor_kwargs["dataset_stats"] = rename_stats(dataset.meta.stats, cfg.rename_map)

Comment on lines +222 to +223
policy feature names. When provided, stats are renamed accordingly so that
NormalizerProcessorStep can locate them after observation keys are remapped.
Comment on lines +625 to +627
if rename_map is not None:
sig = inspect.signature(function)
if "rename_map" in sig.parameters:
…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.
@wadeKeith wadeKeith force-pushed the fix/3512-complete branch from a4402df to 7beeca6 Compare May 5, 2026 18:38
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