Repository navigation
Studio GGUF placement: the dGPU wins Auto only without losing context; explicit picks keep host-only bytes off the dGPU - #14615
Conversation
… picks; discrete tier only while it keeps 32K of Auto context Explicit --device / --main-gpu / LLAMA_ARG_DEVICE picks (and unmappable masks) turn the discrete-first tier off (#14492), but the same cleared set also told the selectors which GPUs share host RAM, so a CPU-pinned projector and host context checkpoints were charged to a dGPU-only subset: a false GpuMemoryShortError or --fit on. The selectors now take the integrated set for accounting and a separate prefer_discrete flag; under an explicit pick a dGPU-only subset is priced without host-only bytes only when it keeps the leading ordinals, so the user's device ordinals still name the same cards. Auto context on an APU + dGPU host took the dGPU at any context down to the floor (#14372), e.g. ~29K on a 16 GB card beside 131K on the APU. The discrete tier now wins only while it keeps min(base walk context, 32768); the drafter probe applies the same rule.
… the base walk's context, drafter and slots A 32K floor still let the dGPU take 62K where the APU held 131K. Auto, the published ceiling sweep and the speculative-drafter probe now keep a discrete-tier subset only when it matches the base walk (the pick before #14372) in every term: context, and for the probe, whether the drafter fits beside the target. The probe's early break on the dGPU had dropped the drafter or cut the default slots 4 -> 1.
|
@codex review |
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 92a0babc46
ℹ️ 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".
| ctx_checkpoints = _placement_ctx_checkpoints, | ||
| # Picks a subset, so an explicit device pick keeps the base pick. | ||
| integrated = _tier_gpus, | ||
| # An explicit device pick skips the discrete tier; host-only accounting still applies. | ||
| integrated = _integrated_gpus, | ||
| prefer_discrete = bool(_tier_gpus), |
There was a problem hiding this comment.
Retain ordinary KV when discounting host checkpoints
Passing _integrated_gpus here newly enables checkpoint discounting for explicit device selections, but _slots_that_fit_on_gpu computes it as kv - _kv(0). The production _estimate_kv_cache_bytes returns zero whenever n_ctx <= 0, so this expression subtracts the entire target KV cache rather than only the host-resident checkpoint snapshots. When an explicit-device load with checkpoints enters slot reduction, the dGPU can therefore be declared fully resident at too many slots and launched with --fit off, risking an OOM; the checkpoint component must be isolated without evaluating the estimator at context zero.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
I don't think this one happens: _kv(0) here means zero checkpoints, not context zero. The helper calls _estimate_kv_cache_bytes(effective_ctx, ..., ctx_checkpoints=ckpts), so both terms use the same context and the difference is only the host snapshots; the n_ctx <= 0 early return would make both terms 0 and subtract nothing. Added test_the_checkpoint_discount_removes_only_the_checkpoints: with the real estimator on hybrid metadata, the dGPU slot count with 8 discounted checkpoints equals the count with no checkpoints, at three free-memory levels.
…needs a leading run of the inherited mask order that keeps every ordinal the flags name
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6458ccfc0e
ℹ️ 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".
| if not token or token.lower() == "none": | ||
| continue |
There was a problem hiding this comment.
Exclude CPU-only selections from GPU discount prefixes
When --device none or LLAMA_ARG_DEVICE=none is used on a mixed host whose leading device is a dGPU, skipping this token returns need == 0, so _discount_prefixes whitelists that dGPU prefix even though the child disables every GPU. The newly discounted calls, particularly _slots_that_fit_on_gpu, can then treat CPU-resident checkpoint/projector bytes as absent from the selected device and reduce --parallel or mark the load fully GPU-resident based on a card the child will never use; the equivalent supported spelling --device cpu correctly declines the discount. Treat none as a CPU-only/unpriceable selection here rather than as an ordinal-free GPU selection.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in e07d7c1. _explicit_device_ordinals_needed now returns None when --device/-dev or LLAMA_ARG_DEVICE names none (any case), the same as an unreadable value, so a CPU-only pick never makes a GPU subset priceable at the lighter size. The launch goes to --fit on with no pin, as without the accounting. Tests cover the helper and the full launch for both the flag and the env var.
| return ( | ||
| _ctx, | ||
| int(_need <= _pool_budget_mib(_subset, _probe_frac(True))), |
There was a problem hiding this comment.
Compare reducible slot counts before preferring the dGPU
When neither the discrete tier nor the base APU placement can hold the drafter at the originally requested slot count, both receive the same (context, 0) score here, so the dGPU remains first. The probe then breaks after recording that placement, and the later slot search can clamp, for example, four slots to one even when the base placement could retain three slots at the same context with the same drafter. Include each placement's best fitting slot count in this comparison rather than only whether all requested slots fit.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in e07d7c1. The drafter probe score is now (context, drafter fits at the requested slots, slots kept). When the drafter does not fit at the requested slots, the slot term is the most slots the slot search keeps the drafter at on that placement (same context-keep rule and one-slot trim), or 0 when slots are pinned. The discrete tier is kept only when it matches the base walk on slots too. In the test the APU keeps the drafter at three slots and the dGPU only at one, so the launch now takes the APU at three; when both keep one slot the tier still wins.
…ted card is tried alone before spreading; the drafter probe keeps the placement with more slots [skip ci]
|
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". |
Seven conflicts in studio/backend/core/inference/llama_cpp.py, all where this branch's explicit-pick accounting (prefer_discrete, discount_prefixes) and main's #12650 shared-memory iGPU ranking (shared_gpu_ids) touched the same signatures and forwarding calls. Both policies are kept; they do not contradict: - _select_gpus, _select_gpus_split_aware, _slots_that_fit_on_gpu signatures: keep prefer_discrete and discount_prefixes, and add shared_gpu_ids. - _select_gpus_split_aware's three _select_gpus calls (first pick, split retry, single-card re-price): forward shared_gpu_ids unconditionally, and keep the explicit-pick accounting kwargs (integrated, prefer_discrete=False, discount_prefixes, discrete_size_bytes) when the caller made an explicit pick. - _slots_that_fit_on_gpu's _select_gpus_split_aware call: forward all three. shared_gpu_ids only reorders ranking (iGPUs after every discrete card); discount_prefixes only lowers the price of a vetted dGPU-only subset under an explicit pick. The auto-merged call sites already pass both. [skip ci]
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. 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". |
Conflicts kept both sides: the host-pinned discount, tied output and per-candidate discounts beside main's input-embedding pricing (unslothai#14465), discrete tier (unslothai#14372, unslothai#14615), restructured drafter and Auto probes, and the arch-crash retry that now reads memory before the kill. main's input-embedding discount takes only what the host-pinned discount does not already cover. Non-Vulkan APUs and integrated CUDA move from _shared_gpu_ids to _unclassified_gpu_ids, so the discount still waits on them while main's ranking and host-pool checks keep the Vulkan iGPU set.
Summary
Follow-up to #14372 and #14492 from a post-merge review. Two ways the discrete-first GGUF placement used less of a mixed APU + dGPU host than it could.
--device/--main-gpu(or an unmappable mask) to keep the user's ordinals stable, but the same set also told the selectors which bytes live in host RAM. A CPU-pinned projector or host context checkpoints were then charged to the dGPU, giving a falseGpuMemoryShortErroror--fit on(fewer layers on the GPU).What changes
_select_gpus,_select_gpus_split_awareand_slots_that_fit_on_gputake the integrated set (which GPUs share host RAM) and a separateprefer_discreteflag. Under an explicit pick, a dGPU-only subset is priced without host-only bytes, but only when it keeps the leading ordinals, so the user's device numbers still name the same cards.Spoofed grid (2304 cells, main vs this branch)
APU first or second; no flag,
--device ROCm0or--main-gpu 0; 0 or 6 checkpoints; Auto or 8K; 6 / 11 / 13 GiB; native 32K or 131K; 16 or 12 GB dGPU; 1 or 4 slots; 60 GB or 1 GB free on the APU; no projector or a 4 GiB host projector.--fit on-> dGPU "0" fully resident,--fit offIn 56 of the 80 explicit-pick cells the slot search now settles on 1 to 3 fully resident slots instead of 4 slots with
--fitoffload; that is Studio's existing rule of full GPU residency over offload, and matches what #14372 did.Tests
test_llama_cpp_placement.py: the review's spoof cells (6 GiB, native 131072, dGPU 7600/8192 and 11000/12288 MiB, APU total 0 and 131072) land on the APU at 131072 with--parallel 4 -ngl -1; the drafter probe at 1 and 4 slots keeps the drafter and slots; projector and checkpoint pricing under explicit picks via argv and env; the leading-ordinal rule; controls (a dGPU holding the full context wins, an 8K model and an explicit 8K stay on the dGPU, no-APU hosts unchanged). 14 new tests fail on main and pass here. Related placement suites: no failure appears only on this branch (the shared ones are the knowntest_mmproj_placement_policyand gguf-module / drafter failures).