Run frontier MoE models on hardware you already own — pure C, zero deps, experts streamed from disk. Tiny engine, immense model. 🐦
C
Merge pull request #576 from NeuralNotwerk/fix/serve-finish-reason-cap-hit
Vincenzo Fornaro047968ab8857
diff --cc c/colibri.cindex 71c2f1af,5856765c..356c6c71--- a/c/colibri.c+++ b/c/colibri.c@@@ -5611,21 -5594,17 +5611,28 @@@ static int mux_submit(Model *m, Tok *Tr->id=sub.id; r->maximum=sub.max_tokens; r->temp=sub.temperature; r->top_p=sub.top_p;r->prompt_tokens=nt; r->started=now_s(); r->hits0=m->hits; r->miss0=m->miss;prof_base(m,&r->pb); /* a few loads: cheap enough to always track */- int room=maxctx-sc->len-1; if(r->maximum>room){r->maximum=room; r->length_limited=1;}+ /* Clamp to the KV room WITHOUT flagging: length_limited must mean "the+ * limit is what stopped us", not "the request asked for more than the+ * context could ever hold" — clients that default max_tokens to the+ * context size would otherwise see finish_reason=length on every+ * naturally-completed generation. The flag is set at the actual+ * emitted>=maximum stops below instead. */+ int room=maxctx-sc->len-1; if(r->maximum>room) r->maximum=room;g_temp=r->temp; g_nuc=r->top_p;+ /* Single-slot speculation (#492/#358): with one KV slot there is no ragged+ * batch — the decode is a single contiguous sequence, exactly the regime+ * spec_decode already serves in chat/run/run_serve. Hand the request to the+ * scheduler's chunked spec path instead of the pending-token cycle; grammar+ * requests keep the forced-draft path (its acceptance is ~1 where it fires,+ * and the two draft sources would fight over the same forward). */+ if(g_draft>0 && nctx==1 && !grd[sub.slot].on){+ if(r->maximum<=0){ free(logit); mux_done(m,sc,r); return 1; }+ r->spec=1; r->spec_logit=logit; r->active=1;+ return 1;+ }int next=pick_tok(logit,m->c.vocab,-1); free(logit);- if(r->maximum<=0 || next==eos || is_stop(next)){ mux_done(m,sc,r); return 1; }+ if(r->maximum<=0){ r->length_limited=1; mux_done(m,sc,r); return 1; } /* no room at all */+ if(next==eos || is_stop(next)){ mux_done(m,sc,r); return 1; }r->pending=next; r->emitted=1; r->active=1; sc->hist[sc->len]=next; m->n_emit++;if(grd[sub.slot].on){ grammar_reset(&grd[sub.slot]); gr_feed(&grd[sub.slot],next); }mux_data(T,r->id,next);