layer split: make the compute headroom overridable, and report what actually failed - #1911
Open
realhidden wants to merge 1 commit into
Open
layer split: make the compute headroom overridable, and report what actually failed#1911realhidden wants to merge 1 commit into
realhidden wants to merge 1 commit into
Conversation
…ally failed The 2 GiB compute headroom held back on every device was hardcoded with no override, and on an asymmetric multi-GPU pair that is what makes layer split unusable. Measured on 8 GB + 12 GB with MiniMax-H3 ref2va Q4 at 1344x768: the params pass fills the 8 GB card to 5473 MB, leaving 2719 MB free, and 2 GiB of that is then reserved — so the small card absorbs no graph segments at all, everything piles onto the 12 GB card, and the plan is refused by 165 MB. --max-vram cannot rescue it: that limit is applied with min(), so it can only ever lower the capacity, never raise it. Every value from 7.5 to 11.7 GB gave byte-identical results because the free-VRAM term always won. SD_COMPUTE_HEADROOM_MB makes the trade — refuse-to-plan versus risking a real OOM — a per-host decision. Default unchanged at 2 GiB. The error message also reported `current_used + bytes` as what the segment "needs", which reads as one huge segment. It is cumulative, so it does not shrink when you lower the resolution: I chased a smaller canvas from 1344x768 to 1280x736 and the number did not move a single byte. It now prints the segment's own size, what was already packed, the capacity and the shortfall.
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.
What this changes
Two small things in
graph_cut_layer_split_backend_capacities/partition_graph_cut_layer_split:compute_headroom_bytes(hardcoded 2 GiB) becomes overridable viaSD_COMPUTE_HEADROOM_MB. Default unchanged.No behaviour change unless the env var is set.
Why
Trying to run MiniMax-H3
ref2vaQ4 at its trained 1344×768 canvas across an 8 GB + 12 GB pair (--backend "diffusion=cuda0&cuda1" --split-mode layer).The params pass fills the 8 GB card to 5473 MB, leaving 2719 MB free. 2 GiB of that is then reserved as compute headroom, so the smaller card's capacity is ~0 — it can absorb no graph segments, everything piles onto the 12 GB card, and the plan is refused. The split silently degenerates to single-GPU:
Two things made this hard to diagnose from the outside:
--max-vramcannot help. The limit is applied withmin(), so it can only ever lower the capacity. I triedcuda1=7.5,11.0,11.7and got byte-identical output every time, because thefree - headroomterm always won. The message points at "current VRAM limits", which reads like--max-vramis the knob.The reported figure is cumulative, not the segment.
current_used + bytesis printed as what "segment N needs", which reads as one enormous segment — so the obvious move is to lower the resolution. That does nothing: I went 1344×768 → 1280×736 and the number did not move a single byte, because it is dominated by what was already packed. The actual segment was 210 MB and the shortfall 157 MB.After the patch:
which says immediately that the problem is the packing, not the segment.
On the override
To be clear about what it bought me: on this hardware, lowering the headroom does not rescue the job. At 512/256/0 MB the planner passes and then the allocation genuinely fails (
cudaMalloc failed: out of memory, then a segfault) — the 2 GiB is load-bearing here, and the honest answer for this pair is that it does not have the VRAM.But that is a useful thing to be able to establish in five minutes rather than by rebuilding, and on a less lopsided pair the headroom is exactly the knob you want. An env var seemed the least invasive way to expose it; happy to make it a CLI flag or a
sd_ctx_params_tfield instead if you'd prefer.Testing
Built with
-DSD_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES=86(2× RTX 3060) and exercised on MiniMax-H3ref2vaQ4 with reference images, single-GPU and split, at canvases from 832×480 to 1344×768. Default path unchanged: same output bytes and same 1.32 s/it as master on the single-GPU configuration.