Skip to content

Studio INT8 attention: leave FLUX.1 and FLUX.2 out of Auto (route on request only) - #19235

Merged
danielhanchen merged 4 commits into
mainfrom
studio-int8-attn-flux-auto-off
Nov 24, 2026
Merged

danielhanchen merged 4 commits into
mainfrom
studio-int8-attn-flux-auto-off

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

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.

…nder Auto

Studio defaults on L4 (1024 px, 8 prompts, fresh process per arm) moved the
image well above the 0.02 LPIPS default-path bar against the kernel off,
whose own repeat is bit-identical: FLUX.1 schnell mean 0.107 / max 0.204,
FLUX.2 klein 4B mean 0.037 / max 0.081. Take both out of AUTO_DITS,
SPEED_UNSET_DITS and AUTO_CUDA_ONLY; a request by name still routes them
on the attention-sink path.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 24, 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-24T10:12:01.456588Z cce0e0e 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. Keep it up!

Reviewed commit: cce0e0e55d

ℹ️ 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]
@danielhanchen
danielhanchen merged commit 81334d3 into main Nov 24, 2026
1 check passed
@danielhanchen
danielhanchen deleted the studio-int8-attn-flux-auto-off branch November 24, 2026 11:35
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