CI(Core): spoof torch.cuda before importing unsloth_zoo in llama.cpp smoke

The previous push of the install_llama_cpp-based smoke failed across
all three cells with:

  File "unsloth_zoo/device_type.py:220" in get_device_type
    raise NotImplementedError("Unsloth cannot find any torch
    accelerator? You need a GPU.")

unsloth_zoo/__init__.py calls device_type.get_device_type() at module
load. On the GH ubuntu-latest CPU-only runner this raises before any
of our code runs. The pytest shims sidestep this by importing
tests/_zoo_aggressive_cuda_spoof.py first; the inline `python <<PY`
block was missing the same harness.

Apply the spoof at the top of the inline script so torch.cuda.is_
available() returns True before the unsloth_zoo import. We never
actually run CUDA tensor ops in this step -- just clone + cmake +
binary --help -- so the spoof is sufficient.
This commit is contained in:
Daniel Han 2026-05-07 07:55:39 +00:00
commit ec9b25da0e

View file

@ -626,7 +626,18 @@ jobs:
sudo apt-get install -y -qq build-essential cmake git curl \
libgomp1 libssl-dev libcurl4-openssl-dev
python <<'PY'
import os, shutil, subprocess, sys
import os, shutil, subprocess, sys, pathlib
# Apply the same CPU spoof the pytest shims use BEFORE any
# unsloth_zoo import: unsloth_zoo/__init__.py calls
# device_type.get_device_type() at module load and raises
# `NotImplementedError: Unsloth cannot find any torch
# accelerator` on a GPU-less runner. The spoof flips
# torch.cuda.is_available() to True so the device probe takes
# the cuda branch; we never actually run CUDA tensor ops in
# this step (just clone+cmake+--help on the binaries).
sys.path.insert(0, str(pathlib.Path("tests").resolve()))
import _zoo_aggressive_cuda_spoof as _spoof
_spoof.apply()
from unsloth_zoo.llama_cpp import (
install_llama_cpp,
LLAMA_CPP_DEFAULT_DIR,