fix(windows): load CUDA backend before device discovery - #1542
IcarusAegis wants to merge 3 commits into
Conversation
Integrazione dev + JustVugg#1542 (CUDA Windows) + OpenMP su Windows senza GPU + ISTRUZIONI.md
|
Reviewed together with #1579 and #1580, full comparison in #1577 (comment). Your diagnosis is the part the other two missed: What #1579 has over this branch is the test, 148 lines against 78, and a more careful update to the HIP threading note now that the caller count changed. I have asked there to adopt your behaviour. If that lands you will see your reasoning in the merged comment; if you would rather bring the test across here instead, say so and I will take this one. |
|
One thing to flag so my earlier comment is not read against a red tick: the CI on this branch shows a failure, but it is a run from two days ago whose job records no longer resolve, so there is nothing in it to read. I have re-run it rather than guess. If it comes back red on its own merits I will post what broke here. Nothing in the review changes either way. The point about |
Adapt DLL module-state probes and the HIP refusal control from ZhiyangK's PR JustVugg#1579. Preserve initialized-context semantics, verify missing-export diagnostics and explicit initialization, and distinguish a valid zero-device response. Clarify the three loader callers and their startup ordering.
76feab0 to
7f14d6b
Compare
Thanks @JustVugg for the detailed review. I’d like to continue with #1542 and bring in the tests and threading clarification from #1579, adapting the tests to preserve the distinction between visible devices and initialized contexts, and to verify the missing-export diagnostic while keeping explicit initialization supported. |
|
Building on @ZhiyangK’s tests in #1579, I added more tests coverage for:
Validation
|
Extend the discovery fixture with separate visible-device and initialized-context state. Cover CUDA/HIP discovery, explicit device forwarding, old DLL diagnostics, failure cleanup, runtime ownership, and repeated calls without changing the original direct-init tests. Exercise real qt_init and qt_init_fp8 selection paths with a stateful backend and add both suites to the mandatory Windows CI job. Adapt module-state and HIP control ideas from ZhiyangK's JustVugg#1579. Validation: 105 focused tests passed without skips; make check passed (Python: 913 passed, 100 skipped); seven regression mutations detected. On RTX 4070 Ti SUPER, nine CUDA test programs and sixteen real DLL/tier scenarios passed. Multi-GPU, AMD HIP hardware, and full-model inference remain unverified. Co-authored-by: ZhiyangK <ZhiyangK@users.noreply.github.com>
…'s one-line diagnostic The conflict resolution in 0c6cb27 kept the fork's JustVugg#1542 body (return 0 when the DLL lacks coli_cuda_available_device_count) over dev's fallback. That contradicts tests/test_backend_loader.py's test_the_probe_falls_back_for_a_dll_without_the_export, which arrived with the dev merge and fails on the Windows loader job. The fallback is upstream's contract, so it stays; what the fork keeps is the stderr line naming the stale DLL, printed once. Before init device_count() is 0, so tests/test_cuda_loader_discovery.py's expectations are unchanged. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Hi @JustVugg, could you clarify how you’d like me to proceed with #1542? |
I discovered this issue while building and testing Colibri's native Windows CUDA version (
CUDA_DLL=1) to run Qwen3.8-Next on the GPU. This build uses MinGW-w64 GCC for the host executable and NVCC with MSVC forcoli_cuda.dll, which the host loads at runtime. During testing of this native Windows build, automatic device selection fell back to CPU instead of using the available GPU.When neither
COLI_GPUSnorCOLI_GPUis set, the Qwen tier queriescoli_cuda_available_device_count()before callingcoli_cuda_init(). The Windows loader returns zero at that point because the backend DLL has not been loaded, so automatic device selection falls back to CPU even with a working CUDA backend.Load the backend on the discovery call. Keep discovery separate from
coli_cuda_device_count(), which counts initialized contexts. If an older DLL lacks the discovery export, report that it needs rebuilding or an explicitCOLI_GPUSselection; explicit initialization remains supported.This follows #1537 , which added the missing wrapper but left the pre-initialization loading issue. Related: #1533 .
Environment
Validation
de26d3c), the discovery and missing-export diagnostic tests fail as expected.qwen38.exewith MinGW GCC 16.1.0 and freshly rebuiltcoli_cuda.dllwith NVCC 12.6.20 / MSVC 19.44.35228; both build logs contain no warnings or errors.git diff --checkpasses.make -C c -j4 checkpassed withPYTHONUTF8=1: portable CPU build and C tests succeeded; Python reported 989 tests, OK with 100 environment-dependent skips. Without UTF-8 mode, the first run had nine GBK decoding errors. The test launcher used WindowsSetErrorModeto prevent intentional malformed-DLL fixtures from opening interactive error dialogs.make -C c cuda-test CUDA_ARCH=nativepassed on Windows. It also passed withNVCCFLAGS='-O3 -std=c++17 -ftz=false -arch=native -Xcompiler=-W3,-utf-8', which removes C4819 encoding warnings. The CUDA test log still contains warnings about an unusedunsetenvfunction and ignored OpenMP pragmas in the CPU reference build.