Skip to content

Studio: fix MiniMax-H3-Image downloads, explicit FP8/INT8 and 16 MP sizes - #17563

Merged
danielhanchen merged 9 commits into
unslothai:mainfrom
oobabooga:studio-h3-image-loader-fixes
Nov 12, 2026
Merged

danielhanchen merged 9 commits into
unslothai:mainfrom
oobabooga:studio-h3-image-loader-fixes

Conversation

@oobabooga

@oobabooga oobabooga commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Fixes four problems with MiniMax-H3-Image (#17453):

  • On a GPU with 24 to 40 GB, picking the model downloads 135 GB, and then the load fails for lack of RAM.
  • On a 48 GB GPU, auto picks the bf16 DiT, and the load fails for lack of RAM.
  • Explicit FP8 or INT8 under Precision is always refused.
  • Every 16 MP size in the size menu is refused.

Downloads

The image repo bundles a bf16 text encoder (66.7 GB) and a second, converted copy of the DiT and VAE. The H3 loader reads none of them. The download plan staged all of them anyway, along with the bf16 DiT, even on cards where the load then uses the hosted INT8 DiT. The loader then found the bundled encoder in the cache and used it instead of the 27 GB INT8 one. With 64 GB of RAM, the load needs 78 GB and fails.

Now the plan stages what the loader will open, using the loader's own rules:

  • From the image repo, only processor, tokenizer, transformer and vae, in the native layout. The converted layout gives bit-identical images, so the loader no longer fetches it.
  • The hosted INT8 encoder (or the H3 repo's bf16 encoder when bf16 is asked for).
  • The hosted INT8 or FP8 DiT when the card will run one, instead of the bf16 shards.

The loader uses a text_encoder/ folder only for a local-folder load, which also fixes caches that already hold the bundled encoder. If the plan cannot list the encoder or settle the DiT scheme, it sets plan_failed rather than reporting the model as fully downloaded.

Auto on 48 GB cards

Auto picked the bf16 DiT whenever it fit the card by itself (40.3 GB plus working memory). It did not count the encoder. On a 48 GB card the loader then kept the DiT in system RAM and swapped it in, which needs about 74 GB of RAM, so the load failed with 70 GB available. Auto now takes bf16 only when it stays on the card beside the encoder, and INT8 otherwise. Cards of 80 GB and up still get bf16. A 48 GB card with enough RAM used to run bf16 from system RAM; it now runs INT8 on the card, which is faster.

Explicit FP8 and INT8

The load route checked explicit precision against the generic torchao path, which refuses any model that cannot run torch.compile. H3 never compiles and quantizes in its own loader, so FP8 and INT8 always got a 409. H3 now skips that check. It refuses only what it cannot run: other schemes, FP8 below SM 8.9, and any scheme without torchao. Before, its own resolver would quietly fall back to auto, INT8 or bf16 in those cases.

16 MP sizes

The generate request capped each side at 2752, so H3's 16 MP sizes (up to 6272) got a 422 before H3's own size check ran. The presets and the chat image tool copied the same cap. All three now use one MAX_REQUEST_SIDE (6272, the largest side of any family). Each family still enforces its own limit.

Not changed

Auto still prefers bf16, as #17453 chose for quality, and falls back to INT8. So on FP8-capable cards the picker row "MiniMax-H3-Image (Fast FP8)" never loads FP8 by default. Changing auto or the label is a separate decision.

Testing

Tested live on a B200 against main, and on an RTX 6000 Ada (48 GB, about 70 GB of RAM). On the B200, smaller cards were emulated by holding the rest of the VRAM, with a 64 GB RAM budget.

Case main This PR
Pick the model, 24 GB card, empty cache Downloads 148 GB, then the load fails Downloads 47 GB, loads, generates
Pick the model, RTX 6000 Ada The load fails (needs 71 GB of RAM) Loads INT8 on the card, generates
Pick the model, full B200, empty cache Downloads 154 GB Downloads 90 GB
Precision FP8 / INT8 Refused Loads; 3.7 s / 4.8 s per 2048 image
16 MP preset (4096 x 4096) Refused Generates in 12.5 s
main This PR
h3_image_24gb_main h3_image_24gb_this_pr

New tests cover the plan, the cached bundled encoder, the auto choice on 48 GB cards, the precision check, plan_failed and the size limit. The plan, cached-encoder and precision-check tests fail on main. The diffusion and H3 backend suites pass, except three tests that also fail on main or pass when run alone.

Colab verification (base vs head)

Real Studio routes (download plan, load, generate) on an empty HF cache per tree, then DiffusionBackend loads from exactly the files the plan listed. Base is the merge base 5d5c1381b0, head is 49eaddbeae (later commits change comments only).

Case Base This PR
L4 (24 GB, 57 GB RAM): plan, auto 135.37 GB (bundled bf16 encoder 66.73 + bf16 DiT 66.28 + VAE) 49.77 GB (hosted INT8 encoder 27.14 + hosted INT8 DiT 20.27 + processor / tokenizer / VAE)
L4: auto load with the bundled encoder in the cache Refused: needs about 78 GB of free system memory, 53.7 GB available Loads in 44.6 s on the INT8 encoder; the bundled copy is ignored
L4: auto, 2048 image not reachable 149.3 s, peak VRAM 19.4 GB, system RAM 14.1 GB; 0.03 GB fetched beyond the plan
L4: explicit FP8 / INT8 409 on the plan and load routes FP8 99.7 s per 2048 image, INT8 144.3 s, VRAM 19.4 GB
4096 x 4096 generate request 422 (less than or equal to 2752) Passes validation; the L4 then refuses it in H3-Image's own memory check (needs about 18 GB of working memory)
A100 40 GB: auto plan 135.37 GB; FP8 / INT8 409 INT8 resident, load 164.6 s, 13.33 s per 2048 image, VRAM 36.9 GB; explicit FP8 refused (needs compute capability 8.9)

One render per cell, no repeats. Not run here: the 48 GB card rule, a 4096 render, Windows / macOS / AMD.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-12T07:30:45.353733Z fdea2ab Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@oobabooga
oobabooga marked this pull request as draft November 11, 2026 22:47
@oobabooga
oobabooga marked this pull request as ready for review November 11, 2026 22:52
chatgpt-codex-connector[bot]

This comment was marked as resolved.

@oobabooga

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: add7be8d19

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +6366 to +6368
"text_encoder": (
H3_IMAGE_TEXT_ENCODER_REPO,
lambda name: name.startswith("text_encoder/"),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Resolve the planned encoder source from the image model index

For an H3-image Hub repo whose model_index.json points text_encoder at a different repository, selecting bf16 (text_encoder_quant="none") stages the hardcoded default encoder here. However, load_minimax_h3_image_pipeline honors the repository declared in that index and now ignores the image snapshot's bundled encoder. Completing this plan therefore leaves the required encoder uncached: a cache-only load fails, while an online load downloads another encoder after staging the unused default. Resolve the encoder repository from the same index before planning its files.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No published MiniMax-H3-Image repo names a different encoder repo: MiniMaxAI/MiniMax-H3-Image and the third-party copies that ship a model_index.json all point text_encoder at MiniMaxAI/MiniMax-H3, which is H3_IMAGE_TEXT_ENCODER_REPO. The case is hypothetical, so the plan keeps the constant.

Comment on lines +1695 to +1697
return (root / native / "config.json").is_file() or not (
root / converted / "config.json"
).is_file()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Fall back to converted weights when native folders are config-only

For a local converted checkpoint that retains transformer/config.json but has pruned the native weights, this predicate selects the incomplete native directory even when transformer_diffusers/ contains complete weights. Previously the loader selected the converted copy whenever its config existed; it now reaches native_shard_map on the config-only directory and raises FileNotFoundError. The same selection issue affects the VAE. Check for usable native weights, rather than just a config, before preferring native over an available converted checkpoint.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No real input reaches this. A Hub load fetches transformer/* and vae/* before _native_layout runs, so the native folder is complete there. The released repo carries full native weights. A local folder only reaches this state if someone deletes the native shards and keeps their config by hand.

@oobabooga

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: add7be8d19

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +7353 to +7357
self._h3_image_planned_dit_scheme(
fam,
load_kwargs.get("transformer_quant"),
load_kwargs.get("gpu_ordinal"),
plan_failures,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Resolve cached H3 DiTs from the same roots as the plan

After Studio's cache directory changes in a running process, the hosted INT8/FP8 DiT can remain only in the import-time Hugging Face cache. This branch now lets the plan omit the dense DiT, while add_missing_entry() also omits the hosted download because its probes search both cache roots. However, H3's hosted_prequant_available(..., local_files_only=True) checks only the live cache_dir, so a cache-only load rejects that cached DiT and falls back to bf16 shards the plan no longer stages. If those shards are absent, loading fails despite staging completing successfully. Make the H3 availability check use the same two-root lookup, or stage the artifact into the live root, before narrowing the plan.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs four things at once: a cache-folder change inside a running process, a hosted DiT left only in the old folder, a load that is not user-initiated (the only cache-only load), and no released shards. A user-initiated load is online, finds the hosted file through _hub_file_exists, and loads it. The single-root probe in hosted_prequant_available is the same as on main and is not touched by this PR.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: add7be8d19

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@oobabooga
oobabooga marked this pull request as draft November 12, 2026 01:01
chatgpt-codex-connector[bot]

This comment was marked as resolved.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Nov 12, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Nov 12, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Nov 12, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: 49eaddbeae

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@oobabooga
oobabooga marked this pull request as ready for review November 12, 2026 02:11
@danielhanchen danielhanchen self-assigned this Nov 12, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: f400e819b0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

[skip ci]
@unslothai unslothai deleted a comment from oobabooga Nov 12, 2026
@unslothai unslothai deleted a comment from oobabooga Nov 12, 2026
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fdea2abb3c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +6409 to +6410
reclaimable_host_gb = pipeline_host_mib(
getattr(getattr(self, "_state", None), "pipe", None)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Credit chat and video RAM in the H3 download plan

For an auto H3 pick on an 80-GB-or-larger GPU while a chat/video model holds host RAM, crediting only self._state.pipe can select INT8 even though handoff will free enough RAM for bf16—for example, 20 GB free during planning and 64 GB after eviction. The default /images/load handoff evicts that other owner before H3 starts, and load_minimax_h3_image_pipeline() re-resolves auto against the larger host budget and selects bf16. Since the new plan omitted the dense shards, an online UI load then downloads another ~66 GB inline while leaving the staged INT8 DiT unused; a cache-only load fails instead. Include the RAM of all residents the handoff will evict, or preserve the planned scheme through loading.

Useful? React with 👍 / 👎.

Chroma01 pushed a commit to Chroma01/unsloth that referenced this pull request Nov 12, 2026
…thai#17579)

## Summary

`studio/backend/vendor/` holds three vendored packages whose files are
pinned by sha256 in their manifests
(`diffusers_minimax_h3_image_manifest.json`, `laya_manifest.json`,
`truststore_manifest.json`). `.gitattributes` keeps `*.py` at LF, but
the manifests also pin the license files (`LICENSE.diffusers`,
`LICENSE.laya`, `truststore/LICENSE`). A Windows clone with
`core.autocrlf=true` rewrites those to CRLF, so their digests stop
matching, and `test_vendored_files_match_the_manifest` fails on the
windows-latest runner (seen on the unslothai#17563 staging run: 1 failed, 900
passed).

This adds `studio/backend/vendor/** -text`, the same rule the repo
already uses for `assets/docs_ui/**` and `requirements/engines/**`.
Checked-in bytes are unchanged, so Linux and macOS checkouts are
identical before and after.

## Evidence

A clone with `core.autocrlf=true` (what the Windows runners use), every
manifest entry hashed:

| Arm | Result |
|---|---|
| main `20686a0d92` | 3 mismatches: `LICENSE.diffusers`, `LICENSE.laya`,
`truststore/LICENSE` |
| this branch | all entries match |

The simulated CRLF hash of `LICENSE.diffusers` on main
(`e28423074ef7...`) is the exact digest the real windows-latest runner
reported when this test failed on the unslothai#17563 staging run; on this branch
the file hashes to the manifest's `f9e2070c2475...`.

## Not covered

- Existing Windows clones keep their CRLF copies until those files are
checked out again.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants