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

perf: balance causal attention prefill work

billdb5b46624b88
diff --git a/c/colibri.c b/c/colibri.c
index 9b4e4445..5faf3b48 100644
--- a/c/colibri.c
+++ b/c/colibri.c
@@ -2579,7 +2579,8 @@ static void attention_rows(Model *m, Layer *l, int layer, float *x, int S, int p
}
#endif
if(!cuda_core){
- #pragma omp parallel for collapse(2) schedule(static)
+ /* Causal rows grow with s; round-robin pairs keep that work balanced. */
+ #pragma omp parallel for collapse(2) schedule(static,1)
for(int s=0;s<S;s++) for(int h=0;h<H;h++){
KVState *ks=kvs?kvs[s]:m->kv;
int pos=positions?positions[s]:pos_base+s;
@@ -2662,7 +2663,8 @@ static void attention_rows(Model *m, Layer *l, int layer, float *x, int S, int p
int64_t sc_cap = Tk - stL;
float *sc_all = falloc((int64_t)omp_get_max_threads()*sc_cap);
double tac=now_s();
- #pragma omp parallel for collapse(2) schedule(static)
+ /* Causal rows grow with s; round-robin pairs keep that work balanced. */
+ #pragma omp parallel for collapse(2) schedule(static,1)
for(int s=0;s<S;s++) for(int h=0;h<H;h++){
int pos=pos_base+s;
const float *qp=Q+(int64_t)s*H*qh+(int64_t)h*qh; /* [qk_nope | qk_rope] */