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.
This commit is contained in:
Daniel Han 2026-07-18 14:53:31 +00:00
commit 07ccf2b233
3 changed files with 14 additions and 5 deletions

View file

@ -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" }

View file

@ -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

View file

@ -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