Implementation:Danijar Dreamerv3 Main Configuration
| Knowledge Sources | |
|---|---|
| Domains | Reinforcement_Learning, Configuration |
| Last Updated | 2026-02-15 09:00 GMT |
Overview
Concrete tool for loading and merging hierarchical YAML configuration with CLI overrides provided by the DreamerV3 entry point.
Description
The main() function in dreamerv3/main.py implements the full configuration loading pipeline. It reads configs.yaml using ruamel.yaml, creates an elements.Config from the defaults preset, iterates over requested config names to merge environment and size presets, then applies CLI flag overrides via elements.Flags. The result is a single immutable Config object that is passed to all downstream factory functions.
Usage
Import and call this when launching any DreamerV3 run. The function is the top-level entry point — called directly from the command line or programmatically with an argv list.
Code Reference
Source Location
- Repository: dreamerv3
- File: dreamerv3/main.py
- Lines: L19-66
Signature
def main(argv=None):
"""
Entry point for DreamerV3. Loads config from YAML + CLI, sets up portal,
and dispatches to the appropriate run mode.
Args:
argv: Optional list of CLI arguments. Defaults to sys.argv if None.
Format: [config_name1, config_name2, ..., --param=value, ...]
"""
Import
from dreamerv3.main import main
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| argv | list[str] or None | No | CLI arguments: config preset names followed by --key=value overrides. If None, uses sys.argv. |
| configs.yaml | File on disk | Yes | YAML file at dreamerv3/configs.yaml containing named presets (defaults, atari, dmc, size100M, etc.) |
Outputs
| Name | Type | Description |
|---|---|---|
| config | elements.Config | Fully merged immutable configuration object with all hyperparameters |
| args | elements.Config | Sub-config extracted from config.run with batch_size, batch_length, etc. |
| logdir | str | Created log directory path on disk |
Usage Examples
Command Line
# Train on Atari Pong with default settings
python dreamerv3/main.py --configs defaults atari --task atari_pong
# Train on DMC Walker Walk with 100M model size
python dreamerv3/main.py --configs defaults dmc size100M --task dmc_walker_walk
# Evaluation only from checkpoint
python dreamerv3/main.py --configs defaults atari --script eval_only --from_checkpoint ./logdir/ckpt
Programmatic
from dreamerv3.main import main
# Launch training with specific config
main(['--configs', 'defaults', 'atari', '--task', 'atari_pong'])
# Launch distributed training
main(['--configs', 'defaults', 'atari', '--script', 'parallel', '--task', 'atari_pong'])