provision: ignore junk/0 UNSLOTH_LLAMA_BUILD_JOBS (cmake -j0 = all cores)

A non-numeric or 0 override silently fell through to `cmake -j0`, which
builds with ALL cores -- the opposite of the thermal-headroom default and a
shutdown risk on NVIDIA-ARM laptops. Validate it's a positive integer; ignore
anything else and auto-compute.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Daniel Han 2026-06-04 13:28:53 -07:00
commit 11d632307c

View file

@ -136,7 +136,8 @@ fi
# (~1.5 GB per nvcc job) to avoid OOM. Tune with UNSLOTH_LLAMA_BUILD_JOBS=N (raise
# on a well-cooled box, lower if it still trips). Incremental: a re-run resumes.
_ncpu="$(nproc 2>/dev/null || echo 4)"
if [ -n "${UNSLOTH_LLAMA_BUILD_JOBS:-}" ]; then
# Honor a valid positive-int override; ignore junk/0 (cmake reads -j0 as "all cores").
if [ -n "${UNSLOTH_LLAMA_BUILD_JOBS:-}" ] && [ "${UNSLOTH_LLAMA_BUILD_JOBS}" -ge 1 ] 2>/dev/null; then
JOBS="$UNSLOTH_LLAMA_BUILD_JOBS"
else
_half=$(( (_ncpu + 1) / 2 )) # ~half the cores for thermal headroom