Files
ZacharyZcR f853ea8a0b refactor: split glm.c into colibri.c + 4 header modules
Rename glm.c → colibri.c and extract four self-contained modules
into header-only files (same pattern as st.h/tier.h/grammar.h):

  quant.h      (672 lines) — SIMD matmul kernels, quantization
  sample.h     (143 lines) — RNG, top-p sampling, stop-set
  kv_persist.h (121 lines) — .coli_kv disk persistence
  telemetry.h  (189 lines) — dashboard protocol, stats, usage

Main engine file shrinks from 6588 to 5396 lines (−18%).

Build system: primary target is now colibri$(EXE); `make glm`
remains as a phony alias for backward compat. CI, setup.sh,
coli CLI, and all 10 test files that include the engine are
updated. make check passes (C + Python, 73 tests, zero warnings).
2026-07-19 21:12:04 +08:00

24 lines
961 B
C

/* kv_alloc must survive re-allocation on the same KVState: every free path is
* guarded by if(k->Lc) precisely so callers (context resize, slot re-init) can
* call it again. A stale duplicate free block frees every Lc[i]/Rc[i] and both
* arrays twice on the second call -> allocator abort. No model file needed:
* the CPU path of kv_alloc only reads c->n_layers/kv_lora/qk_rope. */
#define main coli_glm_main_unused
#include "../colibri.c"
#undef main
int main(void){
static Model m;
m.c.n_layers=2; m.c.kv_lora=8; m.c.qk_rope=4;
m.kv=calloc(1,sizeof(KVState));
kv_alloc(&m,16);
for(int i=0;i<m.c.n_layers+1;i++){ m.Lc[i][0]=1.0f; m.Rc[i][0]=1.0f; }
kv_alloc(&m,32); /* the re-allocation path under test */
for(int i=0;i<m.c.n_layers+1;i++){
m.Lc[i][(int64_t)32*m.c.kv_lora-1]=2.0f;
m.Rc[i][(int64_t)32*m.c.qk_rope-1]=2.0f;
}
printf("OK kv_alloc re-allocation\n");
return 0;
}