Skip to content

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++

fix(moe): spell out the FMA chain of the float4 k=10 combine (#783 PR-c)

Niko12219d9c9ca2a43d
diff --git a/src/kernels/cuda/native_moe.cu b/src/kernels/cuda/native_moe.cu
index fb4818feb..456ab09c3 100644
--- a/src/kernels/cuda/native_moe.cu
+++ b/src/kernels/cuda/native_moe.cu
@@ -80,10 +80,13 @@ __global__ void combine_k10_vec4(const float4* __restrict__ parts4, const float*
for (int expert = 1; expert < 10; ++expert) {
const float w = __ldg(weights + expert);
const float4 p = parts4[int64_t(expert) * n4 + c4];
- sum.x += p.x * w;
- sum.y += p.y * w;
- sum.z += p.z * w;
- sum.w += p.w * w;
+ // the documented contract spelled out: the first product rounded, then one FMA per expert in order. Left to the
+ // compiler's contraction, a build may fuse a different product (gfx1151: the float4 kernel then differed from the
+ // scalar one, native_multi_parity)
+ sum.x = fmaf(p.x, w, sum.x);
+ sum.y = fmaf(p.y, w, sum.y);
+ sum.z = fmaf(p.z, w, sum.z);
+ sum.w = fmaf(p.w, w, sum.w);
}
const float4 sh = shared4[c4];
sum.x += sh.x;