Repository navigation
Fix Windows llama.cpp prebuilt setup with inaccessible PATH entries - #7696
Conversation
|
Codex Review: Didn't find any major issues. Keep them coming! 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". |
Narrowing the source build to helper exit 2 made every other nonzero exit
fatal, but the helper reports a rate-limited or unreachable api.github.com
as EXIT_ERROR: fetch_json raises a bare RuntimeError for HTTP 403, and the
fork branch of the release resolver has no wrapper of its own where the
ggml-org branch does. Unauthenticated GitHub API calls are limited to 60 an
hour per IP, so a shared runner or a NAT'd network hits this routinely, and
a source build clones over git rather than the API, which is why falling
back used to recover. This PR's own macos-14 kill@torch run failed exactly
that way.
Classify release-listing failures on the install path as PrebuiltFallback so
they exit 2 again. Scoped to install_prebuilt rather than the resolver:
--resolve-prebuilt turns PrebuiltFallback into a successful
{"prebuilt_available": false} payload and update_flow caches any exit-0
answer for RESOLVE_TTL_SECONDS, so wrapping there would pin a transient 403
as "no prebuilt" for 24 hours.
Also close the paths that stayed fatal:
- collect_system_report ran inside the PrebuiltFallback handler, so a probe
that raised replaced the in-flight fallback with EXIT_ERROR.
- python_runtime_dirs and windows_runtime_dirs stat sys.path entries and
%ProgramFiles% outside dedupe_existing_dirs, so skip_unusable could not
protect them and a denied entry still aborted Windows discovery.
- binary_env still required inherited LD_LIBRARY_PATH and DYLD_LIBRARY_PATH
to be readable, the same thing the Windows branch stopped requiring.
- sync_marker_force_cpu and sync_marker_llama_backend guarded the marker
read but not the write, so a read-only marker on an otherwise up to date
install failed setup.
- runtime_libs.python_runtime_dirs, the serve-time copy, had the same
unguarded sys.path stat; the sidecar turns the raise into an empty dir
list and loses every CUDA wheel dir.
|
Reviewed this end to end and pushed fb30484 to the branch. The The regression
Unauthenticated GitHub API calls are capped at 60 per hour per IP, so any user without Driving each version's own
So the intent of the PR is preserved: an unexpected error still refuses to source-build. Only transient transport failures go back to falling back. Also fixed in fb30484
Verification
Not changed here, worth separate PRs
One behaviour change worth calling out as intended rather than accidental: Ctrl-C during the prebuilt step (130) used to start a source build and now aborts, which is the better outcome. |
|
Codex Review: Didn't find any major issues. Nice work! 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". |
…rker Three follow-ups from cross-platform validation. The resolver wrapper caught Exception, so a TypeError or AttributeError from a bug in host-conditional resolver code (per-gfx ROCm, Windows arm64, the macOS walk-back) also exited 2 and bought a source build, logged under a message that blames the network. Narrow it to OSError, RuntimeError and ValueError, which covers every transient shape by MRO: URLError, HTTPError, SSLError and TimeoutError are OSError, JSONDecodeError is a ValueError, and fetch_json raises a bare RuntimeError for HTTP 403. Code defects go back to EXIT_ERROR, with a test pinning that direction. Guarding the marker write stopped a read-only marker from failing setup, but it also let a deliberate --force-cpu go unrecorded while setup reported success, which is how the updater re-routes a CPU user onto a GPU bundle (unslothai#7213). Write through atomic_write_bytes first, which swaps in a sibling temp file and so lands on a read-only marker in a writable dir, and warn loudly when it genuinely cannot be recorded. Skip the setup.sh routing test on Windows: setup.sh is the POSIX installer, Windows runs setup.ps1, and driving a POSIX script through Git Bash with Windows paths proves nothing about either. The PowerShell branch of the same routing stays covered by the platform-independent textual test.
…marker Guarding only the search root left the strict dedupe on python_runtime_dirs' own return to raise, so a readable site-packages with a denied torch/lib or nvidia/*/lib child still aborted Windows discovery. That is the same shape as the bug this branch is about, one level down: the parent lists fine and the entry underneath is denied. These candidates are optional CUDA wheel dirs found by globbing, and one that cannot be stat'd could not have served DLLs to the loader either, so skip them like the serve-time copy already does. Drop the in-place retry in the marker rewrite. It opened a valid marker with truncation, so an ENOSPC or I/O error mid-write would strand a partial UNSLOTH_PREBUILT_INFO.json and later updates would stop recognising the install. The atomic path already covers the case the retry was there for, a read-only marker in a writable dir; when it fails, leave the old marker alone and warn.
os.replace keeps the source file's mode and NamedTemporaryFile is 0600, so refreshing a shared install's marker left UNSLOTH_PREBUILT_INFO.json readable only by whoever ran setup, and other users could no longer recognise or update that installation. Reproduced: a 0444 marker came back 0600. Build the temp file here instead of calling atomic_write_bytes, so the original mode is restored before the swap rather than after, leaving no window where the marker is private. Clean up the temp file if the replace fails, so a failed refresh strands nothing next to the marker.
A plain OSError is not evidence of a network problem. EMFILE after file descriptor exhaustion, ENOMEM, or a local EACCES reading TLS configuration were all being converted to EXIT_FALLBACK, so setup started the resource heavy source build that this branch otherwise refuses for unexpected helper failures, and a build needs more descriptors and more memory, not fewer. Name the transport shapes instead: URLError covers HTTPError and the socket/DNS errors urllib wraps, plus SSLError, ConnectionError, TimeoutError, and the RuntimeError and ValueError that fetch_json raises for a 403 and for an undecodable payload. ENOSPC still reaches EXIT_NO_SPACE, now through __main__'s classifier rather than install_prebuilt's, and the test asserts it the same way __main__ decides it. The marker temp file was only unlinked when the chmod or the replace failed. A write, flush or fsync that raised, which is the ENOSPC case this is built to tolerate, jumped straight past the cleanup and left a partial UNSLOTH_PREBUILT_INFO.json.tmp-* beside the valid marker, one per attempt on a full volume. Track it across every failure path instead. Also restore the original owner and group on the replacement where the caller is permitted to, since os.replace installs the temp file's ownership and a shared marker would otherwise pick up the invoking user's primary group.
|
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". |
|
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". |
Summary
Keep Windows llama.cpp prebuilt setup from failing when the inherited
PATHcontains directories the current user cannot inspect. Unexpected helper errors now stop setup with the original diagnostic instead of launching a resource-heavy source build.Motivation
A normal Windows user can inherit this SYSTEM-profile entry:
C:\WINDOWS\system32\config\systemprofile\AppData\Local\Microsoft\WindowsAppsCalling
Path.is_dir()on it can raisePermissionError: [WinError 5] Access is denied. Runtime discovery treated everyPATHentry as required, so the prebuilt helper failed. The setup scripts then treated any nonzero exit as permission to compile llama.cpp from source.Changes
studio/install_llama_prebuilt.py:4411.PATHentries as optional instudio/install_llama_prebuilt.py:4718andstudio/install_llama_prebuilt.py:4988.2) instudio/setup.ps1:4059andstudio/setup.sh:1580.tests/studio/install/test_install_llama_prebuilt_logic.py:909.How to test
python -m pytest -q -p no:cacheprovider tests/studio/install/test_install_llama_prebuilt_logic.py -k "not test_setup_sh_cleanup_unlinks_instruction_symlink_only and not test_diffusion_visual_server_uses_approved_checksum_download" ruff check studio/install_llama_prebuilt.py tests/studio/install/test_install_llama_prebuilt_logic.py python -m py_compile studio/install_llama_prebuilt.py tests/studio/install/test_install_llama_prebuilt_logic.py git diff --check