Repository navigation
Docker Studio: keep the base image's CUDA llama.cpp instead of the CPU prebuilt - #10495
Conversation
…U prebuilt docker/Dockerfile.studio symlinks Studio's llama.cpp dir at the base image's baked CUDA bundle and then runs install.sh --local, but no GPU is visible during an image build, so studio/setup.sh hands install_llama_prebuilt.py a host with has_usable_nvidia=False and _linux_published_attempts() resolves the CPU bundle for the arch and installs it over the CUDA one. setup.sh now honours UNSLOTH_LLAMA_KEEP_PREBUILT=1 through a new _keep_installed_gpu_prebuilt(), which keeps an installed bundle whose UNSLOTH_PREBUILT_INFO.json records a GPU backend from the requested fork at the requested tag, and Dockerfile.studio sets that knob and then fails the build if /opt/unsloth/llama.cpp/libggml-cuda.so is gone after install.sh, mirroring the base Dockerfile's own unresolved-library guard. The knob is opt-in and every other path is untouched: an explicit UNSLOTH_LLAMA_CPP_BACKEND, UNSLOTH_LLAMA_PR, UNSLOTH_LLAMA_FORCE_COMPILE and --with-llama-cpp-dir are all decided before it, a stale tag, a different fork, a CPU or force_cpu marker and a tree with no llama-server are all still replaced, and the arm64 CPU last resort is additionally gated so it cannot undo a kept bundle. Contrary to the report this is not arm64 only. Streaming the Studio install layer of the published unsloth/unsloth:latest straight from the registry shows the same whiteouts on both arches: opt/unsloth/llama.cpp/.wh.libggml-cuda.so and opt/unsloth/llama.cpp/build/bin/.wh.libggml-cuda.so appear in the arm64 child sha256:967df570 and in the amd64 child sha256:177bba4f alike, and the resolver run against the live b10840-mix-d5c17a0 manifest with no GPU picks app-...-linux-arm64-cpu.tar.gz on aarch64 and app-...-linux-x64-cpu.tar.gz on x86_64. The fix is therefore arch independent. Verification without a GPU: the new tests/studio/install/test_docker_studio_keep_cuda_prebuilt.py adds 22 tests, two of which pin the CPU resolution on both arches through the real selector, seventeen drive setup.sh's keep decision out of the live script under a stubbed aarch64 PATH with a failing nvidia-smi against real base-image and installer-written markers, and three pin the wiring. tests/studio/install passes 3968 tests with 6 skips, tests/python/test_docker_llama_prebuilt_probe.py passes 5, all 32 tests/sh scripts that read setup.sh exit 0, bash -n studio/setup.sh is clean and docker buildx build --check on docker/Dockerfile.studio reports no warnings. docker/unsloth_llama_update.sh and docker/fetch_llama_prebuilt.py already agree on amd64 to linux-x64-cuda12-portable and arm64 to linux-arm64-cuda13-portable and needed no change; a full arm64 Studio image build is left to CI.
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. |
|
@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: df4311d93b
ℹ️ 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".
| recorded.discard("") | ||
| if not recorded: | ||
| raise SystemExit(1) | ||
| if requested and requested.lower() != "latest": |
There was a problem hiding this comment.
When UNSLOTH_LLAMA_TAG is pinned to a full release such as b10840-mix-new but the installed marker records b10840-mix-old, this condition accepts the install because both values collapse to b10840. Same-base mix releases are distinct artifact identities, so the keep branch skips the installer and the Docker assertion still passes as long as the old CUDA libraries exist, silently shipping a different release than requested. Require an exact release_tag match for full mix-release pins, reserving the normalized comparison for a bare bNNNN request; the keep decision should also honor an explicit UNSLOTH_LLAMA_RELEASE_TAG.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Agreed. A full mix release pin now has to match the marker's release_tag exactly, an explicit UNSLOTH_LLAMA_RELEASE_TAG is honoured the same way, and the normalized comparison only applies to a bare bNNNN request.
|
Local amd64 Studio build at df4311d on top of The keep branch ran and the assertion passed. One caveat: this host's Docker daemon exposes the GPU during builds, so the pre-fix CPU replacement does not reproduce here (with a GPU visible the old path would have resolved a CUDA asset anyway). The no-GPU CI builder is where the keep branch matters, and the assertion fails the build if it ever does not hold. The arm64 leg is covered by the same code path and the next scheduled publish. |
_keep_installed_gpu_prebuilt() normalized both sides of the tag comparison to their base build, so UNSLOTH_LLAMA_TAG=b10840-mix-new against a marker recording b10840-mix-old collapsed to b10840 on both sides and the stale bundle was kept. A requested tag that is not a bare bNNNN is now required to match one of the marker's recorded release_tag / tag / upstream_tag exactly, while a bare base build pin keeps the existing normalized comparison and latest still accepts; UNSLOTH_LLAMA_RELEASE_TAG is passed in as a fourth argument and must equal the marker's release_tag exactly, independently of the tag check. Dockerfile.studio is unaffected: it passes UNSLOTH_LLAMA_TAG=latest by default and sets no release tag. tests/studio/install/test_docker_studio_keep_cuda_prebuilt.py covers exact mix match, a different mix from the same base build, a bare base pin, and a matching and mismatching UNSLOTH_LLAMA_RELEASE_TAG.
|
@codex review |
|
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". |
Summary
The published
unsloth/unsloth:latest/:studioimages ship a CPU-only llama.cpp while:coreships the CUDA one. #10491 found it on a DGX Spark (arm64); this PR shows it is arch independent and the amd64 image has the same defect.Mechanism:
docker/Dockerfile.studiopoints Studio's llama.cpp directory at the base image's baked CUDA bundle (/opt/unsloth/llama.cpp, marker.unsloth-studio-owned) and then runsinstall.sh --local. No GPU is visible during the image build, sostudio/setup.shhands off toinstall_llama_prebuilt.py, whose host detection (nvidia-smi -Lor/proc/driver/nvidia/gpus) finds nothing and resolves a CPU asset (linux-x64-cpuon amd64,linux-arm64on arm64). That asset name does not match the installed CUDA bundle, so the installer replaces it. The Studio install layer of both published images carries whiteouts foropt/unsloth/llama.cpp/libggml-cuda.soandbuild/bin/libggml-cuda.so.Confirmed on both architectures without a full pull, by streaming the Studio install layer from the registry:
sha256:7940d6e4....wh.libggml-cuda.so(both paths)libggml-cpu-armv8*,armv9*sha256:615f58a8....wh.libggml-cuda.so(both paths)libggml-cpu-alderlake,zen4,sapphirerapids, ...And on a B200 host with the local amd64 images:
latest's marker readsbundle_profile: linux-cpu-x64,backend: cpu,asset: app-b10798-mix-659e406-linux-x64-cpu.tar.gz.Change
studio/setup.sh: new_keep_installed_gpu_prebuilt()and anelifin the llama.cpp branch chain, placed after the local-dir, explicit-backend, force-compile and PR branches so none of them is hijacked. Gated onUNSLOTH_LLAMA_KEEP_PREBUILT=1|true|yes|on; keeps the installed bundle only when its marker records a GPU backend, the same fork and the same tag (the normalized base build, sob10840matchesb10840-mix-d5c17a0) andllama-serveris present. A stale, CPU or foreign bundle is still replaced. The arm64 CPU last resort gets the same guard.docker/Dockerfile.studio: passesUNSLOTH_LLAMA_KEEP_PREBUILT=1intoinstall.sh --local, then fails the build iflibggml-cuda.sois missing from either path, printing the marker, mirroring the base Dockerfile's own check.docker/unsloth_llama_update.shanddocker/fetch_llama_prebuilt.pyalready resolve the CUDA portable bundles per arch; unchanged.Tests
tests/studio/install/test_docker_studio_keep_cuda_prebuilt.py: 22 passed. Two pin the CPU resolution on both arches through the real selector; seventeen drive_keep_installed_gpu_prebuiltsliced out of the livesetup.shunder a stub PATH (uname -mreports aarch64,nvidia-smiexits 9) against real marker files: keep for the base image's CUDA marker at the pinned tag, the base build andlatest, the installer-writtenbackend: cudamarker and ROCm; replace for the shippedbackend: cpumarker, a CPU platform,force_cpu, a stale tag, another fork, no marker, broken JSON, nollama-server, knob unset or0, and an explicit backend request. Three pin the wiring: branch ordering, the arm64 guard, the Dockerfile knob and assertion.tests/studio/install: 3968 passed, 6 skipped.tests/python/test_docker_llama_prebuilt_probe.py: 5 passed. All 32tests/shscripts that readsetup.shexit 0.bash -n studio/setup.shclean.docker buildx build --check -f Dockerfile.studio: no warnings.A local amd64 Studio build at this head is running to confirm the assertion passes and
llama-server --list-devicesreports the GPU; the result will be posted here.