From 38436f2a446959bdf2d9ab411a0db54f979eef25 Mon Sep 17 00:00:00 2001 From: Niko1221 Date: Mon, 12 Oct 2026 23:30:40 +0200 Subject: [PATCH] strata-q36: decode always on the per-token GDN kernels The greedy divergence seen with the fused single-token kernels is not a kernel bug: fused_gdn_conv_l2 and k_conv_seq leave the same history and differ by 1 ulp in h (FMA contraction of the 4-tap sum); the Q8_1 activation rounding turns that into a flipped near-tie (p01 token 4, margin 0.43). KL with either is the same. Drop the switch. --- src/qwen35/q36_engine.cu | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/qwen35/q36_engine.cu b/src/qwen35/q36_engine.cu index 3dd1ad64..522af2cf 100644 --- a/src/qwen35/q36_engine.cu +++ b/src/qwen35/q36_engine.cu @@ -1045,18 +1045,13 @@ struct Engine { k_gdn_gb<<>>(al_b, L.dt, L.ssm_a, be_b, HV, T); } // one token, a window or a chunk: the same kernels (every token in one launch each), so a decode step and a - // verify window compute bitwise the same rows (the MTP's greedy text is the plain greedy text, 10 of 10). - // STRATA_Q36_FUSED_GDN=1 keeps the fused single-token kernels for comparison: after a prompt chunk of more - // than 8 tokens they diverge from llama.cpp's greedy text (p01, token 4) -- not explained yet, same speed - if (std::getenv("STRATA_Q36_FUSED_GDN") != nullptr && T == 1 && !verify) { - K::fused_gdn_conv_l2(conv[li], qkv_b, L.conv, hc_b, C, 2 * HK, m->eps, st); - K::fused_gdn_step_norm_silu(S[li], hc_b, hc_b + HK * D, hc_b + 2 * HK * D, al_b, be_b, z, L.ssm_norm, - m->eps, gdn_y, HK, HV, st); - } else { - k_conv_seq<<>>(conv[li], qkv_b, L.conv, hc_b, C, 2 * HK, m->eps, T, !verify); - k_gdn_seq<<>>(S[li], hc_b, C, al_b, be_b, z, L.ssm_norm, m->eps, gdn_y, HK, HV, - T, !verify); - } + // verify window compute bitwise the same rows and the MTP's greedy text is the plain greedy text. (Strata's + // fused single-token kernels are not used here: fused_gdn_conv_l2's 4-tap sum contracts into FMAs + // differently from k_conv_seq's, a 1-ulp difference in h that the Q8_1 activation rounding can turn into a + // flipped near-tie later; with them the KL is the same, 1.05x / 0.81x the floor, but MTP would not be exact.) + k_conv_seq<<>>(conv[li], qkv_b, L.conv, hc_b, C, 2 * HK, m->eps, T, !verify); + k_gdn_seq<<>>(S[li], hc_b, C, al_b, be_b, z, L.ssm_norm, m->eps, gdn_y, HK, HV, T, + !verify); mm(L.ssm_out, gdn_y, y, T); } else { prep(h, N, T, xq);