fix(kvflash): tests that share a KvFlashPager with luce_common get its CUDA define

DU
2h ago
+6-0

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 when LUCE_BACKEND_CUDA, LUCE_BACKEND_HIP or GGML_USE_HIP is defined.
  • luce_common gets LUCE_BACKEND_CUDA=1 as a PRIVATE definition; the test target does not. So the test compiles a smaller pager than the one luce_common code reads.
  • The test constructs the pager (std::make_unique<KvFlashPager>(), attach). qwen4exp_kvflash_reserve, compiled in luce_common, then reads compute_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_cache
  • test_kvflash

The change is build config only.

Evidence (RTX 3090, sm_86, CUDA 12.0)

treetest_qwen4exp_prefix_cache
main 4af911b74segfault (rc 139) in kvflash() after the 385-row refusal
this PRrc 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.