Skip to content

Studio: keep MiniMax-H3 video Auto INT8 attention off on sm89 (audio drift past the L4 floor) - #19098

Merged
danielhanchen merged 2 commits into
mainfrom
studio-h3-int8-audio-rows
Nov 24, 2026
Merged

danielhanchen merged 2 commits into
mainfrom
studio-h3-int8-audio-rows

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Summary

MiniMax-H3 video's default (Auto) INT8 attention, made the default in #18248, moves the generated audio past the bf16 noise floor on NVIDIA L4 (sm89). This PR keeps Auto INT8 attention off for H3 video on sm89 only. Every other card, including the unmeasured sm86, behaves exactly as on main. Explicit int8_attention="on" and UNSLOTH_DIFFUSION_INT8_ATTENTION_KERNEL=1 still engage the kernel on every card.

Cost: sm89 gives up INT8 attention's denoise speedup under Auto. On L4 INT8 cut denoise time by 23.4% in this run (241 s vs 315 s per clip) and by 22.8% in the #18248 recheck.

Why sm89, and only there

The bar is our standing rule: each lever is scored against the same card's own bf16 spread. That spread is the int8_attention="off" render against an off render that only swaps the bf16 attention kernel (flash vs cuDNN). Measured over 12 rows (6 prompts x 2 seeds, Studio defaults: 20 steps, 960x544x124), with everything scored against the off render:

card INT8 Auto audio log-mel L1 bf16 floor Auto vs floor (paired)
L4 (sm89) 0.481 0.329 +0.152 [+0.050, +0.276], worse on 11/12 rows, p 0.01
A100-40GB (sm80) 0.426 0.404 +0.022 [-0.056, +0.101], 6/12, p 0.68
RTX PRO 6000 (sm120) 0.441 0.454 -0.014 [-0.102, +0.071], 6/12, p 0.91

The INT8 audio drift against off is about the same on every card: log-mel L1 0.40-0.44 on L4, A100 and RTX PRO 6000. The INT8 kernel's bits do not depend on the card. Only L4's own bf16 floor (0.24-0.33) is tight enough to flag it. On L4, MCD was 18.1 vs 12.3 dB and waveform SNR 7.6 vs 11.2 dB. Frames lean worse there too (LPIPS 0.215 vs 0.169, 10/12 rows, p 0.06). A100 and RTX PRO 6000 are inside their floors on frames and audio.

What was tried first

Keeping INT8 on the video query rows only (text and audio query rows recomputed on bf16 attention against the full K / V) does not fix it end to end, so it is not in this PR.

  • Diagnosis on L4 (teacher-forced, one prompt). It pointed at the audio query rows' own attention. With only the video rows on bf16, the per-step audio velocity error stayed at the INT8 level (0.0300 vs 0.0297). With the audio rows on bf16, it came close to the kernel-swap floor (0.0270 vs 0.0259).
  • End to end (free-running, 20 steps). The renders still diverged as much as with INT8 on every row:
card head with split vs main Auto, audio log-mel L1 (paired) denoise time vs main Auto
L4 (12 rows) 0.480 vs 0.481, -0.001 [-0.054, +0.051], p 0.97 +2.0%
RTX PRO 6000 (12 rows) 0.419 vs 0.441, -0.022 [-0.100, +0.055], p 0.57 +2.9% (A/A spread 0.01%)

Changes

  • video_minimax_h3_attn.py:
    • H3_INT8_AUTO_OFF_ARCHS = {(8, 9)}.
    • h3_int8_auto_off_reason(capability) and cuda_capability(device).
    • h3_int8_load_gate(*, mode, attention_backend, auto_attention, speed_on, hosted_int8, comfy_checkpoint, adapters, capability) -> H3Int8Gate(forced, auto, reason): the H3 video load's INT8 attention decision, moved out of video.py so it can be tested directly. Same conditions and status reasons as before, plus the arch check under Auto.
  • video.py, H3 video load:
    • Calls h3_int8_load_gate with the load's own card and uses its forced / auto / reason. The forced path (explicit On / env 1 / an explicit INT8 backend pick) never looks at the arch.
    • When every other Auto condition held, the int8_attention status reason says why it is off: Auto keeps it off for MiniMax-H3 video on sm89 (it moved the audio past the bf16 noise floor on L4); int8_attention='on' engages it.

Verified on L4

This branch under Auto against int8_attention="off", one prompt plus warm-up, fresh process per arm:

  • Status: int8_attention reads {"value": "off", "source": "auto", "engaged": false, "reason": "Auto keeps it off for MiniMax-H3 video on sm89 (it moved the audio past the bf16 noise floor on L4); int8_attention='on' engages it"}.
  • Frames: bit-identical to off (same frames MD5, LPIPS 0).
  • Audio: log-mel L1 0.002 / 0.004 against off. That is inside L4's off-vs-off repeat spread (0.001-0.004); L4 audio is not bit-reproducible run to run.
  • Denoise time: 309.4 s vs 309.6 s.

Tests

studio/backend/tests/test_h3_int8_auto_arch.py (CPU, 33 cases) drives h3_int8_load_gate directly:

  • sm89 under Auto: not forced, not raced, the reason names sm89, the audio and the explicit On override
  • sm80, sm86, sm90, sm100, sm120, sm75 and an unknown / ROCm card under Auto: raced as on main, no reason
  • the off set is exactly sm89
  • explicit On, env 1 (also env 0 with a per-load On) and an explicit INT8 backend pick force the kernel on sm89
  • env 0, a per-load Off, and a per-load Off over env 1 stay off with no reason
  • speed off, an explicit attention pick and an off-config load (no hosted INT8, Comfy checkpoint, adapters) keep their existing reasons on every arch
  • one AST check that the H3 video load calls the gate once, with the load card's capability, and uses forced, auto and reason

All 33 fail on main (the gate does not exist there) and pass on this branch. An exhaustive check of the gate against the inline gate it replaces (this PR's first commit) over 720 input combinations differs only in the sm86 Auto cell, now raced as on main. The existing test_diffusion_int8_attention_toggle.py source check now reads the gate's inputs at the call site. The INT8 attention toggle, auto, families, H3 attention and H3 forward suites pass (236 passed, 34 skipped).

Not tested

  • sm86 (RTX 3090 / A10 / A40): never measured, so Auto is left as on main there. It may need the same gate once measured against its own bf16 floor.
  • Other Ada parts (RTX 4090, RTX 6000 Ada): only the L4 was measured. They share sm89, so the gate applies to them.
  • T4 (sm75), H100 (sm90), B200 (sm100): not measured. Auto behaves as on main there.
  • i2v / reference workflows and the 10-step setting: not re-measured. There was no listening test.

On L4 (sm89) the default INT8 attention moved the generated audio past the
bf16 noise floor (12 rows at Studio defaults, log-mel L1 vs off 0.481 vs
0.329, 11/12 rows worse). Recomputing the text and audio query rows on
torch attention did not bring it back end to end, so Auto keeps the kernel
off on sm89 and on the unmeasured sm86. A100 (sm80) and RTX PRO 6000
(sm120) measured inside the floor and keep Auto as before.

int8_attention="on" and UNSLOTH_DIFFUSION_INT8_ATTENTION_KERNEL=1 still
engage the kernel on every card; the int8_attention status reason says
why Auto left it off.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 23, 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-23T21:44:56.286825Z 6b840ad 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.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 6e4148fa34

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

Move the H3 video load's INT8 attention decision into h3_int8_load_gate so it is tested by behaviour, and drop sm86 from H3_INT8_AUTO_OFF_ARCHS: it was never measured, so Auto keeps main's behaviour there.

[skip ci]
@danielhanchen danielhanchen changed the title Studio: keep MiniMax-H3 video Auto INT8 attention off on sm89 / sm86 (audio drift past the L4 floor) Studio: keep MiniMax-H3 video Auto INT8 attention off on sm89 (audio drift past the L4 floor) Nov 23, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 6b840ad5ff

ℹ️ 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 1fe75ad into main Nov 24, 2026
@danielhanchen
danielhanchen deleted the studio-h3-int8-audio-rows branch November 24, 2026 01:35
danielhanchen added a commit that referenced this pull request Nov 24, 2026
…t on every card (restores the Ada speedup, L4 denoise -19.4%) (#19344)

## Summary

MiniMax-H3 video under Auto now runs the first 4 denoise steps of every
render on the 16-bit attention kernel and INT8 attention after, on every
card where Auto engages the INT8 kernel. This replaces the sm89-only
Auto off switch from #19098, so Ada cards (L4, RTX 4090, RTX 6000 Ada)
get the INT8 speedup back. Explicit `int8_attention="on"` keeps INT8 on
every step; Off is unchanged.

On L4 the denoise time goes from 315.5 s (off, what main runs on sm89
since #19098) to 254.3 s (-19.4%), 85% of the INT8-every-step speedup.
On A100-40 it goes from 86.0 s to 75.0 s (-12.7%), 84% of it.

## Root cause

sm89 does not drift more than other cards. #19098 flagged it only
because its noise floor is tighter.

- The INT8 kernel is bit-identical on L4 (sm89) and A100-40 (sm80) on
the same inputs: a synthetic input at H3's production shape (19315
tokens, 8 heads) and one real captured H3 call (step 0, block 1, the
worst head of 56, 4096 query rows against all 19315 keys) give the same
output SHA-256 on both cards. INT8 error vs fp64 is 0.0234 / 0.0167 on
both, against 0.0011 / 0.0018 for bf16 flash. The per-card kernel
configs differ only in launch shape and instruction order, H3 takes the
plain kernel path (no attention-sink race) on every card, and the
long-call race picks the same 6144-token floor on L4 and A100.
- INT8's distance from off is about the same on every card (audio
log-mel L1 0.43-0.48 on L4, A100 and RTX PRO 6000 in #19098). What
differs is the cuDNN kernel-swap floor it was compared with: 0.33 on L4,
0.40 on A100, 0.45 on RTX PRO 6000.
- Against an fp32-attention reference, INT8 on every step fails on A100
as well (frames +0.039 [+0.004, +0.083], audio +0.081 [+0.005, +0.158]),
so an arch-specific rule is not justified.
- Teacher-forced on L4 (the #19098 diagnosis run), step 0 carries 4.2x
the kernel-swap floor's audio velocity error; later steps are 0.8-1.6x.
Keeping the first steps on 16-bit attention removes most of the drift.

## Changes

- `video_minimax_h3_attn.py`:
- `H3_INT8_EXACT_START_STEPS = 4`, `h3_int8_exact_steps()` and
`H3Int8Gate.exact_steps`. `H3_INT8_AUTO_OFF_ARCHS` is now empty.
- `install_int8_exact_start(transformer, pipe, steps)`: routes the
strided processors' INT8 calls through
`unsloth_h3::int8_attention_exact_start`, an opaque custom op that runs
the processor's own 16-bit kernel (flash / cuDNN pinned as the processor
runs it) or the INT8 kernel, chosen per call from the denoiser's own
flag tensor. A forward pre-hook on the denoiser sets that flag through a
second opaque op (`unsloth_h3::int8_exact_start_tick`) from the render's
video scheduler step index, so no compiled block guards or recompiles on
the step, a caller compiling a function around the whole denoiser
(fullgraph included) traces it without a break, and two denoisers never
read each other's route. Exact steps count from the first step the
render runs, so a render that starts at a later grid point still gets 4.
The op returns V's dtype on both branches (autocast off inside it),
matching its fake.
- The op refuses a CUDA graph capture on the operand's card, and the
denoiser is marked so the block and whole-forward graph paths refuse it
with the reason in the status (a replayed graph would freeze one route
for every step). H3 video already declines graphs by default.
- `finish_h3_int8_auto`, called by the load: if the exact start raises
or installs on no processor, INT8 attention is removed for the load
(never INT8 on every step under Auto) and the status says why.
- `video.py`: after Auto engages INT8 on the H3 denoiser, calls
`finish_h3_int8_auto`. The `int8_attention` status reason names the
exact start, for example `unsloth_int8 (cuda) on 52 attention modules,
the first 4 denoise steps on 16-bit attention`.
- `diffusion_cuda_graph.py`: the graph eligibility checks refuse a
denoiser that carries `_unsloth_cuda_graph_unsafe`.
- `UNSLOTH_H3_INT8_EXACT_STEPS=N` overrides the step count under Auto
(`0` = INT8 on every step, as before #19098); a value that is not a
count keeps the default with a warning.
- `diffusion_int8_attention_dispatch.py`: an out-of-memory probe in the
long / family race is retried once; a second one loses that call only
and is no longer cached for the life of the process (one transient OOM
used to decline INT8 for every later load).
- ROCm: Auto never engages INT8 attention for H3 there (the H3 race is
CUDA-kernel only), so nothing changes on ROCm.

## Evidence

Colab, Studio at this branch, Studio defaults (960x544x124, 20 steps),
the same 12 rows as #19098 (6 prompts x 2 seeds), fresh process per arm.
Arms: REF (int8 off, fp32-math attention on every H3 attention call),
OFF (int8 off), the cuDNN floor (off with the cuDNN kernel), INT8 every
step, and exact start 2 / 4. Every candidate render engaged INT8 on 52
modules and took the exact path for 50 x K calls and INT8 for the rest;
REF ran fp32 attention on every call; OFF, floor and REF never engaged
INT8.

### Rule fixed before running (fp32 reference)

d = metric(X vs REF) minus metric(OFF vs REF), paired bootstrap 95% CI;
pass if the CI upper bound is at or below the floor |mean(cuDNN minus
OFF)|.

| card | arm | frames d [95% CI] | floor | audio d [95% CI] | floor |
|---|---|---|---|---|---|
| L4 | INT8 every step | +0.057 [+0.024, +0.094] | 0.004 | +0.063
[-0.045, +0.175] | 0.056 |
| L4 | exact start 2 | +0.002 [-0.012, +0.014] | 0.004 | -0.000 [-0.047,
+0.046] | 0.056 |
| L4 | exact start 4 | -0.001 [-0.014, +0.015] | 0.004 | +0.008 [-0.027,
+0.043] | 0.056 |
| A100-40 | INT8 every step | +0.039 [+0.004, +0.083] | 0.013 | +0.081
[+0.005, +0.158] | 0.003 |
| A100-40 | exact start 2 | +0.008 [-0.017, +0.040] | 0.013 | +0.028
[-0.037, +0.102] | 0.003 |
| A100-40 | exact start 4 | +0.005 [-0.003, +0.015] | 0.013 | +0.047
[+0.002, +0.092] | 0.003 |

No arm meets the rule on either card at 12 rows. Exact start 4 is
indistinguishable from off against the fp32 reference on L4 (both CIs
straddle 0) and misses only the frames floor bound (upper +0.015 vs
0.004). The A100 audio floor is degenerate: OFF and the cuDNN arm are on
average equally far from the reference (0.003), while their paired
difference spans [-0.056, +0.052], so the cuDNN kernel swap itself would
fail this rule. The A100 A/A repeat of off is bit-identical, so an A/A
floor is 0 there. On both cards exact start 4 is closer to the fp32
reference than INT8 on every step.

### Paired against the cuDNN floor arm (scored against OFF)

metric(X vs OFF) minus metric(cuDNN vs OFF), paired 95% CI; negative =
closer to off than a bf16 kernel swap.

| card | arm | frames X / cuDNN | frames diff [95% CI] | audio X / cuDNN
| audio diff [95% CI] |
|---|---|---|---|---|---|
| L4 | INT8 every step | 0.215 / 0.169 | +0.046 [-0.009, +0.089] | 0.481
/ 0.329 | +0.152 [+0.050, +0.276] |
| L4 | exact start 4 | 0.084 / 0.169 | -0.085 [-0.136, -0.037] | 0.310 /
0.329 | -0.019 [-0.118, +0.092] |
| A100-40 | INT8 every step | 0.208 / 0.195 | +0.013 [-0.029, +0.061] |
0.426 / 0.404 | +0.022 [-0.053, +0.102] |
| A100-40 | exact start 4 | 0.085 / 0.195 | -0.110 [-0.165, -0.062] |
0.328 / 0.404 | -0.077 [-0.121, -0.030] |

### Speed

Denoise seconds per clip, one row per arm, fresh process per arm,
interleaved A B C D D C B A on one VM per card (repeats within 0.4 s):

| card | off | INT8 every step | exact start 2 | exact start 4 | share
of INT8 speedup kept (4) |
|---|---:|---:|---:|---:|---:|
| L4 | 315.5 | 243.0 (-23.0%) | 246.7 (-21.8%) | 254.3 (-19.4%) | 85% |
| A100-40 | 86.0 | 72.9 (-15.2%) | 73.6 (-14.4%) | 75.0 (-12.7%) | 84% |

### Tests

`studio/backend/tests/test_h3_int8_exact_start.py` (CPU, tiny real H3
transformer):

- the gate sets the exact start on every card under Auto, ROCm / unknown
included; explicit On keeps INT8 on every step; explicit Off wins over
the env override; the Auto off reasons are unchanged
- the env override and the bad-value fallback with a warning
- exact steps match the off model bit for bit and later steps call the
INT8 kernel, including a render that starts at a later grid point and
the next render starting over
- the op refuses a CUDA graph capture, judged on the operand's card, and
both graph paths refuse an exact-start denoiser with the reason
- the op adds no graph break over the 16-bit strided processor; a
fullgraph compile of a function around the whole denoiser traces once
and still switches route by step
- two overlapping denoisers keep their own route
- the op's fake dtype matches its real output under autocast
- the load step takes INT8 off when the exact start raises or installs
on no processor
- a transient out-of-memory race probe is retried and never cached
(`test_diffusion_int8_attention_persisted.py`)
- on ROCm, Auto's H3 race installs nothing, so the exact start never
installs
- the H3 load calls the load step only under Auto

`test_h3_int8_auto_arch.py` is updated for the removed sm89 off switch.
The new and the flipped tests fail on the merge base and pass here. The
INT8 attention toggle, families and auto suites, the H3 attention suite,
the CUDA graph suite and the video backend suite pass.

## Not covered

- RTX PRO 6000 / G4 (sm120), sm86 (RTX 3090 / A10 / A40), H100 and B200
were not re-gated with the exact start; they get it by the same rule.
- The RTX 6000 Ada and the 12 / 16 GB tiers from the tester's round were
not re-run on this branch.
- i2v / reference workflows and the 10-step setting were not
re-measured; a render with a begin index is covered by a CPU test only.
- Explicit `int8_attention="on"` still runs INT8 on every step.
- No listening test.
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.

1 participant