Elffuss BraidHub

kikocis/coco public

2d5dfd774425 · 6.9 KiBSourceRawPermalink

coco — an architecture-agnostic LLM engine in Rust

coco

An architecture-agnostic LLM inference + quantization engine, in Rust. Built on candle + Metal.

License Rust GPU status

Website How it works Blog

⚠️ Experimental — work in progress. coco is an early-stage research engine under active development. It builds and the core pieces are validated against oracles, but its APIs, on-disk formats, and coverage are unstable and it is not production-ready. Expect rough edges, breaking changes, and gaps. Use it to learn from and hack on, not to ship.

One engine, not one-file-per-architecture. Every model reduces to a config row plus a single pluggable per-layer seam — so supporting a new architecture is an afternoon, not a rewrite.

Status: experimental, early but real. It builds clean and the headline pieces are validated against reference oracles. It is honest about what it can't do yet (see Limitations). A research engine to learn from — not a drop-in llama.cpp replacement.


What works today

Validated (reproducible)

Limitations (honest)

Quick start

cargo build --release
# run generation (point --model at a HF model dir with config.json, tokenizer.json, *.safetensors)
cargo run --release --bin coco -- --model ./model --prompt "The capital of France is"
# validate the GatedDeltaNet port against its oracle
cargo run --release --bin gdn_ref
cargo test --release

Layout

filewhat
src/config.rsarch registry + config parsing (ARCH_REGISTRY, resolve_arch, build_model dispatch)
src/model.rsDenseDecoder, DecoderLayer, the SequenceMixer trait + its 3 impls, MoeFfn
src/turboquant.rsthe data-free quantizer (rotation + codebook + radius)
src/qlinear.rsfused Metal kernels (quantized matvec, flash-decode, rmsnorm)
src/eval.rs / src/merge.rseval harness + evolutionary merge
tests/fixtures/golden oracles for validation

The story

The design decisions here are written up, for humans, on the Bitácora — with interactive demos. The coco series:

  1. Every new AI model breaks the tooling. I built an engine that shrugs it off. — the SequenceMixer seam
  2. How I ported a new kind of "attention" to Rust without missing a single decimal — oracle-first validation
  3. Shrinking an AI model 3× with no data and no quality loss — turboquant
  4. Why a 3 GB model runs faster than a 14 GB one (and when it stops) — the bandwidth thesis
  5. The GPU trick: multiplying straight from compressed data, without unpacking it — fused Metal kernels
  6. I optimized the GPU and it came out 20× slower. The lesson. — occupancy over traffic-saved
  7. When the honest thing is for your program to say "not yet" — the diagnostic bail

License

Apache-2.0. See LICENSE.