IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /max/get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /max/get-started.md).

Python class

ModelManifest

ModelManifest

class max.pipelines.lib.ModelManifest(*args, metadata=None, **kwargs)

source

Bases: dict[str, MAXModelConfig]

Registry mapping semantic role strings to MAXModelConfig instances.

Each model is identified by a role string (e.g. "main", "draft", "vae", "unet"). Single-model pipelines use the "main" key by convention; multi-component pipelines (diffusion, speculative decoding) store models under their respective roles.

ModelManifest is a dict[str, MAXModelConfig] subclass, so standard dict operations ([], in, len, items, etc.) work directly.

For diffusion pipelines constructed from model_index.json, the metadata property exposes non-component entries (e.g. _class_name, _diffusers_version, is_distilled) as a plain dict.

Parameters:

clear()

clear()

source

Remove all model configs from the manifest.

Return type:

None

from_model_path()

classmethod from_model_path(model_path, revision=None, **kwargs)

source

Create a registry from a single model path.

Inspects model_path for a model_index.json before constructing any MAXModelConfig.

If the model is a diffusion pipeline (has a model_index.json), the registry is automatically expanded into per-component MAXModelConfig instances. Extra kwargs are forwarded to each component’s MAXModelConfig.

For single-model repos, a MAXModelConfig is constructed from model_path and any extra kwargs, then stored under the "main" key.

Parameters:

  • model_path (str) – HuggingFace repo ID or local path to the model.
  • revision (str | None) – Optional HuggingFace repo revision (branch, tag, or commit hash). Defaults to the HuggingFace Hub default.
  • **kwargs (Any) – Additional keyword arguments forwarded to MAXModelConfig (only valid for single-model repos).

Returns:

A new ModelManifest. For transformers-style models this has a single "main" entry; for diffusion models it contains one entry per component.

Return type:

ModelManifest

loader()

loader()

source

Returns a WeightLoader over the role-prefixed union.

Public entry point for multi-component pipelines (diffusion, speculative decoding). Each role’s loader is exposed under its dotted role prefix, so a query like "transformer.blocks.0.attn.qkv_proj.weight" routes to the transformer config’s loader with "blocks.0.attn.qkv_proj.weight".

Single-model pipelines should call manifest["main"].loader() instead – the role prefix is not useful when there’s only one source and the Module tree’s parameter names don’t carry it.

Resolution is lazy: per-role loaders defer to the underlying Weights source, so weight bytes only page in when the Module’s adapter chain actually queries them.

Returns:

A WeightLoader resolving f"{role}.{name}" keys against the per-role source loaders.

Return type:

WeightLoader

log_model_info()

log_model_info()

source

Logs model configuration information for every model in the manifest.

Iterates over each role and delegates to MAXModelConfig.log_model_info() for per-model details.

Return type:

None

main_architecture_name

property main_architecture_name: str

source

Returns the main architecture class name.

For non-diffusion models (those with a "main" key), delegates to MAXModelConfig.architecture_name which returns architectures[0] from the HuggingFace config.

For diffusion pipelines (no "main" key), returns metadata["_class_name"] (e.g. "FluxPipeline").

Raises:

ValueError – If the architecture name cannot be determined.

metadata

property metadata: dict[str, Any]

source

Non-component entries from model_index.json.

For diffusion pipelines built via from_model_path, this contains every key/value pair from model_index.json that is not a component (e.g. _class_name, _diffusers_version, is_distilled). For non-diffusion manifests, returns an empty dict.

model_name

property model_name: str

source

Returns the served model name for metrics and API responses.

For single-model pipelines ("main" key), delegates to MAXModelConfig.model_name. For diffusion pipelines, returns model_path from the first component config.

pop()

pop(*args)

source

Remove and return a model config by key.

Parameters:

args (Any)

Return type:

Any

resolve()

resolve()

source

Validates and resolves every config in the manifest.

Delegates to MAXModelConfig.resolve() for each component.

Return type:

None

total_weights_size

property total_weights_size: int

source

Total weight size in bytes across all components.

Walks every MAXModelConfig in the manifest and sums weights_size(). Components with no weight files (e.g. schedulers) contribute zero.

Raises:

RuntimeError – If the manifest has not been resolved via resolve() first.

update()

update(*args, **kwargs)

source

Update the manifest with new model configs.

Parameters:

Return type:

None

with_override()

with_override(role, config=None, **field_overrides)

source

Return a new manifest with the given role updated.

Three usage patterns:

  1. Partial field update on an existing component:
    manifest.with_override("transformer",
        weight_path=[Path("w.safetensors")],
        quantization_encoding="float4_e2m1fnx2",
    )
  2. Full replacement or addition of a component:
    manifest.with_override("draft",
        config=MAXModelConfig(model_path="org/draft"),
    )
  3. Add/replace with additional field tweaks:
    manifest.with_override("draft",
        config=base_cfg,
        quantization_encoding="q4_0",
    )

Parameters:

  • role (str) – The semantic role string identifying the component.
  • config (MAXModelConfig | None) – A complete MAXModelConfig to use as the base. When None, the existing config for role is used (the role must already exist).
  • **field_overrides (Any) – Individual field values to set on the config via model_copy(update=...).

Returns:

A new ModelManifest — the original is not modified.

Raises:

ValueError – If config is None and role does not exist, or if neither config nor field_overrides are provided.

Return type:

ModelManifest