#594·colibri

[Feature]: Lossless entropy compression for streamed expert traffic (transport layer, any container)

Author: monotophicCreated Jul 24, 2026Updated Sep 27, 2026
Labelsfeature

Problem

For most Colibri deployments, decode speed is a disk problem. On boxes where the container is much larger than RAM (the common case: 300+ GB models on 64–128 GB machines), decode wall ≈ cold-expert bytes/token ÷ storage bandwidth + compute. We measured this decomposition explicitly on my M5 Max during the Metal campaign (#379/#387 arc): ~4 GB of cold expert reads per token against a ~14 GB/s device-level wall, with transport alternatives (prefetch, async I/O, MTLIO) each refuted by instrumented A/B — the bytes themselves are the lever left. Community datapoints (#103, #87, the GB10 threads) sit in the same regime.

The routed-expert bytes are the only bytes that matter here: resident tensors load once and price into RAM, not into the per-token stream.

Proposed solution

Proposal: compression that stops at the cache — a core setting, not a format

Add a lossless compression layer for SSD traffic, scoped to streamed (routed-expert) tensors, applied to ANY existing container:

  • A one-time coli compress preparation pass rewrites expert shards as per-expert entropy-coded blocks + index (reversible, no quantization decisions, no re-mint). Original semantics preserved exactly.
  • At runtime (opt-in, e.g. COLI_ZSTREAM=1), cold expert reads fetch the compressed block and decompress once at cache-fill. The expert cache and every kernel see ordinary bytes — no backend (Metal/CUDA/CPU/Vulkan) needs to know compression exists. Warm hits are untouched.
  • Lossless ⇒ identical output by construction. No quality question, no format-ladder claim, no per-backend kernel matrix.

The boundary ladder (why this phases cleanly)

"Where decompression happens" is a policy dial on one prepared artifact:

  1. Disk boundary (this FR): decompress at cache-fill. Highest value/risk ratio; helps every disk-bound user immediately.
  2. RAM boundary (future, same shards): a compressed warm cache tier below the decoded hot tier (the zswap pattern). Warm hits pay decompress but replace disk reads at ~10× the cost — strictly better than disk by construction — and effective cache capacity grows ~35%, compounding via hit rate. Pure engine policy; zero artifact churn.
  3. Kernel boundary: explicitly out of scope — it only pays when weights-bandwidth-bound, which streamed MoE decode on unified memory is not.

Evidence (measured, reproducible — prototypes are standalone, no engine changes)

Both prototypes ran against real GLM-5.2 int4 expert weights from my container, under pre-registered specs, 2026-07-21, macOS 26.5 / M5 Max:

  • Compression ratio: 26.2% size reduction (achieved ratio 0.7376, encoded/original) with a working static-table rANS encoder/decoder over a 340 MB, 54-tensor sample spread across the layer stack — not a Shannon-bound estimate. Per-expert chunking + one shared table cost ~0.06% of the ratio (measured): random access per expert survives compression intact.
  • Decode throughput: 24.3 GB/s warm-median on Metal (interleaved multi-stream rANS, single dispatch), 1.62× our registered 15 GB/s gate, every warm rep clearing it — comfortably above the ~14 GB/s storage wall it must outrun. Bit-exact across 31 full-container decode+verify passes (2.26B nibbles compared per pass, unsampled).
  • CUDA feasibility: our kernel is the same computational shape as nvCOMP's batched ANS decoder (production, faster hardware class); we have not run CUDA ourselves — flagged as expected-feasible, unverified by us. A tuned multi-thread CPU decode path for GPU-less hosts is the open milestone.

Projected prize (labeled projection, from the measured decomposition)

−26% cold bytes/token at unchanged hit rate → +20–30% decode speed on disk-bound configurations by the plateau arithmetic, before the phase-2 hit-rate compounding. We can price phase 2 on paper from our measured cache-size-vs-hit curves before anyone builds it.

Design decision points (for discussion before any PR)

  • Granularity: per-expert blocks + index (preserves today's access pattern).
  • Representation: sidecar compressed shards + discovery rules vs in-place rewrite (must respect the loader's directory-scan semantics).
  • Scope v1: routed experts only; kv_b/residents/MTP excluded.
  • Placement: cold-read path only; decompress-into-slab may replace (not add to) the existing buffered-read copy.
  • Default OFF, env-gated, with A/B on a single binary (house pattern).

Offer

The prototypes (encoder, Metal decoder, verification harness) are ready to share. I'm happy to validate on my Apple-Silicon hardware through the same measured-battery discipline as our previous PRs, and to build phase 1 as a PR series if the design direction is welcome. Nothing here conflicts with the currently open PR queue (#457/#386/#528/#529/#587) — this is design-stage.

(Coordinates for staleness: analysis measured 2026-07, engine base dev 5724dae-era, macOS 26.5, M5 Max 128 GB. The compression sample is 3 shards / 340 MB; a full-corpus census runs before any PR claims a final ratio.)

Alternatives considered

Entropy compression formats, messier and loses the boundary ladder.

Scope and compatibility

Up through the RAM boundary it is compatible with all platforms and containers. Kernel-boundary becomes platform-specific and will require individual formats for implementation.