loader
YAML-driven configuration loading for fastgen distillation pipelines.
YAML is the first-class entry point for DMD configurations — the fastgen library does not expect callers to hand-build Python dicts. Typical usage:
from modelopt.torch.fastgen import DMDConfig, load_dmd_config
# (a) Load a built-in recipe by relative path
cfg = load_dmd_config("general/distillation/dmd2_qwen_image")
# (b) Load a user-provided file
cfg = load_dmd_config("/path/to/my_dmd.yaml")
# (c) Equivalent classmethod
cfg = DMDConfig.from_yaml("/path/to/my_dmd.yaml")
The loader resolves paths in two places, in order:
modelopt_recipes/(the built-in recipes package shipped with ModelOpt) — resolved viaimportlib.resources.files(). Suffixes.yml/.yamlmay be omitted.The filesystem (absolute or working-directory-relative).
Suffixes .yml and .yaml are both accepted.
Functions
Load a YAML file and return the parsed mapping. |
|
Load a YAML file and construct a |
- load_config(config_file)
Load a YAML file and return the parsed mapping.
Mirrors
modelopt.recipe._config_loader.load_config()in spirit but without the ExMy-num-bits post-processing that is specific to quantization recipes.- Parameters:
config_file (str | Path) – YAML path. Suffix is optional; resolution searches the built-in
modelopt_recipes/package first, then the filesystem.- Returns:
The parsed dictionary. An empty file yields
{}.- Return type:
dict[str, Any]
- load_dmd_config(config_file)
Load a YAML file and construct a
DMDConfig.The YAML is validated against
DMDConfig’s Pydantic schema — unknown keys raiseValidationError.Example YAML:
pred_type: flow guidance_scale: 5.0 student_sample_steps: 2 gan_loss_weight_gen: 0.03 sample_t_cfg: time_dist_type: shifted t_list: [0.999, 0.833, 0.0] ema: decay: 0.9999
- Parameters:
config_file (str | Path)
- Return type: