Repository navigation
Studio: split guided Z-Image on the background-compile recording render - #15057
Merged
Merged
Conversation
The eager render that records inputs for a pending background compile ran the guided call batched (2B), so the background compile built a 2B graph that no compiled render replays. Compiled renders split guidance into two B calls and compiled every block inline on the first render after the background compile. The recording render now splits like the compiled renders will, so the recorder stores B inputs. Other eager renders, including ones under the eager gate while the compile already runs, keep the batched call.
Member
Author
|
@codex review |
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. |
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. 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
Since #14868, a guided Z-Image render that records inputs for a pending background compile runs the guided call batched at 2B. The background compile then builds a 2B graph. Every later compiled render splits guidance into two batch-B calls, finds no B graph, and compiles every block inline. That is the compile background compile exists to hide. #14955 inherits the same rule through
_eager_now.This PR makes the recording render split, the same way the compiled renders will, so the recorder stores B inputs and the background compile builds the graph that later renders replay.
Details
diffusion_bg_compile.recording(module)is a new helper. It is True only when the call is eager-forced, not underno_record(), and aBackgroundCompilehooked on that module is stillrecordingwith room for more samples (BackgroundCompile.wants_samples())._eager_nowindiffusion_zimage_cfg_split.pyno longer treats such a render as eager, so the render splits.guided_runs_at_guidance_off_batchreads the same function, so the request guard prices the recording render at the guidance-off batch, matching how it now runs.compiling) record nothing, so they stay batched.no_record()) also stays batched.atol=1e-5, rtol=1e-4).New dynamo graphs in the first compiled guided render after the background replay. The setup is the real diffusers
ZImageTransformer2DModelwith a tiny config, Studio's per-blocktorch.compile(dynamic=True), the realBackgroundCompilerecorder and the_rebuildreplay:(2,))(16, 1, 8, 8)Tests
New
test_background_compile_recording_render_splits_and_records_the_compiled_shape. It records under a realBackgroundCompile, replays likekick(), then runs a compiled guided render and asserts:It fails on main (
assert (6 - 3) == 0) and passes here.test_compiled_only_honours_the_background_compile_eager_gatenow asserts the corrected rule: eager-forced with nothing recording (no recorder, or one alreadycompiling) stays batched and records nothing, and a compiled render splits.studio/backend,python -m pytest -q -p no:cacheprovider:tests/test_diffusion_zimage_cfg_split.pytests/test_diffusion_cold_start.pytests/test_diffusion_regional_compile.pytests/test_diffusion_block_graph.pytests/test_diffusion_speed.pytests/test_diffusion_vae_oom.pytests/test_diffusion_gguf_compile.pyNot measured: the wall-clock seconds saved on a real Z-Image checkpoint on GPU, and the batching speed the one recording render gives up.