Repository navigation
Say why Studio could not enumerate a GPU, instead of just logging [] - #10056
Conversation
A user reported a model running from system RAM. Their entire log said: GGUF size: 16.4 GB, ... GPUs free: [], selected: None, --fit: on Load mode: the whole load (34.3 GB) fits without paging, using --load-mode none. That records the verdict and none of the reason, and the second line reads like reassurance when it is only about disk paging. There was no way to answer "why did my model go to RAM" from it. _get_gpu_memory() returns [] for at least six unrelated reasons: no torch, a torch with no usable CUDA/HIP device, zero devices enumerated, an empty or stale visibility mask, the #7624 arch gate dropping every card, or amd-smi and the torch fallback both declining. Every one of them puts the model on the CPU, and they need completely different fixes. Adds _explain_empty_gpu_probe(), and warns with it at the placement decision when the list is empty. Facts only, gathered without calling mem_get_info, so it never creates the HIP primary context the amd-smi branch exists to avoid. It never raises and never returns "", since an unexplained empty list is the thing being fixed. The arch gate already warns with a better message when it is the cause, so that case is left to it rather than warned about twice. Tests: 15 cases, one per cause plus the mask reporting and the safety properties. Mutation-checked: dropping the mask note fails 1, inverting the coverage test fails 2, returning "" on error fails 1.
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. |
Found by simulating the change across [Linux, WSL, Windows, macOS] x [NVIDIA, AMD/ROCm, CPU only] rather than only on this host. This probe reads CUDA and HIP, so it returns [] on every Mac. load_model has a whole "No GPU is enumerated on Metal" branch for that state, and an Apple Silicon machine in it still offloads the entire model to the Metal GPU. The warning as first written told every one of those users their model was running on the CPU out of system RAM, which is the opposite of what happens. Three of the twelve matrix cells were wrong. The warning now excludes darwin, and the explainer answers for macOS by naming its own blind spot rather than blaming torch for a device it was never going to see. Tests: the three macOS cells, plus a source-level check that the load site keeps both guards. Mutation-checked: warning on macOS fails 1, dropping the explainer's macOS branch fails 3.
|
Verification pass across the platform and GPU matrix, plus what it changed. It found a real bug in this PRThe probe reads CUDA and HIP only, so it returns Fixed in The matrixDriven in an isolated Plus six edge cases, each the same empty list for a different reason: a container hiding every device with an empty Before and afterBefore, a model that ran from system RAM produced only Does it break anythingNo behaviour changes: placement is untouched and this only explains a decision already made. Nothing is added to the launch command, no new flag, no state or config, so old installs are unaffected in both directions. The cost is paid only on the path that already gave up on the GPU, and the explainer never calls Not applicable here: no HTTP route, template or asset changes, so there is nothing for a browser to exercise. I would rather say that than run a browser matrix that proves nothing. 771 passed across |
|
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". |
Both Manual modes set gpus = [] deliberately, to stand the Python planner down and let --fit or an explicit --gpu-layers place the model. The GPU is fully used there. Reading gpus alone, this warned "running on the CPU, model in system RAM" at every Manual load. That is the case this whole change came from. The reporting user's log has "GPUs free: []" directly under "Manual mode with Auto layers hands memory management to llama.cpp --fit", so their empty list was the mode standing the planner down, not a probe that failed. Guard on _detected_gpus, which holds the probe result and is captured before either Manual branch empties the pool. load_model already draws this distinction for _placement_verdict_partial and the load mode. Also replaces the three source-inspection assertions with a structural extraction of the guard. They took a fixed window of characters before the message, and the window stopped covering the condition as soon as the comment grew: two of them passed against a mutant for that reason, which made the check worthless exactly when it mattered. Tests: 21, mutation-checked. Dropping the _detected_gpus guard fails 1, dropping the macOS guard fails 1, capturing _detected_gpus empty fails 1. 869 passed across the GPU suites.
|
Re-checked this properly, and reproduced the state on real hardware rather than only in mocks. Two things came out of it: a second false-positive bug, and a correction to the diagnosis this PR was built on. Reproduced, unmockedReal host, real torch, real CUDA device, fresh subprocess per case: So the The bug that found: Manual mode is not an absent GPUBoth Manual modes set Worse, that is exactly the case this change came from. The reporting user's log reads: Their empty list was the mode standing the planner down, not a probe that failed. I had read it as a probe failure. It very likely was not one, and their model was probably on the GPU throughout. Fixed in The load site is now executed, not just readThe guard is cut out of
A test-quality problem worth namingThree assertions took a fixed window of characters before the message. Once the guard's comment grew, the window stopped reaching the condition, and two of them passed against a mutant that deleted the guard entirely. They are now a structural extraction of the 21 tests, mutation-checked: dropping the |
Two review findings, both reproduced against the code at head. An empty probe does not mean a CPU load. llama.cpp enumerates devices itself and still receives --fit on, so it can place on a GPU this probe never saw, and an explicit gpu_ids pick is restored into gpu_indices below the warning (llama_cpp.py, "if gpu_ids and gpu_indices is None") and pinned for the child, so those loads reach the GPU the user chose. Asserting "will run on the CPU and the model will live in system RAM" stated an outcome this code does not know. The message now reports what this process observed -- it could not enumerate a GPU, so it planned blind and left placement to --fit -- and stops there. Loads with an explicit pick are excluded outright. sys.platform == "darwin" was too broad an exemption. auto_detect_backend selects Metal only on Apple Silicon and falls back to CPU otherwise, so an Intel Mac with an empty probe really is CPU-only and wants this line. Gated on is_apple_silicon via a helper that falls back to the old platform test if the import fails. Tests: 24, and the simulation now covers an explicit GPU pick, Apple Silicon and an Intel Mac. Mutation-checked: dropping the gpu_ids exclusion fails 1, reverting to the blanket darwin exemption fails 1, going back to asserting the launch outcome fails 5.
Two review findings, both introduced by the previous commit. The explainer still answered "macOS offloads through Metal" for any darwin host, while the load site had just been narrowed to Apple Silicon. So an Intel Mac, which auto_detect_backend resolves to CPU, got the warning and then an explanation naming an offload path it does not have. Both now use _metal_capable_host(), and a test asserts they use the same check, since two notions of "is this Mac fine" is how they drifted apart in the first place. The message also said placement was left to llama.cpp --fit. use_fit is the internal default, read before extra_args are appended to the command, and a last-wins --fit off there wins; the later code calls fit_is_effectively_on for exactly that distinction, and cmd does not exist yet at this point. The message now reports only that the load was planned without device information, and claims nothing about what runs it. Also fixes the test helper that extracts the guard. It stopped at the line holding the marker, so the message's continuation literal was never inspected and a mutant rewriting it passed. It now walks to the end of the block by indentation, and that mutant fails 2. Tests: 29. Mutation-checked: reverting the explainer to blanket darwin fails 2, re-claiming the fitter fails 2. 781 passed across the GPU suites.
|
Codex Review: Didn't find any major issues. What shall we delve into next? 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". |
Comments only, no code change. 27 comment lines to 7.
When Studio cannot enumerate a GPU it plans the load blind and hands placement to
llama.cpp --fit, and the log records that it happened but never why.Before
_get_gpu_memory()returns[]for several unrelated reasons, and they need different fixes:CUDA_VISIBLE_DEVICES,HIP_VISIBLE_DEVICES,ROCR_VISIBLE_DEVICES,GPU_DEVICE_ORDINAL), which a container can set without the user knowingReading
[]you cannot tell which._get_gpu_memory_amd_smi's own docstring lists several more ways to reach it.After
What this deliberately does not claim
It does not say the model will run on the CPU. llama.cpp enumerates devices itself and still receives
--fit on, so it can place on a GPU this probe never saw. Earlier revisions of this PR did assert that, and it was wrong.Three states are excluded, because an empty list there does not mean the probe failed:
gpuson purpose to stand the planner down;_detected_gpusholds the real probe resultgpu_idspickgpu_indicesbelow this block and pinned for the childauto_detect_backendfalls back to CPU thereThe arch gate already warns with a better, more actionable message when it is the cause, so that case is left to it.
Scope, honestly
This is a diagnostic. It changes no placement, adds no flag, no config and no state, so old installs are unaffected in both directions. It does not fix a reported failure: the log that prompted it turned out to be Manual mode standing the planner down, which this now correctly stays quiet about. The value is the visibility-mask and amd-smi-declined cases, which are currently unanswerable from a log.
The explainer never calls
mem_get_info, so it does not create the HIP primary context the amd-smi branch exists to avoid; a test fails if it ever does.Testing
Reproduced unmocked on a real CUDA host: an empty
CUDA_VISIBLE_DEVICESand a mask pointing at an absent ordinal both drive the probe to[]and produce the right reason, while the normal case stays non-empty and silent.Simulated in an isolated
uvvenv across [Linux, WSL, Windows, macOS] x [NVIDIA, AMD/ROCm, CPU only], plus 6 edge cases and 13 load-site cases. The guard is executed, not just read: it is cut out ofllama_cpp.pyby indentation and exec'd with controlled bindings, so the shipped text runs.24 tests, mutation-checked; 776 passed across nine GPU suites.