loader#
YAML-driven configuration loading for fastgen distillation pipelines.
YAML is the first-class entry point for fastgen configurations — the library does not expect callers to hand-build Python dicts. Typical usage:
from modelopt.torch.fastgen import DMDConfig, PDDConfig, load_dmd_config, load_pdd_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")
# (d) PDD uses the same resolver with its own schema
pdd_cfg = PDDConfig.from_yaml("general/distillation/pdd_qwen_image")
The loader resolves paths in two places, in order:
The filesystem (absolute or working-directory-relative).
modelopt_recipes/(the built-in recipes package shipped with ModelOpt) — resolved viaimportlib.resources.files()for relative paths.
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 a YAML file and construct a validated |
- 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 filesystem first, then the built-in
modelopt_recipes/package.- 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: