From 07ccf2b2339c119af9359ba730c0862f8326fec3 Mon Sep 17 00:00:00 2001 From: Daniel Han Date: Sat, 18 Jul 2026 14:53:31 +0000 Subject: [PATCH] install: reconcile branch internals with the repo test suite Cross-platform staging CI surfaced five Repo tests (CPU) failures where main's tests assert on script internals this branch legitimately changed; each reconciled on its merits. The WoA native-wheel probe still used uv's deprecated --index-url alias that main's test suite now forbids in favor of --default-index (same semantics, and --default-index is what overrides inherited uv index defaults); the probe now matches the convention. The CUDA provision gate spelled its linked-dir guard with the :-false default form that main's prune-refactor test blacklists file-wide. The variable is unconditionally initialized far above, so the guard now uses the plain spelling with identical semantics. The variable guard itself stays: unlike a symlink test, it also covers the canonical-location reuse case where the linked dir is not a symlink. The gpu-detection tests extract named shell functions into a sandbox, so _setup_has_usable_nvidia_gpu's new _resolve_nvsmi dependency made the sandboxed helper die on command-not-found and report not_usable for usable cases; the extraction list now includes the resolver, and the driver-version hardening assertion tracks the resolved-path spelling while still requiring the timeout wrapper. Also hardened the resolver assignment with an explicit empty fallback so a future non-condition call site cannot trip set -e. The staging run also showed the Mac Studio Update uninstall step dying mid-run, consistent with the round-seven group kill signalling its own process group; the round-eight self-pgid guard already fixes that and this push carries it to CI. Verified: the five failing tests pass locally at this head (the one remaining local red, test_negative_control_no_tokenizers, fails identically with these changes stashed and did not fail in CI), bash -n, PowerShell AST parse, and the sh battery matches the branch baseline. --- install.ps1 | 2 +- studio/setup.sh | 4 ++-- .../studio/install/test_gpu_detection_followups.py | 13 +++++++++++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/install.ps1 b/install.ps1 index 0286d0fd8a..1482bf574f 100644 --- a/install.ps1 +++ b/install.ps1 @@ -2091,7 +2091,7 @@ exit 0 # a native win_arm64 CUDA wheel exists on the index. $global:LASTEXITCODE = -1 try { - & uv pip install --python $VenvPython --dry-run --reinstall "torch>=2.4,<2.11.0" --index-url $TorchIndexUrl *> $null + & uv pip install --python $VenvPython --dry-run --reinstall "torch>=2.4,<2.11.0" --default-index $TorchIndexUrl *> $null $_nativeCudaTorchOk = ($LASTEXITCODE -eq 0) } catch { $_nativeCudaTorchOk = $false } finally { $ErrorActionPreference = $prevEapProbe } if ($_nativeCudaTorchOk) { step "gpu" "native CUDA PyTorch now available for win_arm64 -- keeping native install" "Green" } diff --git a/studio/setup.sh b/studio/setup.sh index a6d219fd25..6aba8bf4f7 100755 --- a/studio/setup.sh +++ b/studio/setup.sh @@ -290,7 +290,7 @@ _setup_has_usable_nvidia_gpu() { if _setup_cvd_hides_nvidia; then return 1 fi - _setup_nvsmi="$(_resolve_nvsmi)" + _setup_nvsmi="$(_resolve_nvsmi)" || _setup_nvsmi="" if [ -n "$_setup_nvsmi" ]; then if _setup_run_smi "$_setup_nvsmi" -L 2>/dev/null \ | awk '/^GPU[[:space:]]+[0-9]+:/{found=1} END{exit !found}'; then @@ -2041,7 +2041,7 @@ if [ "$_HOST_SYSTEM" = "Linux" ] \ && _NVSMI_GATE="$(_resolve_nvsmi)" && [ -n "$_NVSMI_GATE" ] \ && "$_NVSMI_GATE" -L 2>/dev/null | awk '/^GPU[[:space:]]+[0-9]+:/{found=1} END{exit !found}' \ && [ "${_setup_nvidia_usable:-}" = true ] \ - && [ "${_LOCAL_LLAMA_CPP_LINKED:-false}" != true ] \ + && [ "$_LOCAL_LLAMA_CPP_LINKED" != true ] \ && ! _have_cuda_llama_server; then # Under WSL this runs ONLY for a DIRECT `install.sh` run: install.ps1 sets # UNSLOTH_WSL_LLAMA_DEFERRED=1 and builds in the background; a direct run has diff --git a/tests/studio/install/test_gpu_detection_followups.py b/tests/studio/install/test_gpu_detection_followups.py index f5ad9566d7..5c1339d556 100644 --- a/tests/studio/install/test_gpu_detection_followups.py +++ b/tests/studio/install/test_gpu_detection_followups.py @@ -265,10 +265,14 @@ class TestSetupShHardening: assert wrapped, "compute_cap probe must be wrapped in _setup_run_smi (timeout-bounded)" def test_driver_version_probe_timeout_wrapped(self, setup_src): + # The probe resolves nvidia-smi explicitly (root WSL shells drop + # /usr/lib/wsl/lib from PATH) and must still go through the timeout + # wrapper with the resolved path. start = setup_src.find("_cuda_driver_max_version()") end = setup_src.find("\n}", start) body = setup_src[start:end] - assert "_setup_run_smi nvidia-smi" in body + assert "_resolve_nvsmi" in body + assert '_setup_run_smi "$_cdm_smi"' in body # TEST: install.sh -- UNSLOTH_TORCH_BACKEND classified on the final path segment @@ -455,7 +459,12 @@ class TestHiddenCvdNotUsable: out = self._run_sh_helper( tmp_path, src, - ["_setup_run_smi", "_setup_cvd_hides_nvidia", "_setup_has_usable_nvidia_gpu"], + [ + "_resolve_nvsmi", + "_setup_run_smi", + "_setup_cvd_hides_nvidia", + "_setup_has_usable_nvidia_gpu", + ], cvd, ) assert out == expected