tests: prefill_mmq_kquant_test waits for its uploads before the kernels

The inputs and the NaN sentinel go up with cudaMemcpy / cudaMemset on the legacy stream, and the kernels run on a
cudaStreamNonBlocking stream, which does not wait for it: a pageable copy or the memset can land after the kernels
started. On an RTX 4090 (sm_89, 128 SMs) that failed the screen ("unwritten or non-finite output") in 3 of 3 runs,
in a different product each time; with the sync before the kernels, 5 of 5 runs passed. The same fix as the fused
tests' (prefill_fused_moe_test.cpp, prefill_fused_iq_test.cpp).

(PR #532)
This commit is contained in:
eadra authored and Niko1221 committed 2026-10-06 15:57:38 +02:00
1 parent b9fdc1cdce
commit 638ab2dd5e
1 file changed
+3
+3
View File
@@ -95,6 +95,9 @@ void product(mmq::Context& ctx, cudaStream_t s, const char* name, ggml_type t, i
ck(cudaMemcpy(db.p, bounds.data(), bounds.size() * 4, cudaMemcpyHostToDevice), "bounds");
ck(cudaMemcpy(dw.p, w.data(), w.size(), cudaMemcpyHostToDevice), "w");
ck(cudaMemset(dy.p, 0xff, (size_t) rows * (size_t) out_rows * 4), "sentinel");
// the copies and the sentinel above run on the legacy stream, which a non-blocking stream does not wait for: a
// pageable cudaMemcpy/cudaMemset can still be in flight when the kernels start (a 128-SM 4090 caught it)
ck(cudaDeviceSynchronize(), "inputs");
mmq::quantize((const float*) dx.p, (const int32_t*) dsrc.p, dxq.p, (int) t, cols, cols, rows, s);
mmq::Product p;
p.w = dw.p; p.type = (int) t; p.w_rows = out_rows; p.w_cols = cols; p.expert_bytes = eb; p.n = n;