Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.
C++
#606: clamp the three unclamped q8_1 scale/sum emit sites via q8_1_ds
Matthew Hines7a0e30235c05
diff --git a/src/kernels/cuda/fused_gr.cu b/src/kernels/cuda/fused_gr.cuindex 210cf228c..23aeedd70 100644--- a/src/kernels/cuda/fused_gr.cu+++ b/src/kernels/cuda/fused_gr.cu@@ -1,5 +1,6 @@// src/kernels/cuda/fused_gr.cu - see include/strata/kernels/fused_gr.hpp.#include "strata/core/emulate.hpp"+#include "strata/kernels/q8_1_finite.hpp" // #606: q8_1_ds#include "strata/kernels/fused_gr.hpp"#include "strata/kernels/bf16_bits.hpp"#include "strata/kernels/verify_kernels.hpp"@@ -199,7 +200,7 @@ __device__ __forceinline__ void gr_q8_tail(const GrMulti& m, int d0) {const int8_t q = amax == 0.0f ? 0 : roundf(xi / d);GrQ81* y = reinterpret_cast<GrQ81*>(m.a[warp].q8_mixed) + c0 / 32;y->qs[lane] = q;- if (lane == 0) y->ds = make_half2(d, sum);+ if (lane == 0) y->ds = q8_1_ds(d, sum); // #606: clamped scale/sum - an unclamped pair NaN-poisons the dot path}// Step 1 of `gr_down_kernel`, one block per token, same threads and reduction order: rs[t] and xn[t] to global.__global__ void __launch_bounds__(THREADS) gr_norm_multi_kernel(GrMulti m) {diff --git a/src/kernels/cuda/iq_kernels.cu b/src/kernels/cuda/iq_kernels.cuindex 1c20986d5..05dac2ffa 100644--- a/src/kernels/cuda/iq_kernels.cu+++ b/src/kernels/cuda/iq_kernels.cu@@ -2327,7 +2327,7 @@ __global__ void s26_swiglu_q8_1_kernel(const float* __restrict__ gate, const floconst int8_t q = amax == 0.0f ? 0 : roundf(xi / d);const long long ib = i / 32, iqs = i % 32;y[ib].qs[iqs] = q;- if (iqs == 0) y[ib].ds = make_half2(d, sum);+ if (iqs == 0) y[ib].ds = q8_1_ds(d, sum); // #606: clamped scale/sum (the S26 path bypassed the finite helper)}template<bool LT, bool LX, int RG, int RD, bool SL = false, bool FQ = false, bool TS = false, int BD = 0>void s26_launch_l(const NativeExpertLayout& L, int64_t cap_groups, cudaStream_t s, const unsigned long long* grp_ptr,diff --git a/src/kernels/cuda/verify_kernels.cu b/src/kernels/cuda/verify_kernels.cuindex 122db9973..525c24b21 100644--- a/src/kernels/cuda/verify_kernels.cu+++ b/src/kernels/cuda/verify_kernels.cu@@ -4,6 +4,7 @@// elementwise.cu) with the same operation order, so a verify window reproduces plain decode bit for bit.#include "strata/kernels/verify_kernels.hpp"#include "strata/core/emulate.hpp"+#include "strata/kernels/q8_1_finite.hpp" // #606: q8_1_ds#include "strata/kernels/dp4a.hpp"#include "strata/kernels/pdl.hpp"@@ -199,7 +200,7 @@ __device__ __forceinline__ void gdn_q8_1_store(GdnQ81* __restrict__ xq, size_t iconst float d = amax / 127.0f;const int8_t q = amax == 0.0f ? 0 : roundf(xi / d);xq[idx / 32].qs[idx % 32] = q;- if (idx % 32 == 0) xq[idx / 32].ds = make_half2(d, sum);+ if (idx % 32 == 0) xq[idx / 32].ds = q8_1_ds(d, sum); // #606: clamped (the QFUSE path bypassed the finite helper)}template <bool ALL_OUT, bool Q>