Skip to content

[H3-Image 2/4] feat(fsdp): resolve a Diffusers component's class and folder from the checkpoint's modular index - #394

Open
zhihengy wants to merge 16 commits into
fsdp/denoising-step-index-to-forwardfrom
h3-image/01-loader
Open

zhihengy wants to merge 16 commits into
fsdp/denoising-step-index-to-forwardfrom
h3-image/01-loader

Conversation

@zhihengy

@zhihengy zhihengy commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

[H3-Image 2/4] Stacked on #393. MiniMax-H3-Image keeps its Diffusers DiT in transformer_diffusers/, declared only in modular_model_index.json; its root model_index.json names the engine's native class in transformer/. The Diffusers backend read only the root index and always used the component's name as the folder, so it could not load this release.

Stack: main <- #393 (step index) <- #394 (loader) <- #395 (family) <- #400 (recipe and model page) and #410 (full-weight training), both on #395. #392 (diffusers 0.43.0) has merged, so the stack runs in the default CI image.

What

  • DiffusersModelBackend._resolve_component (was _resolve_component_class) returns a component's class and its folder. It reads the index diffusers' modular loader reads: ModularPipeline.load_config, and when that raises, DiffusionPipeline.load_config as before.
  • The folder is the subfolder of the component's loading spec when its index entry has one, else the component's name.
  • The component is still addressed by its name (--update-weight-target-module transformer), which is also what the rollout engine calls it. Only where its Diffusers weights live changes.

Why

  • The checkpoint's own index says where each layout lives, so there is no per-family table of folder names. [A4]
  • The index is chosen by the same two calls, in the same order, as diffusers' ModularPipeline._load_pipeline_config, so the class and folder are the ones diffusers itself would use, with no Hub probe of miles' own. [A7]
  • The repository a loading spec names (pretrained_model_name_or_path) is not followed: weights come from the checkpoint the run names, so a local mirror or a fine-tuned copy that kept the release's index trains its own weights. [A4]
  • A modular index that sits in a local directory and cannot be read raises. Any other failure to read one (the checkpoint has none; the Hub cannot answer and no copy is cached) falls through to the root index and logs one line with diffusers' reason: a classic checkpoint has no modular index, so raising there would break every existing run. [A2]
  • The cost of the fall-through is a modular checkpoint whose modular index cannot be fetched while its root index can (a partial cache read offline): it resolves through the root index. For MiniMax-H3-Image that fails by name, since the root index's class does not exist in diffusers, and the error says which index was read. A checkpoint whose two indexes both resolve to loadable classes would load the root layout, with the log line as the only sign; none is known.

Behaviour ledger

_resolve_component at this head with diffusers 0.43.0 (no weights loaded), by repo id with the Hub reachable:

checkpoint ships a modular index component class, folder vs before
MiniMaxAI/MiniMax-H3-Image yes transformer MiniMaxH3ImageTransformer2DModel, transformer_diffusers raised "cannot resolve the class"
MiniMaxAI/MiniMax-H3 yes, same entries as the root index transformer, transformer_ref MiniMaxH3Transformer3DModel, component name same
nvidia/Cosmos3-Nano yes transformer Cosmos3OmniTransformer, transformer same
Wan-AI/Wan2.2-T2V-A14B-Diffusers no transformer_2 WanTransformer3DModel, transformer_2 same, plus the log line
Qwen/Qwen-Image, Qwen/Qwen-Image-2.1 no transformer QwenImageTransformer2DModel / QwenImage21Transformer2DModel, transformer same, plus the log line
stabilityai/stable-diffusion-3.5-medium gated, no token and no cached copy on this box transformer diffusers' own error from the root index same
  • From local snapshot directories: 34 of the 35 transformer* components of the Diffusers checkpoints cached on this box resolve to the class and folder they have on main; the 35th is MiniMax-H3-Image.
  • LTX-2.3 loads through MilesModelBackend and is not touched.
  • A component that only the root index lists no longer resolves when the checkpoint ships a modular index: nvidia/Cosmos3-Nano's vision_encoder is in its root index and not in its modular one, and now raises "has no component". miles loads only the components named by --update-weight-target-module, which for Cosmos3 is transformer.
  • A classic checkpoint logs one info line per component load on each rank, and one given by repo id costs one more Hub request per load; the Hub client's retries apply to that request when the Hub is unreachable and HF_HUB_OFFLINE is unset (not timed at this head).
  • The "has no component", "cannot resolve the class" and "names no subfolder" errors name the index file that was read.
  • Not followed from a loading spec: its repository (above) and its revision. A spec that names a variant is refused as untested, since loading without it could read the component's other weights; variant and revision are null in every index read for the table. type_hint-only entries ([null, null, {...}]) are rejected as before.

Validation

CPU, on this box, CI-recipe environment with diffusers 0.43.0, head 3e082dc:

check result
test_model_backend.py 13 passed
...::test_modular_index_names_the_class_and_the_folder[h3-image, h3] new: the two releases' index entries resolve to the real diffusers classes and folders
...::test_component_loads_from_the_checkpoint_not_the_repository_its_spec_names new
...::test_loading_spec_without_a_subfolder_is_rejected, ...::test_loading_spec_with_a_weight_variant_is_rejected new
...::test_checkpoint_without_a_readable_modular_index_reads_model_index_and_logs_it new: the real Hub client, offline, against an empty cache; resolves from the root index with exactly one log record
...::test_cached_modular_checkpoint_resolves_from_its_modular_index_while_the_hub_is_offline new: the real Hub client, offline, against a cache seeded with a modular index, which is the path a run on MiniMaxAI/MiniMax-H3-Image takes
...::test_missing_local_checkpoint_is_reported_as_a_missing_directory, ...::test_unresolvable_class_names_the_index_it_was_read_from new
by hand, on temporary directories: a path that does not exist; a directory with no index; a component the index lacks; a class no library provides; a modular entry without a subfolder; one with a variant; a modular index that is not valid JSON beside a valid root index; a repo id with the Hub unreachable and nothing cached each raises
tests/ci/run_suite.py --hw cpu --suite stage-a-cpu at the stack's two tops, which contain this head 704 passed at #410 (bed8b8d, with the engine branch that PR pins), 686 at #400 (e6259e3)
pre-commit run --all-files passes

Not executed: the GPU suites and the e2e. load_component("transformer") on the released MiniMax-H3-Image snapshot (644 tensors, 33.13 B elements) was run at an earlier head and not repeated; the from_pretrained call is unchanged.

Not in this PR

@zhihengy
zhihengy changed the base branch from chore/bump-diffusers-0.43 to fsdp/denoising-step-index-to-forward November 17, 2026 23:26
@zhihengy zhihengy changed the title [H3-Image 1/3] feat(fsdp): resolve a Diffusers component's class and folder from the checkpoint's modular index [H3-Image 2/4] feat(fsdp): resolve a Diffusers component's class and folder from the checkpoint's modular index Nov 17, 2026
@zhihengy
zhihengy added this pull request to stack #396 November 17, 2026 23:34
… checkpoint's modular index

MiniMax-H3-Image keeps its Diffusers DiT in `transformer_diffusers/`, declared only in `modular_model_index.json`; its root `model_index.json` names the engine's native class in `transformer/`. The backend read only the root index and used the component's name as the folder. It now reads the modular index when the checkpoint ships one, as diffusers' modular loader does, and takes the folder from the component's loading spec. Weights still come from the checkpoint the run names, not from the repository a loading spec names.
…modular index

A classic checkpoint's cache never holds modular_model_index.json, so the probe has no cached copy to fall back to.
Offline it already read as absent, but a gated repo without a token or a stale token raised, and a mistyped local
path surfaced as a repo-id error: loads that worked before the probe failed at trainer start. All three now fall
through to the root index, which loads from the cache or gives diffusers' own error. The class error names the
index it read, so a root-index read of a partially cached modular checkpoint is visible.
… error found

A probe the Hub could not answer (offline, gated, not a repo id) fell through to `model_index.json` without a
trace, and the class error that follows for a checkpoint whose root index names another layout blamed remote
code. The fall-through is logged with its cause, a 404 stays silent, the class error says the installed
library does not provide the class, and the missing-subfolder error names the index it read.
The Hub tests covered only the fall-through to `model_index.json`. A repo id whose modular index is cached is
the path a MiniMax-H3-Image run takes, and returning early when offline would break it with every test green.
diffusers' modular loader passes a spec's `variant` to `from_pretrained`; the backend read only `subfolder`,
so a checkpoint that names one would have loaded the repository's default weights of that component without
a word. No index read so far names a variant, so the load is refused as untested instead of guessed.
"Names a class the installed library does not provide" is false for a null entry and for a type_hint-only
one, which fail in the same place.
…e Hub client's wrapper

Offline mode, a refused connection and a timeout all reach the fall-through as one LocalEntryNotFoundError
that tells the reader to check their connection; the reason is its cause. The log prints that, and the tests
pin both halves of the split: a 404 logs nothing, an offline probe logs why.
@zhihengy zhihengy added the run-ci-e2e Run e2e metric-regression tests on this PR label Nov 20, 2026
…config fall-through

The hand-written probe (hf_hub_download, three Hub exception classes, the cause of a wrapped one) did what
ModularPipeline.load_config followed by DiffusionPipeline.load_config does, which is how diffusers' modular
loader picks the index. A fall-through logs one line whatever its cause, and a modular index that sits in a
local directory and cannot be read raises instead of falling through. The three tests that patched the probe
become one test of the offline fall-through and its log line.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run-ci-e2e Run e2e metric-regression tests on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant