Run frontier MoE models on hardware you already own — pure C, zero deps, experts streamed from disk. Tiny engine, immense model. 🐦
C
fix(quant): pin the grouped-int4 group accumulate as an fma
Konnerb6af434b1af2
diff --git a/c/colibri.c b/c/colibri.cindex d0e6f515..56ab1eab 100644--- a/c/colibri.c+++ b/c/colibri.c@@ -888,7 +888,9 @@ static void matmul_i4_grouped_pair(float *yg, float *yu, const float *x,accu=_mm256_fmadd_ps(_mm256_loadu_ps(xs+i), w0u, accu);accu=_mm256_fmadd_ps(_mm256_loadu_ps(xs+i+8), w1u, accu);}- ag+=hsum256(accg)*scg; au+=hsum256(accu)*scu;+ /* Same pinning as matmul_i4_grouped in quant.h: contraction+ * here is the compiler's choice, so the result was too. */+ ag=fmaf(hsum256(accg),scg,ag); au=fmaf(hsum256(accu),scu,au);#endiffor(; i+1<base+glen; i+=2){uint8_t bg=wg[i>>1], bu=wu2[i>>1];diff --git a/c/quant.h b/c/quant.hindex c0db9a65..16056b30 100644--- a/c/quant.h+++ b/c/quant.h@@ -188,7 +188,14 @@ static void matmul_i4_grouped(float *y, const float *x, const uint8_t *q4, const__m256 w1=_mm256_cvtepi32_ps(_mm256_sub_epi32(_mm256_cvtepu8_epi32(_mm_srli_si128(nib,8)),b8));acc=_mm256_fmadd_ps(_mm256_loadu_ps(xs+i), w0, acc);acc=_mm256_fmadd_ps(_mm256_loadu_ps(xs+i+8), w1, acc); }- a+=hsum256(acc)*sc;+ /* Pinned as an fma in the SOURCE. With the default+ * -ffp-contract=fast the compiler may fuse this multiply-add+ * (one rounding) or not (two), so the same source produced+ * different bits depending on the flag -- see the PR for a+ * reproduction. That made every bit-exactness gate, including+ * the glm_tiny token oracle, depend on build flags rather than+ * on the code. */+ a=fmaf(hsum256(acc),sc,a);#endiffor(; i<base+glen; i+=2){if(i+1<base+glen){ uint8_t byte=w[i>>1];