Overview
Theparc_1_train_gen.py script trains a Motion Diffusion Model (MDM) on the current iteration’s motion dataset. This model learns to generate kinematic motions conditioned on local heightmaps and target directions.
Purpose
This is Stage 1 of the PARC pipeline. It:- Trains a motion diffusion model with terrain awareness
- Uses a weighted motion sampler for balanced training across motion types
- Supports training from scratch or fine-tuning from a previous checkpoint
- Logs training progress to Weights & Biases (WandB)
- Saves model checkpoints periodically
Usage
Basic Command
Default Configuration
Command-Line Arguments
| Argument | Required | Description |
|---|---|---|
--config | No | Path to the MDM training configuration YAML file |
Key Configuration Parameters
Training Parameters
batch_size: Number of motion samples per training batchepochs: Total number of training epochsiters_per_epoch: Number of iterations per epochepochs_per_checkpoint: Save checkpoint every N epochsdevice: Training device (e.g., “cuda:0”, “cpu”)
Model Parameters
input_model_path: Path to pretrained model checkpoint (optional, for fine-tuning)motion_lib_file: Path to YAML file containing motion datasetoutput_dir: Directory for saving checkpoints and logs
Sampler Parameters
sampler_save_filepath: Path to save/load the motion sampler pickle filesampler_stats_filepath: Path to save/load sampler statistics for normalizationcreate_dataset_config: Path to dataset creation config (optional)
WandB Integration
use_wandb: Boolean flag to enable Weights & Biases logging
Training Process
Motion Sampler Creation
The script usesMDMHeightfieldContactMotionSampler which:
- Loads motion data from the dataset
- Computes sampling weights for different motion types
- Pre-processes terrain data for augmentation
- Can be cached to disk for faster subsequent runs
Model Initialization
The model can be initialized in two ways:- From scratch: Creates a new MDM model
- From checkpoint: Loads a previous model for fine-tuning (useful for iterative training)
Checkpointing
Checkpoints are saved to{output_dir}/checkpoints/ at regular intervals. A final model is saved to {output_dir}/final_model.ckpt.
Example Configuration
Output Files
After training, the following files are created:Training from Previous Iteration
For iterations after the first, you should provide the previous model as a starting point:- Fine-tuning on the expanded dataset
- Consistent motion normalization across iterations
- Faster convergence
Implementation Details
Key Classes
MDM(parc/motion_generator/mdm.py): The motion diffusion model with local heightmap and target direction conditioningMDMHeightfieldContactMotionSampler(parc/motion_generator/mdm_heightfield_contact_motion_sampler.py): Weighted dataset samplerMDMTransformer(parc/motion_generator/mdm_transformer.py): Transformer architecture for the diffusion model
Fault Handling
The script enables fault handlers for debugging segmentation faults and crashes during training.Usage in PARC Pipeline
Location
scripts/parc_1_train_gen.py