KV cartridges (GPU)
A KV cartridge is one of mnesio’s frontier bets (Phase 12): instead of re-reading a long memory context through the model on every query, you compile the relevant memories’ attention key/value state once into a cartridge, then reuse it. The cartridge is just another materialized view of the log — keyed and rebuildable by replay, like every other index.
How it’s keyed
Section titled “How it’s keyed”A cartridge is identified by a CartridgeKey of
(model_id, quant, rope_config, log_head). Because it’s pinned to a log_head,
it’s reconstructible by replaying the log up to that point — satisfying
Hard Rule #4 (every view is a function of the log).
The lifecycle
Section titled “The lifecycle”-
Compile.
compile()opens key-sealed memories, hands the surviving plaintext to aKvBackend, and produces a cartridge blob. -
Gate.
CartridgeStore::activateonly serves a cartridge that passesis_committable()— the same safety gate as everything else (Hard Rule #1). A cartridge that doesn’t hold accuracy is not activated. -
Version, never mutate. New cartridges supersede old ones; they’re never edited in place (Hard Rule #2).
-
Erase by recompile. Crypto-shred a subject’s key, recompile, and the rebuilt blob can’t reconstruct the erased content — reconciling KV memory with the right to be forgotten on an append-only log.
Measured speedups
Section titled “Measured speedups”These are real numbers from the candle/Metal GPU path, reported with their conditions. See Benchmarks for the full table.
| Configuration | Speedup | vs. baseline |
|---|---|---|
| GPU KV (general) | 107× | text-context retrieval |
| GPU bf16, 1.5B model | 1577× | CPU f32 |
| q8 quantized | 4× | f32 cartridge |
Selecting a model + precision at runtime
Section titled “Selecting a model + precision at runtime”The server exposes the active KV configuration (model + precision) at
GET /api/kv/metrics, with a dashboard panel for it. The backend is swappable
behind the KvBackend trait — fake, GPT-2 generative, or the candle/Metal GPU
path — without touching the cartridge substrate.
Next: the full numbers in Benchmarks.