-
Notifications
You must be signed in to change notification settings - Fork 4k
Add SmolVLA example training script #2647
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,206 @@ | ||||||||
| from pathlib import Path | ||||||||
|
|
||||||||
| import torch | ||||||||
|
|
||||||||
| from lerobot.datasets.lerobot_dataset import LeRobotDataset, LeRobotDatasetMetadata | ||||||||
| from lerobot.policies.factory import make_pre_post_processors | ||||||||
| from lerobot.policies.smolvla.configuration_smolvla import SmolVLAConfig | ||||||||
| from lerobot.policies.smolvla.modeling_smolvla import SmolVLAPolicy | ||||||||
|
|
||||||||
|
|
||||||||
| # Output directory for saving the trained model | ||||||||
| output_directory = Path("outputs/train/my_smolvla") | ||||||||
| output_directory.mkdir(parents=True, exist_ok=True) | ||||||||
|
|
||||||||
| device = torch.device("cuda") # or "cuda" or "cpu" | ||||||||
|
||||||||
| device = torch.device("cuda") # or "cuda" or "cpu" | |
| device = torch.device("mps") # or "cuda" or "cpu" |
Copilot
AI
Dec 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hardcoded rename_map is specific to the svla_so100_pickplace dataset and will not work with other datasets that have different camera keys. Consider adding a comment explaining this mapping is dataset-specific and may need adjustment, or checking if the pretrained model's camera keys match the dataset's keys before applying the rename.
Copilot
AI
Dec 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This statement is unreachable.
Copilot
AI
Dec 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent pin_memory condition. This script uses device.type == "cuda" but other training examples (act_training_example.py:64, diffusion_training_example.py:65) use device.type != "cpu". The latter is more inclusive as it also covers MPS devices. Consider changing to device.type != "cpu" for consistency.
| pin_memory=device.type == "cuda", | |
| pin_memory=device.type != "cpu", |
Copilot
AI
Dec 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing gradient clipping before optimizer step. The SmolVLA config defines grad_clip_norm=10 (via get_optimizer_preset), but gradient clipping must be manually applied. Add torch.nn.utils.clip_grad_norm_(policy.parameters(), optimizer_config.grad_clip_norm) after loss.backward() and before optimizer.step().
| loss.backward() | |
| loss.backward() | |
| torch.nn.utils.clip_grad_norm_(policy.parameters(), optimizer_config.grad_clip_norm) |
Copilot
AI
Dec 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent dataset naming. The dataset ID uses 'svla_so100_pickplace' but line 192's comment refers to 'my_smolvla_so101' and line 205 mentions 'SO101 robot'. The documentation at docs/source/smolvla.mdx:40 confirms the dataset is 'svla_so100_pickplace'. The comments should consistently use SO100 to match the dataset, or clarify if SO101 is intentionally different.
Copilot
AI
Dec 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This statement is unreachable.
Copilot
AI
Dec 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent reference to robot type. The comment mentions 'SO101 robot' but the dataset being used is 'svla_so100_pickplace' (line 18). This should be 'SO100 robot' to match the dataset, or clarified if SO101 is a different robot model.
| print("3. Deploy on your SO101 robot!") | |
| print("3. Deploy on your SO100 robot!") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing module-level docstring. Other training examples in this repository (act_training_example.py, diffusion_training_example.py) include a docstring at the top that describes what the script demonstrates. Consider adding a similar docstring such as: """This script demonstrates how to train SmolVLA Policy on a real-world dataset."""