win32: auto-enable the GPU in bare coli chat#363
Conversation
|
Cross-ref for context: this launcher fix only does something useful once #298 (g64 CUDA backend, Related branches:
This PR (#363) is the clean standalone |
On Windows a bare 'coli chat' (no --gpu/--vram/--auto-tier) ALWAYS ran CPU-only, even on a CUDA build with a GPU present. Two defects: 1. cuda_binary() returned False on Windows. It detects CUDA by running 'ldd glm | grep libcudart', which is Linux-only (no ldd on win32) and meaningless anyway because the Windows engine links cudart only inside a runtime-loaded coli_cuda.dll, not as a libcudart symbol in glm.exe. So the --gpu/--vram/--auto-tier gates (which call cuda_binary()) never opened. 2. Even with detection fixed, bare 'coli chat' set no CUDA env: env_for's else-branch only enables CUDA when --gpu/--vram is passed. Nothing auto-enabled the GPU. Now: cuda_binary() on non-Linux returns True iff coli_cuda.dll exists next to glm.exe β the exact file backend_loader.c loads from the engine's own directory, so its presence is a faithful, cheap, DLL-hijack-safe proxy for a CUDA-capable build. And env_for, scoped to win32 (Linux keeps its working explicit-flag UX), auto-enables CUDA when a bare chat detects a CUDA build plus a GPU via nvidia-smi, sizing the expert-tier VRAM budget from real free VRAM via the existing build_plan/environment_for_plan machinery (same as --auto-tier, no guessed budget). If nvidia-smi is missing it falls back to CPU with a clear warning; --gpu none still forces CPU; explicit --vram/--gpu still win. CUDA_DENSE stays an explicit opt-in (matches --auto-tier). Verified on a Windows + RTX 5070 Ti box: bare 'coli chat --model <g64>' now prints '[GPU] auto-enabled CUDA ... 13.0 GB expert tier' and emits COLI_CUDA=1 / COLI_GPUS=0 / CUDA_EXPERT_GB=13.044 (was: all unset, CPU-only). Tests: 4 new cases (auto-enable, nvidia-smi-missing fallback, CPU-build silent, Linux-unchanged) plus the 4 existing default-I/O tests guarded to mock cuda_binary() so they stay host-independent. Full python suite green (env_defaults 8, resource_plan 10, doctor 8, makefile_platform 3, cli_output 3). Out of scope: doctor.cuda_linkage is also POSIX-only and mis-reports on Windows β separate follow-up.
669ee03 to
0b05f6a
Compare
|
Rebased onto current Conflict resolutionOne conflict in VerificationIncluding the 3 |
Summary
On Windows, a bare
coli chat(no--gpu/--vram/--auto-tier) always ran CPU-only, even on a CUDA build with a GPU present. Two defects:cuda_binary()returnedFalseon Windows. It detects CUDA by runningldd glm | grep libcudartβ Linux-only (nolddon win32) and meaningless anyway, because the Windows engine links cudart only inside a runtime-loadedcoli_cuda.dll, not as alibcudartsymbol inglm.exe. So the--gpu/--vram/--auto-tiergates (which all callcuda_binary()) never opened.Bare
coli chatset no CUDA env even with detection fixed.env_for'selse:-branch only enables CUDA when--gpu/--vramis passed. Nothing auto-enabled the GPU. So every Windows user runningcoli chaton a CUDA build silently got CPU-only.The fix
cuda_binary()β on non-Linux, returnTrueiffcoli_cuda.dllexists next toglm.exe. That is the exact filebackend_loader.cloads from the engine's own directory, so its presence is a faithful, cheap, DLL-hijack-safe proxy for a CUDA-capable build. (Linux keeps the workinglddcheck untouched.)env_forβ scoped to win32 (Linux keeps its working explicit-flag UX), when a bare chat (a.gpu is None, no--vram, no--auto-tier) detects a CUDA build and a GPU vianvidia-smi, it now:COLI_CUDA=1+COLI_GPUS=<detected indices>build_plan/environment_for_planmachinery (same as--auto-tierβ no guessed budget, 2 GB reserve honoured)[GPU] auto-enabled CUDA Β· <names> Β· <N> GB expert tierIf
nvidia-smiis missing fromPATHit falls back to CPU with a clear warning (pass --vram N to enable CUDA).--gpu nonestill forces CPU; explicit--vram/--gpustill win;CUDA_DENSEstays an explicit opt-in (matches--auto-tier).Verification
On a Windows + RTX 5070 Ti box (this branch):
Resulting env:
COLI_CUDA=1,COLI_GPUS=0,CUDA_EXPERT_GB=13.044(before: all unset, CPU-only). Overrides confirmed:--gpu noneβCOLI_CUDA=0;--vram 4βCUDA_EXPERT_GB=4. Engine smoke run prints[CUDA] mode: routed experts only.Tests: 4 new cases in
test_env_defaults.py(CudaAutoEnableTest):test_win32_auto_enables_cuda_when_gpu_presenttest_win32_falls_back_to_cpu_when_nvidia_smi_missingtest_win32_cpu_build_stays_silenttest_linux_bare_chat_not_auto_enabled(proves the win32 guard is scoped)The 4 existing default-I/O tests are guarded to mock
cuda_binary()so they stay host-independent. Full Python suite green:env_defaults8,resource_plan10,doctor8,makefile_platform3,cli_output3.Behaviour matrix
coli chat(win, CUDA build + GPU)coli chat(win, CUDA build, no nvidia-smi)coli chat(win, CPU build)coli chat --gpu nonecoli chat --vram 4make glm CUDA=1to even startcoli chat(Linux)Out of scope
doctor.cuda_linkageis also POSIX-only and mis-reports CUDA on Windows (coli doctorsays "engine is CPU-only" even on a CUDA build). Same class of bug, different command β separate follow-up.compat_preadtransient-retry fix for [Bug]: python coli chat doesn't endΒ #307).