Run frontier MoE models on hardware you already own — pure C, zero deps, experts streamed from disk. Tiny engine, immense model. 🐦
C
omp: reset CPU affinity before the tuning re-exec (fixes #471)
veerareddyvishal1444dfe581af5e6
diff --git a/c/colibri.c b/c/colibri.cindex 4524c105..92d33417 100644--- a/c/colibri.c+++ b/c/colibri.c@@ -6016,6 +6016,18 @@ int main(int argc, char **argv){setenv("COLI_OMP_TUNED","1",1);#ifdef __linux__fprintf(stderr,"[OMP] hot-thread tuning: re-exec once (COLI_NO_OMP_TUNE=1 to skip)\n");+ /* #471: execv PRESERVES the CPU affinity mask. If the user exported+ * OMP_PROC_BIND/OMP_PLACES, libgomp's constructor already bound THIS thread to+ * place 0 (one core's SMT siblings) before main() ran; the re-exec'd image would+ * inherit that 1-core mask, enumerate OMP_PLACES=cores inside it, and jail the+ * whole team on one core (measured ~20x slowdown). Reset to all online CPUs so+ * the fresh libgomp binds from the full set — the user's OMP_* env still wins. */+ { cpu_set_t all; CPU_ZERO(&all);+ long ncpu = sysconf(_SC_NPROCESSORS_ONLN);+ if(ncpu > CPU_SETSIZE) ncpu = CPU_SETSIZE;+ for(long i = 0; i < ncpu; i++) CPU_SET((int)i, &all);+ if(sched_setaffinity(0, sizeof(all), &all) != 0)+ perror("[OMP] sched_setaffinity pre-reexec (continuing)"); }execv("/proc/self/exe", argv); /* returns only on failure -> fall through and run untuned */perror("[OMP] execv self-reexec failed, running untuned");#endifdiff --git a/docs/tuning.md b/docs/tuning.mdindex c95eca8d..ff1e7850 100644--- a/docs/tuning.md+++ b/docs/tuning.md@@ -40,6 +40,13 @@ Auto-tier plans size OpenMP from physical cores and bind workers across cores.Memory-bound quantized kernels can regress sharply when SMT siblings compete forlimited memory channels; explicit `OMP_*` settings always take precedence.+> Note (#471): exporting `OMP_PROC_BIND`/`OMP_PLACES` used to interact badly with+> the engine's one-time OpenMP tuning re-exec on Linux — the re-exec'd image+> inherited the first image's place-0 thread binding and the whole team landed on+> one core (~20× slowdown). The engine now resets its affinity to all online CPUs+> right before the re-exec, so explicit `OMP_*` pinning works as documented.+> `COLI_OMP_TUNED=1` remains the escape hatch that skips the re-exec entirely.+```bashcoli plan --model /models/glm52_i4 --policy qualitycoli run --auto-tier --policy quality "Explain MoE offloading"