Skip to content

fix(train): restrict legacy RA-BC migration to JSON checkpoints only#3490

Open
masato-ka wants to merge 3 commits intohuggingface:mainfrom
masato-ka:fix/lerobot_train-failed-load-yaml-config
Open

fix(train): restrict legacy RA-BC migration to JSON checkpoints only#3490
masato-ka wants to merge 3 commits intohuggingface:mainfrom
masato-ka:fix/lerobot_train-failed-load-yaml-config

Conversation

@masato-ka
Copy link
Copy Markdown
Collaborator

_migrate_legacy_rabc_fields was called for all config files, causing json.load to raise DecodeError when a YAML config was passed to lerobot-train for a new training run. Guard the block with an .endswith(".json") check so migration only runs when resuming from a JSON checkpoint.

Also adds types-PyYAML to pre-commit mypy additional_dependencies to fix a pre-existing [import-untyped] error in envs/robotwin.py.

Title

Short, imperative summary (e.g., "fix(robots): handle None in sensor parser"). See CONTRIBUTING.md for PR conventions.

Summary / Motivation

PR #3480 (cd6b43e) introduced _migrate_legacy_rabc_fields, which was called unconditionally
whenever config_file is not None. Since this function calls json.load() as its first step, passing
a YAML config file via --config_path to start a new training run raised a JSONDecodeError and
aborted the process. This fix adds an .endswith(".json") guard to the migration block so that the
legacy RA-BC migration only runs when resuming from a JSON checkpoint. A clarifying comment was
also added to make the intent clear to future readers. Additionally, a pre-existing mypy
[import-untyped] error in lerobot/envs/robotwin.py (missing types-PyYAML stubs) was resolved by
adding types-PyYAML to the pre-commit mypy additional_dependencies.

Reproduction steps (before fix)

Raises JSONDecodeError on main with #3480 applied

  lerobot-train --config_path=act-training.yaml             
  # act-training.yaml
  dataset:                                                                                          
    repo_id: lerobot/pusht                                  
  policy:
    type: act
    push_to_hub: false
    device: cuda
  output_dir: outputs/train/act-pusht                                                               
  job_name: pusht
  batch_size: 8                                                                                     
  save_freq: 20000                                          
  steps: 40000
  wandb:
    enable: false
    project: lerobot

Related issues

What changed

  • src/lerobot/configs/train.py: Changed the legacy RA-BC migration guard in
    TrainPipelineConfig.from_pretrained from if config_file is not None: to if config_file is not None
    and os.path.basename(config_file).endswith(".json"):, preventing json.load from being called on
    YAML configs.
    • src/lerobot/configs/train.py: Added a comment explaining the intent of the guard condition.
    • .pre-commit-config.yaml: Added types-PyYAML to the mypy hook's additional_dependencies to fix
      the pre-existing [import-untyped] error in lerobot/envs/robotwin.py.

How was this tested (or how to run locally)

  1. Resume from legacy RA-BC JSON checkpoint (regression check for Migrate legacy RA-BC fields in train config loading #3480)
    Confirmed that resuming from a JSON checkpoint correctly migrates sample_weighting and
    sub-options, and that training resumes without error.
  lerobot-train \                                           
    --config_path=./outputs/train/policy_smolbla_rabc/checkpoints/last/pretrained_model/train_config
  .json \                                                                                           
    --steps=60000 \
    --resume=true                                                                                   
  1. New training run with YAML config
    Confirmed that running the command below with the fix applied starts training successfully without
    a JSONDecodeError.
  lerobot-train --config_path=act-training.yaml   

Checklist (required before merge)

  • Linting/formatting run (pre-commit run -a)
  • All tests pass locally (pytest)
  • Documentation updated
  • CI is green
  • Community Review: I have reviewed another contributor's open PR and linked it here: # (insert PR number/link)

Reviewer notes

  • Anything the reviewer should focus on (performance, edge-cases, specific files) or general notes.
  • Anyone in the community is free to review the PR.

_migrate_legacy_rabc_fields was called for all config files, causing
json.load to raise DecodeError when a YAML config was passed to
lerobot-train for a new training run. Guard the block with an
.endswith(".json") check so migration only runs when resuming from
a JSON checkpoint.

Also adds types-PyYAML to pre-commit mypy additional_dependencies
to fix a pre-existing [import-untyped] error in envs/robotwin.py.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions github-actions Bot added the configuration Problems with configuration files or settings label Apr 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

configuration Problems with configuration files or settings

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant