From f9dae2a2d625120e4f478599d6d098c6eb773084 Mon Sep 17 00:00:00 2001 From: Valeriy Selitskiy <239034+iamwavecut@users.noreply.github.com> Date: Thu, 27 Aug 2026 17:32:40 +0200 Subject: [PATCH] cuda: zero the MMQ stream-k fixup staging buffer The fixup buffer comes from the pool uninitialized. Zero it before the stream-k pass so any fixup cell the merge visits without a producer contributes nothing instead of stale pool bytes. Hardening found while chasing (unrelated, as it turned out) batch-1 nondeterminism in the MiniMax Music 3 flow graph. --- external/ggml/src/ggml-cuda/mmq.cuh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/external/ggml/src/ggml-cuda/mmq.cuh b/external/ggml/src/ggml-cuda/mmq.cuh index 2cdab492d..35a141f3c 100644 --- a/external/ggml/src/ggml-cuda/mmq.cuh +++ b/external/ggml/src/ggml-cuda/mmq.cuh @@ -4008,6 +4008,10 @@ static void launch_mul_mat_q(ggml_backend_cuda_context & ctx, const mmq_args & a ggml_cuda_pool_alloc tmp_fixup(pool); if (fixup_needed) { tmp_fixup.alloc(block_nums_stream_k.x * mmq_x*mmq_y); + // Pool memory is recycled uninitialized; zero the partial-sum staging + // so any fixup cell the merge pass visits before/without a producer + // contributes exactly nothing instead of stale pool bytes. + CUDA_CHECK(cudaMemsetAsync(tmp_fixup.ptr, 0, block_nums_stream_k.x * mmq_x*mmq_y * sizeof(float), stream)); } const dim3 block_nums_fixup(block_nums_stream_k.x, mmq_y/warp_size, 1);