kempnerforge.config.loader

Config loading: TOML files → dataclass configs with CLI overrides.

Loading pipeline:
  1. Start with default JobConfig

  2. Load TOML file (if provided) and overlay

  3. Apply CLI overrides (–model.dim=512 style)

  4. Return JobConfig instance (call .validate(world_size) at distributed setup time)

Functions

load_config([config_path, cli_args])

Load a JobConfig from optional TOML file + CLI overrides.

load_toml(path)

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.

Parameters:

path (str | Path)

Return type:

dict[str, Any]

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. Cross-config validation (e.g., parallelism vs world_size) requires calling config.validate(world_size=…) separately at distributed setup time.

Parameters:
  • config_path (str | Path | None) – Path to a TOML config file (or None for defaults).

  • cli_args (list[str] | None) – CLI arguments to parse (defaults to sys.argv[1:]).

Returns:

A JobConfig with layered defaults → TOML → CLI overrides.

Return type:

JobConfig