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

probe: env-gated top-2 logit-gap dump at greedy selection (COLI_LOGIT_GAP)

monotophic32dc3f95e94c
diff --git a/c/sample.h b/c/sample.h
index c1187cf3..332e13e7 100644
--- a/c/sample.h
+++ b/c/sample.h
@@ -5,6 +5,7 @@
#include <math.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include "tok.h"
@@ -114,7 +115,22 @@ static int pick_tok(const float *lo, int V, int ban){
for (int k = 0; k < 5; k++) fprintf(stderr," %d:%.6f", id[k], v[k]);
fprintf(stderr,"\n");
}
- if (g_temp <= 0) return argmax_v(lo, V);
+ if (g_temp <= 0) {
+ int a = argmax_v(lo, V);
+ /* COLI_LOGIT_GAP=1: probe-only dump of the top-2 logits at each greedy
+ * pick, to tell a near-tie (float accumulation order) apart from a real
+ * divergence. Read-only: the token returned is unchanged. */
+ static int gap_dbg = -1; static int gap_pos = 0;
+ if (gap_dbg < 0) { const char *e = getenv("COLI_LOGIT_GAP"); gap_dbg = (e && *e && *e != '0'); }
+ if (gap_dbg) {
+ int b = -1; float bv = -INFINITY;
+ for (int i = 0; i < V; i++) { float x = lo[i]; if (i != a && x == x && x > bv) { bv = x; b = i; } }
+ double t1 = (double)lo[a], t2 = (b >= 0) ? (double)bv : 0.0;
+ fprintf(stderr, "LOGITGAP pos=%d top1=%d:%.6f top2=%d:%.6f gap=%.9f\n",
+ gap_pos++, a, t1, b, t2, (b >= 0) ? t1 - t2 : 0.0);
+ }
+ return a;
+ }
dist_build(lo, V);
return dist_sample(V, ban);
}