Repository navigation
Studio diffusion: Automatic arms CFG-parallel on an idle card of the same model - #16680
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.
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 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6490905be4
ℹ️ 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".
| def _idle_card(probe: Any) -> bool: | ||
| free, total = getattr(probe, "free_mib", None), getattr(probe, "total_mib", None) | ||
| if free is None or total is None: | ||
| return False | ||
| return int(total) - int(free) <= AUTO_CFG_PARALLEL_IDLE_USED_MIB |
There was a problem hiding this comment.
Check GPU utilization before automatically borrowing a card
On a shared host, a secondary GPU running a compute-heavy workload that uses at most 1 GiB of VRAM passes this idle check, so Automatic now places a denoiser replica on an actively used card. Neither DeviceProbe nor smi_free_total_mib() preserves utilization telemetry, and the replica-build recheck uses this same memory-only predicate. This can slow both the existing workload and generation despite the intended idle-only behavior. Preserve the nvidia-smi utilization reading and enforce the stated 5% utilization limit alongside the memory threshold when selecting and rechecking an automatic partner.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
The utilisation limit lands in the next PR of this stack, #16682: automatic_partner reads nvidia-smi utilization.gpu per card and refuses a partner above 5%, and as of e128b3b the replica-build recheck reads it again before building on that card (test_automatic_replica_is_not_built_on_a_card_another_job_keeps_busy). The stack is merged in order, so this PR never ships without it.
|
@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". |
…el-streamed-primary [skip ci]
Summary
Automatic placement (no
gpu_ids, the UI default) never armed CFG-parallel, so a guided model that fits one card left an identical idle second card unused.Change
UNSLOTH_DIFFUSION_CFG_PARALLEL_AUTO=0.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: