Repository navigation
Studio: warm the compile workers and Triton / inductor keys during a load that compiles inline - #16918
Merged
Conversation
…load that compiles inline A load that compiles at its first render (default tier, not deferred) paid Triton's triton_key() hash, inductor's torch_key() hash and the compile worker start inside that render. The deferred tier already warms these on a side thread from the 2nd image; a load whose compile cache context begins now starts the same side warm-up while the rest of the load runs.
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 |
1 similar comment
Member
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. Chef's kiss. 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 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
A load that compiles at its first render (the default speed tier when it is not deferred) paid three one-time, model-free costs inside that render: starting inductor's compile workers, Triton's
triton_key()(a hash of the Triton install) and inductor'storch_key()(a hash of torch's sources). The deferred tier already warms the first two on a side thread from the 2nd image (start_deferred_prewarm), and the first render of an inline load gets none of that.This PR:
load_pipelineas soon as the compile-cache context begins on a CUDA target, so it runs while the rest of the load (speed layer, CUDA graph setup, placement) finishes;torch_key()to the warm-up (warm_inductor_key). It is cached per process, so the first compile reads it instead of hashing torch's sources;UNSLOTH_DIFFUSION_DEFERRED_PREWARM=0(warms the pool inline only).Nothing about the compile itself changes: same knobs, same graphs, same cache keys.
Results
Colab G4 (RTX PRO 6000 Blackwell), one VM, torch 2.13.0+cu130, diffusers 0.42.1, Studio from
install.sh --local. FLUX.2-klein-4B, 1024x1024, 4 steps. Base =ccc8a827d2, head = base + this change, 3 reps interleaved (B H, H B, B H). Fresh = new process with empty Studio home and inductor / Triton caches; returning = a second and third process on that home.Returning first render: -0.32 s (-6%), outside the A/A spread of both arms (0.04 s base, 0.03 s head). The warm-up overlapping the load costs about +0.07 s of load time (median), so load-to-first-image drops by about 0.25 s on a returning start (process wall 17.19 to 16.97 s median). Fresh first render: -0.3 to -0.8 s. Steady renders are unchanged.
Tests
tests/test_diffusion_deferred_prewarm.py: the warm-up order now includes the inductor key,warm_inductor_keyfills the key and never raises, andload_pipelinestarts the warm-up aftercompile_cache.begin(AST check, like the existing 2nd-image check). 19 passed.Not proven