Repository navigation
Studio: INT8 attention by default for FLUX.1, FLUX.2 and HunyuanVideo-1.5 where it wins per card - #18085
Merged
Conversation
…-1.5 where it wins per card FLUX.1 (dev, schnell, Kontext), FLUX.2 (klein, dev) and HunyuanVideo-1.5 call diffusers' dispatch_attention_fn but were not raced with the switch unset. Add them to AUTO_DITS (and the CUDA-only and attention-sink sets; the FLUX families also to SPEED_UNSET_DITS, the T4 default), so the per-card accuracy check and race decide as for the other dispatch families. HunyuanVideo-1.5's padded-text trim processor captured dispatch_attention_fn in a closure, so the route could never see its calls; it now reads it from diffusers' module at call time (same call, same arguments). Qwen-Image (v1 / Edit / 2512) stays on request only: per-step error max 0.031 vs 0.013 for its INT8 weights and 50-step images LPIPS 0.14 from native. HunyuanImage-2.1 and Krea-2 attend with a text padding mask on every call, so there is nothing to route.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Member
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. 🚀 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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
added a commit
that referenced
this pull request
Nov 24, 2026
…request only) (#19235) ## Summary Studio's automatic INT8 attention (on by default since #18085) routes FLUX.1 and FLUX.2 denoisers. Re-gated with the accuracy rule Studio uses for automatic kernels, INT8 moves FLUX.1 schnell and FLUX.2 klein 4B significantly further from an fp32-attention reference than a bf16 kernel swap does, on both L4 and A100-40, for a 6-7% speed gain on L4 and under 2% on A100. This takes `FluxTransformer2DModel` and `Flux2Transformer2DModel` out of Auto. Picking INT8 attention explicitly still routes them. ## Change - `diffusion_int8_attention_dispatch.py`: FLUX.1 and FLUX.2 removed from `AUTO_DITS`, `SPEED_UNSET_DITS` and `AUTO_CUDA_ONLY`. FLUX.3, Krea 2, MOSS-Image, HunyuanVideo-1.5, Qwen-Image-2.1, Wan and Z-Image keep Auto. ## Evidence Colab, Studio main `a4135f0fa6`, 30 prompts with fixed seeds, 1024 px, Studio defaults (4 steps, int8 weights, compiled), a fresh process per arm, one VM per family and card. - Reference: the same load with fp32-math attention, so only attention differs. - OFF: bf16 SDPA (flash), the path without INT8. Repeated on the same VM, bit-identical. - AUTO: Studio's default, INT8 attention routed. - Kernel-swap floor: the larger LPIPS shift of two other bf16 attention kernels (efficient, cuDNN) against OFF, i.e. how far an accepted bf16 kernel change moves the output. Rule, fixed before running: keep Auto for a family only if the upper bound of the paired bootstrap 95% CI of (AUTO minus OFF, LPIPS against the reference) is at or below the floor. | card / family | INT8 vs ref, mean / max | bf16 vs ref, mean / max | INT8 minus bf16 [95% CI] | floor | s/img OFF -> INT8 | |---|---|---|---|---|---| | L4, FLUX.1 schnell | 0.103 / 0.217 | 0.085 / 0.204 | +0.0177 [0.0104, 0.0269] | 0.0057 | 4.65 -> 4.35 (-7.0%) | | L4, FLUX.2 klein 4B | 0.031 / 0.083 | 0.019 / 0.063 | +0.0122 [0.0090, 0.0154] | 0.0010 | 1.98 -> 1.87 (-6.1%) | | A100-40, FLUX.1 schnell | 0.099 / 0.196 | 0.091 / 0.230 | +0.0074 [0.0016, 0.0122] | 0.0018 | 1.151 -> 1.134 (-1.5%) | | A100-40, FLUX.2 klein 4B | 0.027 / 0.071 | 0.019 / 0.065 | +0.0089 [0.0061, 0.0119] | 0.0009 | 0.590 -> 0.580 (-1.7%) | Every lower bound is above its floor, so all four cells fail the rule. On klein 4B INT8 is about 1.5-1.65x further from the reference than bf16. On schnell (4 distilled steps) any attention change can move the layout; INT8 moves it more than the bf16 kernels do (for example added furniture and a different ceiling on one interior prompt). Tests: the INT8 attention dispatch, families, auto, toggle and speed-route suites, 259 passed, 90 skipped (GPU-only). The family tests now assert FLUX.1 / FLUX.2 stay off under Auto and still route when INT8 is requested. ## Not covered - T4, Blackwell (G4) and AMD were not re-gated. - FLUX.1 dev / Kontext and FLUX.2 klein 9B / dev share the two classes and leave Auto with them; they were not measured separately. - One seed per prompt, no human rating.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
These families call diffusers'
dispatch_attention_fnbut were never raced for INT8 attention while the switch is unset:This PR adds them to
AUTO_DITS,AUTO_CUDA_ONLYand the attention-sink set (SINK_DITS). The two FLUX classes also go intoSPEED_UNSET_DITS, which T4 uses by default. The per-card accuracy check and race then decide, as for FLUX.3, Qwen-Image-2.1, Wan and Z-Image.HunyuanVideo-1.5 also needed a fix. Studio's padded-text trim processor captured
dispatch_attention_fnin a closure, so the route never saw its calls: 0 modules routed on main, even when forced. It now reads the function from diffusers' module at call time, with the same call and arguments.Staying off:
Results
Colab, main vs this branch, 3 interleaved repeats each. Error is teacher-forced per-step rel L2 against bf16 weights with native attention, the same gate #18004 uses.
Testing
test_diffusion_int8_attention_families.py, 25 tests plus 4 CUDA ones. It covers which families race when unset, the speed-unset rule, a lost race keeping the incumbent, the kill switches, Qwen and the masked families staying off, and the HunyuanVideo-1.5 trim route.test_diffusion_int8_attention_dispatch.pyare updated.