Repository navigation
Studio diffusion: CFG-parallel for U-Net families (SDXL) by batch split - #16679
Merged
Merged
Conversation
A U-Net pipeline sends both guidance branches through one call at batch 2B, so
CFG-parallel declined it ('no DiT denoiser') and the second card stayed idle.
UnetCfgParallelRouter cuts that call in half along the batch, runs the second
half on the replica card through run_pair, and concatenates. Odd batches,
unknown tensor inputs and replica failures stay on the source card.
UNSLOTH_DIFFUSION_CFG_PARALLEL_UNET=0 turns it off.
The primary half goes through _primary_noting (waits on a cold replica, marks its signature warm); a module compiled whole after the router was installed, or a call under torch.compile, runs whole on the source; PAG-style processors that chunk the batch themselves keep the U-Net off the router.
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. 👍 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". |
danielhanchen
added a commit
that referenced
this pull request
Nov 5, 2026
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 U-Net denoiser was never CFG-parallel (
no DiT denoiser), so SDXL on two GPUs ran at one GPU's speed: the second card sat idle.Change
UnetCfgParallelRouter(diffusion_multigpu.py) splits a batch-2B U-Net call along dim 0 and runs the conditional and unconditional halves on the two cards, then concatenates.UNSLOTH_DIFFUSION_CFG_PARALLEL_UNET=0(bitwise identical to main).Evidence
gpu_ids=[0,1]: 24.47 -> 13.94 s per image (1.75x), LPIPS 0.003 against one card.speed_mode="default"): 20.12-20.22 -> 11.05-11.58 s (1.79x), 0 graph breaks, 0 recompiles after the first render, every guided step paired (100 of 100).Stack
This is one of four stacked PRs that make every decision to use a second GPU automatic, merged in order:
Results for the whole stack, Kaggle 2x T4, same VM per row, base A/A first: