Repository navigation
Studio runtime keeps the GPU when nvidia-smi cannot answer, and prefers a GPU-capable llama-server beside a CPU build - #11005
Conversation
…ndows embedding DLL path
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. |
…r the GPU build this host's vendor runs
|
@codex review |
|
@codex security review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6fa7fd574e
ℹ️ 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 token.isdigit(): | ||
| hits = [r for r in rows if str(r.get("index")) == token] |
There was a problem hiding this comment.
Defer numeric masks until GPU index spaces agree
When nvidia-smi fails on a heterogeneous multi-GPU host and CUDA_DEVICE_ORDER is not PCI_BUS_ID, numeric CUDA_VISIBLE_DEVICES entries are CUDA ordinals, while these NVML row indices identify physical devices. Matching them directly can therefore feed auto-placement the free/total memory of a different GPU and cause an invalid layer fit or OOM; the existing _cuda_compute_caps path explicitly declines this same join unless PCI ordering is enabled, so this fallback should likewise defer to the CUDA/torch probe or map the devices by UUID.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
The NVML index is the index nvidia-smi prints (nvidia-smi is an NVML client, same enumeration), so this fallback joins a numeric mask exactly as the nvidia-smi rows above it do and sets _GPU_IDS_ARE_PCI_INDICES for the same reason. A different join here would make the two probes disagree on the same host. UUID entries now match the rows' own uuid, which is the unambiguous form.
…est allows a card with no free memory
…fer only backends this process can reach, for PR #11005
…r set, void the probe on a missing handle, for PR #11005
|
Codex Review: Didn't find any major issues. You're on a roll. 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". |
|
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". |
…ple Silicon, for PR #11005
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. Swish! 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". |
…rs a GPU-capable llama-server beside a CPU build (unslothai#11005) * Runtime NVML memory fallback, GPU-capable llama-server preference, Windows embedding DLL path * Honour uuid CUDA_VISIBLE_DEVICES masks in the NVML fallback and prefer the GPU build this host's vendor runs * Keep a denied pinned candidate ahead of the GPU-capable reorder for PR unslothai#11005 * An ambiguous uuid abbreviation hides every GPU; the real-host probe test allows a card with no free memory * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * List MIG slices in the probe so a MIG assignment is honoured, and prefer only backends this process can reach, for PR unslothai#11005 * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Hand a uuid mask back to the child as uuids, keep a known-empty vendor set, void the probe on a missing handle, for PR unslothai#11005 * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Keep the devices before an invalid mask entry, prefer the GPU build in the legacy in-tree fallback, read the CUDA mask for HIP, for PR unslothai#11005 * A MIG parent is its first slice to CUDA: report the slice memory and pin the child to it, for PR unslothai#11005 * A MIG slice the mask names stays that slice, for PR unslothai#11005 * One MIG slice per card, and the uuid map is reset for every memory query, for PR unslothai#11005 * Apply the repository kwarg spacing, for PR unslothai#11005 * Read the WSL2 runtimes behind /dev/dxg as the GPU vendor, for PR unslothai#11005 * Derive the child's uuid pin from the NVML rows on each call, let a GPU build for another vendor yield, skip the Linux path test on Windows, for PR unslothai#11005 * Make the embedding and sibling-build tests independent of the host, for PR unslothai#11005 * Tell the probe child to emit utf-8, and pin the embedding test off Apple Silicon, for PR unslothai#11005 * A visible NVML row without a memory reading voids the answer, for PR unslothai#11005 * The two ROCm visibility masks stack when deciding whether AMD is reachable, for PR unslothai#11005 * A full card is a reading; only a missing total voids the NVML answer, for PR unslothai#11005 --------- Co-authored-by: danielhanchen <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
The runtime half of #10985, plus the binary-precedence defect behind #5941. Both leave a working CUDA llama.cpp running on the CPU, which is what the "my GPU is not used" reports describe once the installer side is right.
What was wrong
LlamaCppBackend._get_gpu_memoryasks nvidia-smi, then amd-smi, then torch. On a host where nvidia-smi is absent, stale or hung and torch is not installed (a GGUF-only install), it returns[], andLlamaServerBackend._gpu_availablereads that as "no GPU": the embedding server is launched with-ngl 0andCUDA_VISIBLE_DEVICES=""around a CUDA build. The installers stopped trusting that misread in Studio: read the NVIDIA inventory from NVML or the CUDA driver when nvidia-smi cannot answer #10985; the runtime still did.llama_server_candidateslisted only<root>/,build/binandbuild/bin/Release, and the finder took the first executable hit, so a tree with a CPUbuild/next to a CUDAbuild-cuda/ran on the CPU forever, with the user's log reading "llama.cpp was compiled without GPU support" while training used the GPU normally._build_windows_path_dirs(venv nvidia wheels,CUDA_PATH); the embedding server built its own environment and skipped it, so a CUDA build whose cudart lives in the venv loaded no GPU backend.sys.prefixwent intoglob.globunescaped, soStudio[CUDA]matched nothing and the child lost its CUDA library path.torch/libwas also missing from the chat and embedding lists although the shared helper includes it.The change
studio/nvidia_probe.pyreportsmemory_total_mibandmemory_free_mibper NVML device (nvmlDeviceGetMemoryInfo); the CUDA driver rows carry 0, since memory needs a context that probe never creates._get_gpu_memorygains an NVML step between nvidia-smi and amd-smi:_get_gpu_memory_nvmlruns the probe module in a child with a 10 s deadline, masks the physical rows byCUDA_VISIBLE_DEVICESas the CUDA runtime reads it (indices, GPU- and MIG- uuid prefixes; an entry naming no single device ends the mask there), reports a GPU in MIG mode as the slice CUDA exposes and pins the child to it by uuid, and ignores rows without a memory reading so the torch probe still runs.UNSLOTH_NVIDIA_LIBRARY_PROBE=0turns it off, as it does the installers' probe.llama_server_candidatesalso listsbuild-cuda,build-hip,build-rocmandbuild-vulkan;prefer_gpu_capablemoves a usable candidate that ships a GPU backend library ahead of a first hit proven CPU-only (a split-library build withggml-cpuand no GPU backend beside it). Unknown layouts, the installer's wrapper included, keep their place, so the managed install resolves as before. Bothresolve_llama_server_binaryand the runtime finder use it.torch/lib.Measured
On this host (8x B200, driver 590.48.01), with a stub
nvidia-smithat exits 1 on PATH and no torch importable:_get_gpu_memory()[][(3, 182630, 183359)](the one GPUCUDA_VISIBLE_DEVICESallows)-ngl 0,CUDA_VISIBLE_DEVICES=""-ngl -1Tests
studio/backend/tests/test_gpu_memory_nvml_fallback.py: the NVML step (a failing nvidia-smi now reads the inventory, the mask applies in its index, uuid and MIG forms, rows without memory are not evidence, a working nvidia-smi is not second-guessed, the switch and a missing script turn it off, the real script is found beside the installers), the embedding decision (offloads on NVML alone, still CPU when nothing answers), the Windows embedding DLL path, the bracketed prefix andtorch/libon both Linux builders, and the #5941 tree on Linux and Windows layouts for both the settings resolver and the runtime finder. The probe module tests cover the new payload fields, including on a real NVIDIA host.