Implementation:ARISE Initiative Robomimic ConfigGenerator generate
| Knowledge Sources | |
|---|---|
| Domains | Robotics, Experiment_Management, Hyperparameter_Optimization |
| Last Updated | 2026-02-15 08:00 GMT |
Overview
Concrete tool for generating combinatorial JSON config files and a launch script from accumulated parameter sweep definitions provided by the robomimic hyperparameter utilities module.
Description
The ConfigGenerator.generate method orchestrates the full sweep generation pipeline. It calls _generate_jsons (L202-292) to compute parameter combinations and write JSON configs, then _script_from_jsons (L294-308) to produce the launch bash script.
Internally, _get_parameter_ranges (L128-200) groups parameters by group ID, computes Cartesian product across groups while zipping within groups, and returns all combinations. _generate_jsons loads the base config, applies each combination's overrides using hierarchical key parsing (slash-separated keys), sets experiment names, and writes JSON files.
Usage
Call this method after accumulating all parameters via add_param. Execute the resulting shell script to launch the training sweep.
Code Reference
Source Location
- Repository: robomimic
- File: robomimic/utils/hyperparam_utils.py
- Lines: L80-89 (generate), L128-200 (_get_parameter_ranges), L202-292 (_generate_jsons), L294-308 (_script_from_jsons)
Signature
def generate(self, override_base_name=False):
"""
Generates json configs for the hyperparameter sweep using attributes
@self.parameters, @self.base_config_file, and @self.script_file.
Args:
override_base_name (bool): if True, use empty string as base experiment name
"""
Import
from robomimic.utils.hyperparam_utils import ConfigGenerator
# Usage:
generator = ConfigGenerator(base_config_file="bc.json", script_file="sweep.sh")
generator.add_param(...)
generator.generate()
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| self.parameters | OrderedDict | Yes | Accumulated parameter definitions from add_param calls |
| self.base_config_file | str | Yes | Path to base JSON config |
| self.script_file | str | Yes | Output shell script path |
| override_base_name | bool | No | Use empty base name. Default: False |
Outputs
| Name | Type | Description |
|---|---|---|
| JSON config files | Files | One JSON file per parameter combination in generated_config_dir (or same dir as base config) |
| Shell script | File | Bash script at script_file with one "python train.py --config <path>" per config |
Usage Examples
Complete Sweep Workflow
from robomimic.utils.hyperparam_utils import ConfigGenerator
# 1. Create generator
generator = ConfigGenerator(
base_config_file="robomimic/exps/templates/bc.json",
script_file="/tmp/run_sweep.sh",
generated_config_dir="/tmp/sweep_configs/",
)
# 2. Define sweep parameters
generator.add_param(
key="algo/optim_params/policy/learning_rate/initial",
name="lr", group=1, values=[1e-3, 1e-4],
)
generator.add_param(
key="train/num_epochs", name="ep", group=2, values=[100, 200],
)
# 3. Generate configs (2 × 2 = 4 configs)
generator.generate()
# 4. Launch sweep
# bash /tmp/run_sweep.sh
Launch Generated Script
# Run all sweep configs sequentially
bash /tmp/run_sweep.sh
# Or run in parallel across GPUs
cat /tmp/run_sweep.sh | xargs -I {} -P 4 bash -c '{}'