config_loader

General-purpose YAML config loading with $import resolution.

This module provides the config loading infrastructure used by both modelopt.recipe and modelopt.torch.quantization.config. It lives in modelopt.torch.opt (the lowest dependency layer) to avoid circular imports.

Functions

load_config

Load a YAML config and resolve all $import references.

load_config(config_path, *, schema_type=None)

Load a YAML config and resolve all $import references.

This is the primary config loading entry point. It loads the YAML file, resolves any imports / $import directives, and returns the final config dict or list.

schema_type supplies a typing context for import resolution when the file itself has no modelopt-schema comment. It is intentionally not a request to validate the top-level file. Top-level files are validated only when they declare modelopt-schema; imported snippets are stricter and must always declare modelopt-schema.

Parameters:
  • config_path (str | Path | Traversable)

  • schema_type (Any | None)

Return type:

dict[str, Any] | list[Any]