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++
q8_1 emit sites (#1448): clamp the scale and quantize against it, as the other producers do
Niko1221e372d4ffd994
diff --git a/src/kernels/cuda/fused_gr.cu b/src/kernels/cuda/fused_gr.cuindex 23aeedd70..19f89fb1c 100644--- a/src/kernels/cuda/fused_gr.cu+++ b/src/kernels/cuda/fused_gr.cu@@ -196,8 +196,8 @@ __device__ __forceinline__ void gr_q8_tail(const GrMulti& m, int d0) {for (int o = 16; o > 0; o >>= 1) amax = fmaxf(amax, __shfl_xor_sync(0xffffffffu, amax, o));#pragma unrollfor (int o = 16; o > 0; o >>= 1) sum += __shfl_xor_sync(0xffffffffu, sum, o);- const float d = amax / 127.0f;- const int8_t q = amax == 0.0f ? 0 : roundf(xi / d);+ const float d = q8_1_finite(amax / 127.0f); // #606: as native_quantize_q8_1_kernel - finite blocks bit for bit+ const int8_t q = q8_1_quant(xi, d, amax);GrQ81* y = reinterpret_cast<GrQ81*>(m.a[warp].q8_mixed) + c0 / 32;y->qs[lane] = q;if (lane == 0) y->ds = q8_1_ds(d, sum); // #606: clamped scale/sum - an unclamped pair NaN-poisons the dot pathdiff --git a/src/kernels/cuda/iq_kernels.cu b/src/kernels/cuda/iq_kernels.cuindex 05dac2ffa..c1ba087df 100644--- a/src/kernels/cuda/iq_kernels.cu+++ b/src/kernels/cuda/iq_kernels.cu@@ -2323,8 +2323,8 @@ __global__ void s26_swiglu_q8_1_kernel(const float* __restrict__ gate, const floamax = fmaxf(amax, __shfl_xor_sync(0xffffffffu, amax, o));sum += __shfl_xor_sync(0xffffffffu, sum, o);}- const float d = amax / 127.0f;- const int8_t q = amax == 0.0f ? 0 : roundf(xi / d);+ const float d = q8_1_finite(amax / 127.0f); // #606: as native_quantize_q8_1_kernel - finite blocks bit for bit+ const int8_t q = q8_1_quant(xi, d, amax);const long long ib = i / 32, iqs = i % 32;y[ib].qs[iqs] = q;if (iqs == 0) y[ib].ds = q8_1_ds(d, sum); // #606: clamped scale/sum (the S26 path bypassed the finite helper)diff --git a/src/kernels/cuda/verify_kernels.cu b/src/kernels/cuda/verify_kernels.cuindex 525c24b21..6642f0745 100644--- a/src/kernels/cuda/verify_kernels.cu+++ b/src/kernels/cuda/verify_kernels.cu@@ -197,8 +197,8 @@ __device__ __forceinline__ void gdn_q8_1_store(GdnQ81* __restrict__ xq, size_t ifor (int o = 16; o > 0; o >>= 1) amax = fmaxf(amax, __shfl_xor_sync(0xffffffffu, amax, o));#pragma unrollfor (int o = 16; o > 0; o >>= 1) sum += __shfl_xor_sync(0xffffffffu, sum, o);- const float d = amax / 127.0f;- const int8_t q = amax == 0.0f ? 0 : roundf(xi / d);+ const float d = q8_1_finite(amax / 127.0f); // #606: as native_quantize_q8_1_kernel - finite blocks bit for bit+ const int8_t q = q8_1_quant(xi, d, amax);xq[idx / 32].qs[idx % 32] = q;if (idx % 32 == 0) xq[idx / 32].ds = q8_1_ds(d, sum); // #606: clamped (the QFUSE path bypassed the finite helper)}