Skip to content

Studio MiniMax-H3-Image: the streamed int8 GEMM route also installs the fused SwiGLU - #18798

Merged
danielhanchen merged 1 commit into
mainfrom
studio-img-gaps-h3streamed
Nov 22, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
studio-img-gaps-h3streamed

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

On the MiniMax-H3-Image streamed tier, every MLP ran the stock forward. This is the tier 24 GB cards get (L4, 3090, a capped Ada). _install in diffusion_minimax_h3_image_speed.py installed the fused SwiGLU only when the levers held the exact string "h3_int8_gemm", but the streamed route records "h3_int8_gemm_streamed". So on those cards value * silu(gate) was written out in bf16, then rotated and quantised again for the down projection, in every block and every step. The resident tiers have fused this since #18090 / #18284.

Change

  • The fused SwiGLU now installs on both int8 GEMM routes.
  • This is safe on the streamed route for three reasons:
    • The pinned streamer keeps the swapped Linears and copies into their parameters. That is the condition int8_gemm_route already requires before it picks the streamed GEMM.
    • producer_linear returns None, which falls back to the stock MLP, for any call whose weight is not on the card.
    • _ready falls back as well whenever the SwiGLU module or the down Linear has a hook. The input projection still runs its own forward, so its hooks are kept.
  • The pageable streamer, which swaps parameters per call, still gets neither the GEMM nor the fused MLP.
  • UNSLOTH_H3_FUSED_SWIGLU=0 keeps the stock MLP, as before.
  • Q / K / V fusion stays resident-only. Merging the three weights into one buffer would leave the streamer copying into parameters the GEMM no longer reads.

Tests

  • test_the_fused_swiglu_installs_on_every_int8_gemm_route (CPU, 5 cases): pinned streamed installs it, resident installs it, UNSLOTH_H3_FUSED_SWIGLU=0, UNSLOTH_H3_IMAGE_INT8_GEMM_STREAMED=0 and the pageable streamer do not.
    • The streamed-pinned case fails on main and passes here (test_differential.py: DISCRIMINATING, no head failures).
  • tests/test_diffusion_minimax_h3_image_speed.py, tests/test_h3_fused_swiglu.py, tests/test_h3_image_resident_route.py: 62 passed.

GPU (Colab L4, 22.5 GB: the streamed tier)

H3-Image at 1024x1024, 6 steps, streamed placement. Main and this branch ran in fresh processes on one VM, sharing one Studio home, with 2 warm-up cells and then 3 interleaved reps per arm. The batch ran twice, on two VMs, after an infrastructure retry.

VM main s/step branch s/step delta
1 0.8628 0.8472 -1.8%
2 0.8652 0.8518 -1.5%

Medians of 9 steady renders per arm.

  • Fused-SwiGLU calls: 1500 to 2100 per cell here, 0 on main.
  • Images: identical to main, with LPIPS 0.000 and torch.equal on all 4 prompts on both VMs. Every arm also repeats itself bit for bit.
  • Peak allocated memory: 17.98 GiB on both arms.

Not proven here

  • sm86 (3090) is not a Colab tier.
  • No larger-card resident-tier comparison ran. It is not needed for accuracy, because the streamed images match main bit for bit.

…sed SwiGLU too

The fused SwiGLU installed only when the levers held the exact string
h3_int8_gemm, so the streamed tier (24 GB cards, h3_int8_gemm_streamed)
ran every MLP on the stock forward: value * silu(gate) materialised, then
its own rotation and act quant before the down projection. The pinned
streamer keeps the swapped Linears and copies into their parameters,
and producer_linear already takes the stock path for any call whose
weight is not on the card, so the streamed route now installs it as the
resident tiers do. UNSLOTH_H3_FUSED_SWIGLU=0 keeps the stock MLP.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 21, 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-21T19:01:03.878103Z 4c39066 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: 4c390667e3

ℹ️ 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".

@danielhanchen
danielhanchen merged commit 1dd5949 into main Nov 22, 2026
@danielhanchen
danielhanchen deleted the studio-img-gaps-h3streamed branch November 22, 2026 01:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant