Skip to content

Run frontier MoE models on hardware you already own — pure C, zero deps, experts streamed from disk. Tiny engine, immense model. 🐦

C

test(cuda): make the mxfp4 compare NaN-aware

monotophic84c6154b9fc0
diff --git a/c/tests/test_mxfp4_cuda.cu b/c/tests/test_mxfp4_cuda.cu
index 3dada8ad..764b35e7 100644
--- a/c/tests/test_mxfp4_cuda.cu
+++ b/c/tests/test_mxfp4_cuda.cu
@@ -83,6 +83,13 @@ static void one_case(const char *what, int S, int I, int O, int fixed_exp) {
int bad = 0;
for (int i = 0; i < S * O; i++) {
float a = y_cpu[i], b = y_gpu[i];
+ if (std::isnan(a) || std::isnan(b)) { /* NaN only agrees with NaN: without this,
+ NaN against anything falls through the
+ relative compare (NaN > tol is false)
+ and silently counts as a pass */
+ if (std::isnan(a) != std::isnan(b)) bad++;
+ continue;
+ }
if (isinf(a) || isinf(b)) { /* exponent 255: both must agree it is inf */
if (isinf(a) != isinf(b) || (isinf(a) && ((a > 0) != (b > 0)))) bad++;
continue;