Skip to main content
The lerobot-train command trains robot learning policies using offline datasets.

Command

Location: src/lerobot/scripts/lerobot_train.py

Overview

The training script:
  • Loads datasets from Hugging Face Hub or local storage
  • Trains policies with distributed training support (multi-GPU)
  • Logs metrics to Weights & Biases
  • Saves checkpoints periodically
  • Evaluates policies during training (optional)
  • Supports resuming from checkpoints

Key Options

Dataset Options

str
required
Dataset repository ID (e.g., lerobot/pusht).
str
Local path to dataset. Defaults to $HF_LEROBOT_HOME/{repo_id}.
list[int]
Specific episodes to use for training.Example: --dataset.episodes="[0,1,2,3,4]"
dict
Temporal offsets for observation/action queries.Example:

Policy Options

str
required
Policy type: act, diffusion, tdmpc, vqbet, pi0, etc.
str
Path or Hub ID to pretrained model for fine-tuning.
str
default:"cuda"
Device for training: cpu, cuda, cuda:0, etc.
bool
default:"False"
Use automatic mixed precision training.

Training Options

int
default:"100000"
Number of training steps.
int
default:"32"
Batch size per GPU.
int
default:"4"
Number of dataloader workers.
int
Random seed for reproducibility.
bool
default:"False"
Use deterministic CUDNN operations (slower but reproducible).

Optimizer Options

str
default:"adamw"
Optimizer type: adamw, adam, sgd.
float
default:"1e-4"
Learning rate.
float
default:"0.01"
Weight decay for regularization.
float
default:"10.0"
Gradient clipping norm. Set to 0 to disable.

Checkpoint Options

str
default:"outputs/train"
Directory for saving checkpoints and logs.
bool
default:"True"
Whether to save checkpoints.
int
default:"10000"
Save checkpoint every N steps.
bool
default:"False"
Resume training from latest checkpoint.
str
Specific checkpoint path to resume from.

Logging Options

int
default:"100"
Log metrics every N steps.
bool
default:"True"
Enable Weights & Biases logging.
str
default:"lerobot"
W&B project name.
str
W&B entity (username or team).
str
W&B run name.

Evaluation Options

int
default:"10000"
Evaluate every N steps. Set to 0 to disable.
int
default:"50"
Number of episodes for evaluation.
int
default:"10"
Number of parallel environments for evaluation.
str
Environment type for evaluation: pusht, xarm, aloha, etc.

Usage Examples

Basic Training

Training with Evaluation

Multi-GPU Training

Fine-tuning from Pretrained

Resume from Checkpoint

Training with Custom Dataset Episodes

Training with Delta Timestamps

Training with PEFT (LoRA)

Custom Policy Configuration

Output Structure

The training script creates the following structure:

Configuration File

You can use a YAML configuration file instead of command-line arguments:
Run with:

Programmatic Usage

You can also call the training function programmatically:

Advanced Features

Gradient Accumulation

For effective larger batch sizes:

Mixed Precision Training

Learning Rate Scheduling

See Also