Repository navigation
Studio diffusion: TF32 matmuls on the default speed tier, not only max - #16762
Merged
Merged
Conversation
The default (compiled) tier now sets matmul TF32 on CUDA like max does; cuDNN TF32 is already torch's default. It only touches fp32 matmuls (bf16 / fp16 compute is unchanged): on an A100 fp32 SDXL VAE decode it is 0.56% faster (223.8 -> 222.6 ms, A/A 0.04%) at LPIPS 5e-7 and at most 1/255 per pixel. The off and eager tiers keep strict fp32. UNSLOTH_DIFFUSION_TF32=0 keeps strict fp32 matmuls on both compiled tiers; the compile cache keys on it. The autoopt parity fixture gains tf32 on the 188 default-tier CUDA cases.
Codex Review SummaryThis 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. Nice work! 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". |
This was referenced Nov 5, 2026
danielhanchen
added a commit
that referenced
this pull request
Nov 5, 2026
…er rows (#16838) ## Summary `seam-guard` (`studio/backend/tests/test_diffusion_autoopt_parity.py`) fails on main and on every PR that runs it, for example the staging runs for #16711 and #16799: ``` FAILED tests/test_diffusion_autoopt_parity.py::test_autoopt_resolves_the_same_optimizations_as_before FAILED tests/test_diffusion_autoopt_parity.py::test_legacy_sequence_still_matches_fixture E AssertionError: {'image|chroma|default|bfloat16|offload=0|gguf=0': {'before': {'applied': [['compiled', 'cuda_graph', 'cudnn_benchmark', 'fp16_accum']], ... ``` Bisected on main: `7d0c0952a0` (#16762, "TF32 matmuls on the default speed tier, not only max") is the first failing commit; its parent passes. #16762 added `tf32` to the default tier and regenerated `fixtures/diffusion_autoopt_parity.json`, but its branch predates #16710, which added the Anima and Chroma families. Those 16 rows (2 families x 2 dtypes x offload x GGUF on the default tier) kept their pre-#16762 values, so both parity tests now see them change. The code is right; the fixture is stale for the two families that landed in between. ## Change `studio/backend/tests/fixtures/diffusion_autoopt_parity.json` only. The 16 `image|anima|default|...` and `image|chroma|default|...` rows are rewritten from the current resolver, in the file's existing one-row-per-line format. In every one of them the only change is `tf32` appended to `applied`, the same change #16762 made to the other families' default-tier rows. No other row moves, and both `autoopt_entry` and `legacy_entry` produce the new rows. ## Testing - `tests/test_diffusion_autoopt_parity.py` and `tests/test_diffusion_speed.py`: main 2 failed; this branch 236 passed. - `7d0c0952a0~1`: the two parity tests pass; `7d0c0952a0`: they fail, which is the bisect above. - A script check over the diff: 16 rows changed, and in each the only difference is `tf32` added to `applied`.
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
The
defaultspeed tier now enables TF32 matmuls on CUDA. Until now onlymaxdid.torch.backends.cuda.matmul.allow_tf32 = Trueon the default tier.offandeagerkeep strict fp32. Nothing changes on the bit-exact tier.max.snapshot_backend_flags/restore_backend_flagsalready restore it on unload.UNSLOTH_DIFFUSION_TF32=0keeps strict fp32 matmuls on both compiled tiers. The compile cache keys on that switch.max-only. See below for why.Evidence (A100-SXM4-40GB, Colab, torch 2.14.1)
The test decodes a 128x128 latent (1024x1024 output) with
stabilityai/sdxl-vaein fp32. Each arm was timed in 5 interleaved rounds of 10 decodes with the arm order rotated, and strict fp32 was timed twice for A/A.The gain is small, because a bf16 model step does not use fp32 matmuls. The output change is below what torch's own default cuDNN TF32 already causes, so this falls under the "faster or equal, fp-order level" rule.
Also measured in the same run, as the reason it stays
max-only: the DiT QKV fuse on the default tier. On a FLUX.1-shaped model (2 double + 4 single blocks, regional compile, bf16), the fused projections ran 36.33 vs 36.58 ms (0.7%, inside the per-round spread). For DiTs the unfused projections are kept beside the fused ones, which costs +453 MB peak on just those 6 blocks. No change for it.Tests
test_speed_default_dense_falls_back_to_regional_compilenow expects TF32 on the default tier.test_the_tf32_kill_switch(default and max) andtest_the_eager_tier_leaves_tf32_off.UNSLOTH_DIFFUSION_TF32automatically.fixtures/diffusion_autoopt_parity.json:tf32is added to the applied set of exactly the 188 default-tier CUDA cases, and nothing else in the fixture changes. Both parity tests pass.test_diffusion_speed.py,test_diffusion_autoopt*andtest_diffusion_compile_cache*:max.Not covered here