cuda-dll: make the Windows CUDA build work as shipped — MSVC host flags, CUDA_PATH defaults, POSIX shim in kernel test (#157, first hardware validation of #131's loader)#158
Conversation
…IX setenv shim in the kernel test (JustVugg#157) First hardware validation of the JustVugg#131 CUDA_DLL path (RTX PRO 6000 Blackwell sm_120, MSVC 14.44 + CUDA 13.2, MSYS2 UCRT64 host build) found three blockers that made 'make cuda-dll' unbuildable as shipped: - NVCCFLAGS passed GCC-style -Xcompiler=-Wall,-Wextra to the MSVC host compiler (hard error D8021). Use -Xcompiler=-W3 on Windows — dash form, since MSYS make mangles /W3 into a filesystem path. - NVCC defaulted to $(CUDA_HOME)/bin/nvcc with CUDA_HOME=/usr/local/cuda; on Windows default CUDA_HOME from the installer's CUDA_PATH and NVCC to plain 'nvcc' from PATH (CUDA_PATH contains spaces, which the unquoted recipe checks cannot survive; an MSVC PATH environment is already required). - tests/test_backend_cuda.cu used POSIX setenv/unsetenv (undefined under MSVC); add a two-line _putenv_s shim. Also corrects the stale '11 API symbols' comment (the header exports 15 and backend_loader.c resolves all 15). Validated: make cuda-dll (stock flags) + make glm CUDA_DLL=1 ARCH=native → [CUDA] device init on sm_120, tiny oracle TF 32/32 + greedy 20/20, kernel suite 'q8/q4/q2/f32 correctness ok', graceful no-dll fallback, plain build byte-identical CPU behavior. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…EASE_HOST=1)
expert_host_release() freed the expert slab with plain free(), but the slab
is posix_memalign'd — which compat.h maps to _aligned_malloc on Windows, so
free() corrupts the CRT heap: instant 0xC0000374 crash on the first released
expert. This is the exact pattern the compat.h audit fixed at the original
expert_load site ("l'unico sito che libera memoria aligned e' free(s->slab)");
this call site was added later and reintroduced it. compat_aligned_free is
plain free on POSIX, so non-Windows behavior is unchanged. fslab stays plain
free (malloc/falloc on the CPU path).
Found running the VRAM expert tier on real hardware (80 GB resident on an
RTX PRO 6000, CUDA_RELEASE_HOST=1 to avoid 80 GB of host double-residency —
reproducible crash before, clean generation after).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Pushed a second commit: running the actual VRAM expert tier on the 96 GB card surfaced a Windows heap-corruption crash in Repro/validation on the RTX PRO 6000 (single GPU):
VRAM-tier performance numbers for a real GLM-5.2 int4 run coming to #156's thread once the current battery finishes. |
|
Independent confirmation of all three fixes on RTX 5090 (sm_120) + RTX 4090 (sm_89), Windows 11, MSVC 14.44 (VS2022 BuildTools) + CUDA 13.1, MinGW-w64 GCC 16.1 host:
Hardware-validated on the full GLM-5.2 int4 checkpoint, not just the tiny oracle. Hope this helps it land — #162 builds on top of these fixes. 🤖 Generated with Claude Code |
|
The glm.c merge wave just landed on |
…n no job covers engine-cuda-syntax compiles backend_cuda.cu with nvcc's GCC host on Linux, and check.yml's windows job is MinGW/UCRT64 CPU-only by design (JustVugg#140). Neither exercises nvcc's MSVC host — the only host compiler nvcc accepts on Windows — so `make cuda-dll` and `make glm CUDA_DLL=1` are currently built by nothing. The gap has already cost real bugs, all compile-time, all catchable without a GPU: - JustVugg#158: MSVC rejects the GCC-style -Xcompiler=-Wall,-Wextra ("D8021 invalid numeric argument '/Wextra'"), CUDA_HOME/NVCC defaults were unresolvable, and the kernel test used POSIX setenv. `make cuda-dll` was unbuildable as shipped. - JustVugg#314: CUDA_HOME containing spaces — the CUDA installer's default layout. This job installs to exactly that path, so it reproduces the condition by default. Two Windows-specific facts the job encodes, both verified by making it fail first: - sub-packages needs "cudart", not just "nvcc": cuda-dll *links* the runtime, and on Windows the headers/import lib are a separate installer component. With '["nvcc"]' alone it dies at `#include <cuda_runtime.h>` — the Linux syntax job never notices because it only compiles. - runs-on is pinned to windows-2022: windows-latest now ships Visual Studio 18 (MSVC 14.5x) and CUDA's crt/host_config.h hard-errors on any host newer than VS 2022. That is a real constraint on every Windows CUDA user today, so the pin tracks what the toolkit supports rather than papering over it with -allow-unsupported-compiler. Build-only on purpose: hosted runners have no NVIDIA device, so this proves the Windows+MSVC CUDA build stays buildable, not that the kernels or the DLL loader behave on real silicon — that still needs hardware (JustVugg#157). A check that overclaims buys the false confidence the engine-cuda-syntax comment already warns about. Verified green on a fork before proposing: https://github.com/lEWFkRAD/colibri/actions/runs/29524302993 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Summary
First hardware validation of the #131
CUDA_DLLpath (closes the build half of #157) — on RTX PRO 6000 Blackwell (sm_120), MSVC 14.44 + CUDA 13.2, MSYS2/UCRT64 host build. Result: the design works, butmake cuda-dllwas unbuildable as shipped by three Windows-specific issues, fixed here:NVCCFLAGSpassed GCC flags to MSVC. nvcc's host compiler on Windows iscl.exe, which hard-errors on-Xcompiler=-Wall,-Wextra(D8021 invalid numeric argument '/Wextra'). Windows now uses-Xcompiler=-W3— dash form deliberately: MSYS make mangles/W3into a filesystem path (C:/msys64/W3). POSIX branch byte-identical.NVCC/CUDA_HOMEdefaults couldn't resolve on Windows.CUDA_HOME=/usr/local/cudais meaningless there, and pointing at$(CUDA_PATH)/bin/nvccfails the recipe's unquotedcommand -vbecauseCUDA_PATHcontains spaces. Windows now defaultsCUDA_HOMEfrom the installer's system-wideCUDA_PATH(for-L) andNVCC=nvccfrom PATH — symmetric with the recipe's existing requirement that MSVC (cl) be on PATH via vcvars64.tests/test_backend_cuda.cuused POSIXsetenv/unsetenv— undefined under MSVC, so the kernel gate could never compile on Windows. Two-line_putenv_sshim.Also corrects the stale "11 API symbols" comment — the header exports 15 and
backend_loader.cresolves all 15.Validation
make cuda-dll CUDA_ARCH=sm_120(stock flags) → coli_cuda.dll buildsmake glm CUDA_DLL=1 ARCH=native→[CUDA] device 0: NVIDIA RTX PRO 6000 Blackwell Workstation Edition, 102.6 GB VRAM, sm_120; tiny oracle TF 32/32 + greedy 20/20 with the GPU tier initializedcuda backend: q8/q4/q2/f32 correctness ok on 1 device(s)COLI_CUDA=1→ clean "backend unavailable" message; noCOLI_CUDA→ pure-CPU run, no CUDA output, oracle-exactmake -C c checkstill green (changes are confined toIS_WINCUDA branches)Compatibility
🤖 Generated with Claude Code