Move cfg.validate() earlier to fix NoneType error with --policy.path#2782
Merged
imstevenpmwork merged 2 commits intoJan 12, 2026
Merged
Conversation
sandhya-cb
pushed a commit
to sandhya-cb/lerobot-clutterbot
that referenced
this pull request
Jan 28, 2026
dohun2665
pushed a commit
to orocapangyo/lerobot
that referenced
this pull request
Feb 28, 2026
lu391see
pushed a commit
to lu391see/lerobot_tactile
that referenced
this pull request
Mar 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Title
fix(train): initialize policy before accelerator creationType / Scope
Summary / Motivation
When training with
--policy.path, thecfg.policyobject remainsNoneuntilcfg.validate()is explicitly called. This is due to the custom argument filtering in the parser that handles loading configs from local or hub paths. Currently, the code attempts to accesscfg.policy.deviceto initialize theAcceleratorbeforecfg.validate()is executed, leading to anAttributeError: 'NoneType' object has no attribute 'device'. This change moves the validation step to the beginning of the training pipeline to ensure the policy is correctly initialized from the provided path before being accessed.Related issues
What changed
cfg.validate()call to the beginning of thetrain()function insrc/lerobot/scripts/lerobot_train.py.cfg.policyis populated when using--policy.pathbefore it's used for device configuration inAccelerator.How was this tested
--policy.pathargument, which previously crashed withAttributeError.How to run locally (reviewer)
Run a training job using a pretrained policy path:
Checklist (required before merge)
pre-commit run -a)pytest)Reviewer notes
draccusdoesn't handle the--policy.pathlogic natively, and ourvalidate()method is what actually loads the policy config into thecfgobject.