Skip to content

Studio diffusion: real-step CUDA graph warm-ups by default - #18533

Merged
danielhanchen merged 28 commits into
mainfrom
studio-graph-real-warmup
Nov 20, 2026
Merged

danielhanchen merged 28 commits into
mainfrom
studio-graph-real-warmup

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Summary

Stacked on #18532 (the INT8 attention sink path repeats a seed from the first render); merge that first.

Today a resident denoiser's step CUDA graph runs three warm-up forwards on a side stream for each graph key, on the first render of every load, and throws them away before recording. With this change the key's first three real steps are the warm-ups: they run eagerly on copies laid out like the capture statics, and the fourth step records. The first render of a load runs three fewer denoiser forwards per graph key. UNSLOTH_DIFFUSION_GRAPH_REAL_WARMUP=0 keeps the side-stream warm-ups.

Real-step warm-ups are used only where the key is sure to reach its recording step inside the render: Studio passes the render's denoise steps (after img2img strength) to the graph handle before the pipeline call, and a key takes real warm-ups only when

  • the render has more than 3 steps,
  • the pipeline has one denoiser (experts that split the steps keep the side-stream path), and
  • the key follows no step-dependent branch (NVFP4 per-step precision, a pre-hook's branch flag), since such a key may appear on only 1 to 3 steps.

Every other key records on its first call with side-stream warm-ups, exactly as on main. So SDXL-Turbo's 1-step default, any 1 to 3 step render, and low-strength img2img or inpaint replay from their first render as before. A caller that names no step count (anything outside Studio's render path) also gets main's behaviour.

Before its first real warm-up, a key does what the capture does before its warm-ups: its NVFP4 GEMMs are tuned at the step's row counts, and NVFP4 activation scales that are still calibrating go to the capture's refusal (eager for the load), as before.

Evidence

Colab L4, torch 2.13.0+cu130, one VM per run, base = merge base 0b278200d2, head = this stack, the same prompt and seed for every render of a process.

FLUX.2 klein (4 steps, so real warm-ups apply), INT8 by Auto, 1024 px, processes m h | h m m h h m (the first two cold, then race files shared and warm restarts):

first-render denoise, warm restarts (median of 3, range) cold first render second-render denoise (median) graph engagement, render 1 images
base 4.777 s (4.770-4.784) 10.63 s 0.793 s 1 capture, 4 replays 6aff2096 in all 4
head 3.739 s (3.713-3.780), -21.7% 10.16 s 0.782 s 3 real warm-ups, 1 capture, 1 replay 6aff2096 in all 4

From render 2 on both arms replay all 4 steps; 0 graph fallbacks.

SDXL-Turbo, Studio's 1-step default, 512 px, default (deferred) speed profile: graphs engage once the background compile finishes (UNSLOTH_DIFFUSION_BG_COMPILE_YIELD=0 in every arm, so image 4 waits for it), so images 4, 5 and 6 of the process are the first three graphed renders. Replays per render:

renders 1-3 after the graphs engage
base 1, 1, 1 (recorded on the first call)
this PR's previous head 0, 1, 1 (one real warm-up, then a side-stream recording)
head 1, 1, 1 (recorded on the first call, 0 real warm-ups)

All 6 renders of each process are byte-identical across the three trees.

The earlier L4 run of the same real warm-up path (median of 3 warm restarts, first-render denoise): Qwen-Image-2.1 12.72 -> 10.30 s, Z-Image-Turbo 9.92 -> 7.89 s, MOSS-Image 16.82 -> 13.20 s, FLUX.3 klein about equal; second renders and images unchanged (MOSS-Image varies VM to VM on main itself). All of these run 8 or more steps on one denoiser, so the step-count rule leaves them on real warm-ups.

  • B200, correctness only: Studio's MOSS transformer (tiny random config, compiled, bf16, true CFG with two graph keys, 12 steps, two renders) is bit-identical to the side-stream path on all 24 calls; a toy DiT on the real INT8 attention kernels is torch.equal with 16 executed forwards instead of 19.
  • CPU: the CUDA graph, offload graph, block graph and INT8 attention suites pass on main (595), on Studio diffusion: the INT8 attention sink path repeats a seed from the first render #18532 (607) and here (635), no failures. test_differential.py against Studio diffusion: the INT8 attention sink path repeats a seed from the first render #18532's head is API only (every new test names the new switch or note_render_steps); reverting the switch alone fails the 11 real warm-up tests, and removing only the step-count gate fails the 10 tests that pin main's behaviour for 1 to 3 step renders, branch keys, several denoisers and a caller with no step count. Against this PR's previous head, the no-step-count 1-step test is FIXED (replays per render [0, 1, 1, 1, 1] before, [1, 1, 1, 1, 1] now, as main).

Not covered

  • Only FLUX.2 klein and SDXL-Turbo ran on this head; Qwen-Image-2.1, Z-Image-Turbo, MOSS-Image and FLUX.3 klein numbers are from the previous head, whose path is unchanged for them. A100, T4, G4, a LoRA change, low-strength img2img on GPU and Windows did not run.
  • A key that is not a branch key but first appears in the last 3 steps of a render (for example a short second stage inside one pipeline call; no current Studio pipeline was found doing this) still records on the next render's first call, not on its own first call.
  • Video families (graphs opt-in) render through a path that passes no step count, so they keep main's side-stream warm-ups.

…rst render

A sink-family route (FLUX.3, FLUX.2, Z-Image, Qwen-Image-2.1,
HunyuanVideo-1.5) runs the sink path while its plan learns over its first
32 calls whether a head clipped V, and races at the 48th. Where a head
clipped and the race picked the kernels without the sink path
(Qwen-Image-2.1 on L4 and A100) or torch's attention, every call of the
next render ran that winner, so the first render of a load was a different
image from the next render of the same seed (Qwen-Image-2.1: LPIPS 0.0027 on
L4) whenever no thrown-away CUDA graph warm-ups had used up the 48 calls:
graphs off, a LoRA scale or a long prefix K/V on the step.

The race and its inputs stay as they were. Each learning check now records
whether its call's output was used (not inside a capture's side-stream
warm-ups). A verdict other than the sink path is taken only where no used
call clipped on the sink path; otherwise the plan keeps the sink path for
the load, which is what its earlier calls computed. The verdict is kept for
the bucket and persisted per card, toolchain, sources, DiT class and
checkpoint, so new plans of the load and later loads take it at their first
clipped call: that call's clip count is read right after its quantisers
(one wait per learning call until the first clip, only where a verdict is
known) and the verdict runs before its attention. An out-of-memory race and
a DiT with no known checkpoint persist nothing, as before.
A resident denoiser's first capture ran three warm-up forwards on a side
stream and threw their outputs away, once per graph key, on the first
render of every load. With UNSLOTH_DIFFUSION_GRAPH_REAL_WARMUP=1 the
key's first three real steps are its warm-ups instead (run on copies
laid out like the capture statics) and the fourth step records at once,
as an offloaded key warmed by its timed eager steps already does.

Off by default: prototype for a first-render measurement.
… identical

Measured on L4: FLUX.3 klein INT8 is byte-identical with the switch on.
Qwen-Image-2.1 is not (first render vs the same seed's next render,
LPIPS 0.0027, the same image main gives with CUDA graphs off). Comment
only.
A resident denoiser's graph key no longer runs three warm-up forwards on a
side stream and throws them away on the first render of a load: its first
three real steps are the warm-ups (on copies laid out like the capture
statics) and the fourth records. With INT8 attention deciding its sink path
before a call's output is used, the first render is the same image as the
next one of the same seed. UNSLOTH_DIFFUSION_GRAPH_REAL_WARMUP=0 keeps the
side-stream warm-ups.

Before its first real warm-up a key's NVFP4 GEMMs are tuned at the step's
row counts, as the capture does before its warm-ups, so no eager step runs
an untuned tactic; NVFP4 scales still calibrating go to the capture's
refusal as before.

Tests: the stub tests of what a key's first-call recording does pin the
side-stream warm-ups; new tests cover the same cases on the default path.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 19, 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-20T19:50:28.610637Z 5ea1266 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[bot]

This comment was marked as resolved.

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 77a6e885a5

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

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: c2bd656db7

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

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: a2a219d537

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

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Nov 20, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Nov 20, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: ee6904705c

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

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: 645b17b04b

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

The first-render rule stays: a plan whose used calls clipped on the sink
path keeps it for the load, so the same seed repeats. Sink race verdicts
are no longer written to or read from the probe cache, so every load races
on its own inputs again. Drops the per-checkpoint key, the early clip read
that applied a persisted verdict at the first clipped call, and their tests.
The first-render rule stays: a plan whose used calls clipped on the sink
path keeps it for the load, so the same seed repeats. Sink race verdicts
are no longer written to or read from the probe cache, so every load races
on its own inputs again. Drops the per-checkpoint key, the early clip read
that applied a persisted verdict at the first clipped call, and their tests.

[skip ci]
…the steps to finish them

A key seen on fewer than WARMUP_ITERS + 1 steps of a render (SDXL-Turbo's
1-step default, a 1-3 step or low-strength img2img render, an NVFP4
protect or pre-hook branch key) recorded only after three real steps, so
renders 2 and 3 ran eager where main replays. The render now passes its
denoise step count to its graph handles: real warm-ups run only for a
single denoiser, on a key that follows no step-dependent branch, in a
render of more than WARMUP_ITERS steps. Every other key records on its
first call with side-stream warm-ups, as on main.

[skip ci]
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: 5ea126648e

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

…-up branch

# Conflicts:
#	studio/backend/core/inference/diffusion_int8_attention.py
#	studio/backend/tests/test_diffusion_int8_attention_auto.py
Base automatically changed from studio-int8-sink-first-render to main November 20, 2026 21:59
@danielhanchen
danielhanchen merged commit b693051 into main Nov 20, 2026
@danielhanchen
danielhanchen deleted the studio-graph-real-warmup branch November 20, 2026 23:59
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