Repository navigation
Studio: price the fixed Inkling 2 reserve and split multi-GPU pins by bytes (builds on #19148) - #19249
Conversation
The fix to unslothai/llama.cpp#386 runs several slots banded over cell positions and short ubatches over the padded cache, so its load-time reserve is the f16 KQ masks plus a per-ubatch remainder for any slot count or K/V type. Detect it by the two graph inputs it adds to libllama and price it from 116 llama-server measurements; b12649-mix keeps the dense pricing.
…uld overflow a card llama.cpp cuts a --fit off layer split by layer count, weighted by free memory. Unsloth Dynamic quants keep some layers at higher precision, so the count cut can land several GB more on the smaller card than it holds (Inkling-2-Mini UD-Q8_K_XL on 16 + 12 GB: 13.4 GB on the 12 GB card). When that happens, emit a --tensor-split whose runs fit each card, or let --fit place the model when no cut fits. Pins whose count split fits keep llama.cpp's own split.
…lit that fits Fewer serving slots are only worth it when the smaller pin loads. If no layer split puts the cut pin's share within each card, launch --fit on with the slots asked, as before the cut, instead of the cut count.
…ments Name every KV argument at the call, as the planner's seam tests require, and count the split check among the micro-batch re-derivations.
Codex Review Summary: ✅ CompletedThis 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: 3c1fb21784
ℹ️ 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".
| "No layer split over GPUs %s fits each card; using --fit on", | ||
| list(gpu_indices), | ||
| ) | ||
| use_fit, gpu_indices, _mixed_split = True, None, None |
There was a problem hiding this comment.
Preserve explicitly selected GPUs when falling back to the fitter
When a user selects multiple CUDA/ROCm GPUs and no contiguous layer split fits, clearing gpu_indices also removes the launch-time device restriction. The visibility-mask branch later requires gpu_indices is not None, while its alternative explicitly excludes requests with gpu_ids; competing device flags are also stripped for an explicit GPU selection. Consequently, on a host with additional visible GPUs, this fallback lets the fitter allocate on cards the user did not select. Retain the requested device list when switching to --fit on.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 431b67c. The fallback keeps gpu_indices when the user picked GPUs, so the launch takes the --fit on branch with the pick still pinned in the child's visibility mask (an auto Vulkan fit keeps its discrete pool; only an unpinned auto load goes back to every card). test_the_fitter_fallback_keeps_an_explicit_gpu_pick: 3 cards, gpu_ids = [0, 1], no layer split fits, launches --fit on with CUDA_VISIBLE_DEVICES=0,1 (unset before the fix).
| "No layer split over GPUs %s fits each card; using --fit on", | ||
| list(gpu_indices), | ||
| ) | ||
| use_fit, gpu_indices, _mixed_split = True, None, None |
There was a problem hiding this comment.
Apply the partial-fit refusal to the new fitter fallback
For loads with intent.refuse_partial_gpu_fit=True, a pooled fit that fails this per-card split check now silently switches to CPU offload instead of raising GpuMemoryShortError. The partial-fit guard has already run, and _placement_verdict_partial was recorded while use_fit was still false. The later host-memory guard only rejects a host-RAM shortfall, so it does not enforce this policy when RAM is sufficient. This bypasses the route's refusal behavior for alongside loads and prevents its eviction/retry flow from running; perform this check before that guard or explicitly enforce the refusal here.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 431b67c. The refusal body is now one local function, _refuse_partial_fit, called by the existing guard and by the fallback, which also marks the placement partial before handing the load to the fitter. test_the_fitter_fallback_honours_the_partial_fit_refusal: with refuse_partial_gpu_fit = True the fallback raises GpuMemoryShortError (it launched --fit on before), and a split that fits still launches --fit off.
…falls back to the fitter [skip ci]
Builds on #19148 (includes its commits); merging this merges #19148.
Problem
#19148 prices the large compute reserve that unslothai/llama.cpp#386 added in
b12649-mix. The next llama.cpp prebuild may ship the fix to that reserve. In the fixed build, several slots run the banded kernel over cell positions, and short ubatches run banded over the padded cache. The reserve then drops to almost nothing:b12649-mixWith #19148 alone, Studio would keep pricing the fixed build with the
b12649-mixreserve. On the measured points that overestimates the compute buffer by 0.2 to 55 GB, so Studio would place fewer layers on the GPU than fit. This PR prices the fixed build separately, which makes #19148 safe to merge.Fix
libllama:attn_inp_k_pos_swa(several slots, banded over cell positions) andattn_inp_rel_shift_swa(short ubatches over the padded cache). No earlier build has either name. Both survivestrip. Both must be present.--swa-full) plus 160 KiB per ubatch token, for any slot count and K/V type. A layer split adds its mask copies as before.--fit-target, as Studio: price Inkling 2's compute reserve on the b12649-mix llama.cpp prebuild #19148 does forb12649-mix. The markers identify the build even when its build number cannot be read.b12649-mixand the merge-only rebuild of There is no 12.1 or 11.6 versions of pytorch-cuda for MacOS. Which should I use? #386 keep Studio: price Inkling 2's compute reserve on the b12649-mix llama.cpp prebuild #19148's pricing. Older builds keep the pricing onmain.--fit offmulti-GPU load by bytes when llama.cpp's split by layer count would overflow a card. Unsloth Dynamic quants keep some layers at higher precision: the last four layers of Inkling-2-Mini UD-Q8_K_XL are about 2 GB each, against 0.6 GB for the rest, so a split by count can put several GB more on the smaller card than it holds. Studio now emits a--tensor-splitwhose layer runs fit each card. When no split fits, it lets--fit onplace the model with the slots the user asked for, not a count cut only to fit every layer on the GPUs. A load whose count split already fits keeps llama.cpp's own split.Which pricing each build gets (
grep -cof each string in the builtlibllama):inkling2_loop: %zu cache slots exceedattn_inp_k_pos_swaattn_inp_rel_shift_swab12631-mixmain(build below 12649)b12649-mixAccuracy
Compute buffer at load from
llama-server, Inkling-2-Mini, flash attention, B200, on the fixed build. The table is a sample of 116 points: 1 to 64 slots, ub 256 to 2048, f16 / bf16 / q8_0 / q4_0 / q4_1 / q5_0 / q5_1 / mixed K/V, 4K to 1M context, with and without--swa-full, and with a DSpark drafter.--swa-full--swa-fullAcross all 116 points the estimate is 1.01x to 1.25x the measurement (+14 to +184 MiB) and never under it. The highest ratio is 64 slots at 64K, where the flat estimate's output rows lead.
After two concurrent 13.5K-token prompts at ub 2048 with 4 slots, the compute buffer grew by 120 MiB past the load reserve. The 512 MiB pool margin in
--fit-targetcovers that.#19137 on the fixed build
The #19137 setup with Inkling-2-Mini UD-Q8_K_XL: 2 GPUs, 32K context, 4 slots requested, the Windows reserve floor. Studio's planner ran for each free VRAM pair. The command it produced then ran on two B200s, with
cudaMemGetInfocapped to that pair. The cap only changes what llama.cpp sees as free memory; it does not stop an allocation. So for every load, the table checks llama.cpp's own per-card memory (weights, cache, compute, unaccounted) against the card. Every load answered two concurrent 13.5K-token prompts.main--fit on, target 3714: 12.3 GiB of weights on GPU--fit on, target 1536: 16.6 GiB on GPU--fit on, target 3714: 12.8 GiB on GPU--fit on, target 1536: 16.6 GiB on GPU--fit on, target 1536)--tensor-split 19.5,5.5: 15.0 GB and 11.1 GB, under 16 and 12 GBDecode speed, median of 5 runs of 256 tokens after a warmup, in tok/s. These numbers are noise-dominated: the host CPU was shared with other jobs, and loads with every layer on the GPUs measured anywhere from 91 to 698 tok/s across rounds of the same setup. They do not rank the versions; the placement above is the result.
mainmainon the fixed build reproduces the report: 11.6 and 7.9 GB used of the two cards with expert weights on the CPU, as in the Task Manager readings in #19137. With 16 + 12 GB free, this PR keeps the whole model on the GPUs and loads.mainand #19148 plan the same placement but split by layer count, so the 12 GB card cannot hold its share.The 1024 MiB per-device overhead matches what llama.cpp reports as unaccounted per device (0.8 to 1.3 GB), so this PR leaves the multi-GPU margins as they are.
Boundaries
llama-completionreserves a logit row per ubatch token, so its single-slot buffers are larger thanllama-server's at the same settings (819 vs about 252 MiB at 32K, ub 512). Studio launchesllama-server, which is what this PR prices.Tests
test_inkling2_banded_quant_kv.pyadds:--fit-targetmargin;test_byte_balanced_layer_split.pycovers:--fit on.--fit on.main, Studio: price Inkling 2's compute reserve on the b12649-mix llama.cpp prebuild #19148 and this PR. All 321 come from this host's CUDA probe guard (a CPU test reachingtorch.cudaon a GPU host without a queried device), not from these changes.