From 94705a1463cb8bcd4f33e3269c5ea0cc2387526b Mon Sep 17 00:00:00 2001 From: Niko1221 Date: Sat, 3 Oct 2026 01:57:12 +0200 Subject: [PATCH] decode_cluster_parity: wait for every upload before the graph replays and timings use it (#548, as #536) Dev::put uploads with a pageable cudaMemcpy, which can return before its DMA lands, and the graph replays and the timing cases run on a cudaStreamNonBlocking stream that does not wait for the legacy stream: the graph could read the previous replay's logits (one argmax token off; 5 of 6 replays on an RTX 5060 Ti, now and then on a 5090). Dev::put now synchronizes the device after its copy, which covers run_graph_case and bench(). Test only; no engine code. --- src/kernels/decode_cluster_parity.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/kernels/decode_cluster_parity.cpp b/src/kernels/decode_cluster_parity.cpp index 48032298..665fe6fa 100644 --- a/src/kernels/decode_cluster_parity.cpp +++ b/src/kernels/decode_cluster_parity.cpp @@ -58,6 +58,9 @@ template struct Dev { ~Dev() { cudaFree(p); } void put(const std::vector& h) { ck(cudaMemcpy(p, h.data(), h.size() * sizeof(T), cudaMemcpyHostToDevice), "up"); + // #548 #536: a pageable cudaMemcpy can return before its DMA lands, and the graph replays and the timing + // cases run on a cudaStreamNonBlocking stream that does not wait for the legacy stream - so wait here + ck(cudaDeviceSynchronize(), "up landed"); } std::vector get() const { std::vector h(n);