Repository navigation
Studio diffusion: CFG-parallel for a group-offloaded denoiser - #16681
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.
…same model With no gpu_ids (the UI's Automatic) CFG-parallel always declined, so a guided render on a two-card box left the second card idle unless the user picked both cards. Automatic now arms it when a secondary is the same card model and idle at load (at most 1 GiB in use); a busy or different card is never borrowed. UNSLOTH_DIFFUSION_CFG_PARALLEL_AUTO=0 restores the old behaviour.
Record compile arguments under Automatic too (a compiled denoiser's replica needs them), and re-check at replica build time that the card Automatic borrowed is still idle.
…eights sit in host memory cfg_parallel_decline read the denoiser's first parameter device, so a group-offloaded DiT whose first group lives in host memory between calls (Wan2.2-TI2V-5B on a 15 GiB card) was refused as 'not on a CUDA card' while one whose first group stayed resident (Qwen-Image-2.1) armed. The execution device now falls back to the offload groups' onload card: the primary branch keeps streaming, the replica runs resident on the second card.
An automatic load on the current card onloads its offload groups to bare 'cuda' (no index), so the CFG-parallel replica search found no card model to compare and declined every secondary as 'a different model'.
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". |
…el-streamed-primary [skip ci]
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 group-offloaded DiT whose first group sits in host memory was refused for CFG-parallel (
denoiser is not on a CUDA card): the check read the device of the first weight.Change
cudais resolved to the current card.Evidence
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: