kempnerforge.config.loader¶
Config loading: TOML files → dataclass configs with CLI overrides.
- Loading pipeline:
Start from the dataclass field defaults
Import the modules listed in the plugins key (registry side effects)
Load TOML file (if provided) and lay the CLI overrides (–model.dim=512 style) over it
Build the config once from the field defaults and the merged layers, so each check, and each default that __post_init__ derives from other fields, reads them together
Return JobConfig instance (call .validate(world_size) at distributed setup time)
Functions
|
Load a JobConfig from optional TOML file + CLI overrides. |
|
Load a TOML file and return its contents as a dict. |
- kempnerforge.config.loader.load_toml(path)[source]¶
Load a TOML file and return its contents as a dict.
- kempnerforge.config.loader.load_config(config_path=None, cli_args=None)[source]¶
Load a JobConfig from optional TOML file + CLI overrides.
The returned config has all sub-config __post_init__ validations applied. They run once, on the TOML with the CLI overrides laid over it, so a check that compares fields reads them whichever layer sets each. Each section is built from its field defaults and the merged layers, so a default that
__post_init__derives from other fields, such asmodel.n_kv_headsfrommodel.n_heads, follows them whichever layer sets them. Cross-config validation (e.g., parallelism vs world_size) requires calling config.validate(world_size=…) separately at distributed setup time.Modules named by the top-level
pluginskey are imported before the overlay, so components they register are visible to those validations.