fix(kvflash): tests that share a KvFlashPager with luce_common get its CUDA define
What
On CUDA builds, test_qwen4exp_prefix_cache segfaults on main in its KVFlash case. The crash comes right after the case's expected refusal, [qwen4exp][kvflash] a 385-row forward exceeds the 384 rows a 512-slot pool keeps resident:
#4 cuEventRecord () from libcuda.so.1
#6 cudaEventRecord () from libcudart.so.12
#7 luce::common::qwen4exp_kvflash_reserve(Qwen4ExpCache&, int, int)
#8 kvflash(ggml_backend*)
Cause: the two sides build KvFlashPager differently.
KvFlashPager(src/common/kvflash_pager.h) adds its async-DMA members only whenLUCE_BACKEND_CUDA,LUCE_BACKEND_HIPorGGML_USE_HIPis defined.luce_commongetsLUCE_BACKEND_CUDA=1as a PRIVATE definition; the test target does not. So the test compiles a smaller pager than the oneluce_commoncode reads.- The test constructs the pager (
std::make_unique<KvFlashPager>(),attach).qwen4exp_kvflash_reserve, compiled inluce_common, then readscompute_stream_past the end of the test's object, gets garbage, and records an event on it.
HIP builds are not affected: ggml propagates GGML_USE_HIP to every consumer, so both sides build the DMA layout.
Fix: on CUDA, give the define to the two test targets that construct a KvFlashPager and pass it to luce_common code:
test_qwen4exp_prefix_cachetest_kvflash
The change is build config only.
Evidence (RTX 3090, sm_86, CUDA 12.0)
| tree | test_qwen4exp_prefix_cache |
|---|---|
main 4af911b74 | segfault (rc 139) in kvflash() after the 385-row refusal |
| this PR | rc 0, all 9 sections PASS, including the KVFlash case |
Not run:
test_kvflash, which needs a qwen35 GGUF; it is built only.- HIP, where the change does nothing because it is CUDA-only.
Considered: making kvflash_pager.h also check GGML_USE_CUDA, which ggml already propagates, would fix every consumer at once. But it would also move the header-only pager tests onto the DMA path, so it belongs in a separate change.