Every optimization at a glance
Each row is one family of optimization, ordered from the GPU silicon outward to host DRAM, NVMe, and multi-agent scheduling. The sections below give each one in full. The configurations differ: some numbers come from a 448k context held entirely on the GPU, some from a 524k–786k context with mixture-of-experts layers offloaded to the CPU, and some from a component measured alone. The last column says which.
| Family | Headline measurement | Configuration |
|---|---|---|
| Decode kernels and re-quantization | 4k decode at B=1: 92.58 t/s, against 56.5 t/s on stock llama.cpp | All-GPU, 4k context, one stream. |
| Long-context decode | B=1 decode at 124,742 of context: 64.00 t/s against 31.61 t/s with stock fattn-vec in the same patched build (patch 0005), output identical to that build with stock attention on the short-context parity set. At 416,582, the largest single-stream context that fits on the GPU: 43.87 t/s against 13.25 t/s. | Shipped GGUF, all-GPU, one stream, exact AttnRes mode. |
| All-GPU context | 448k at 90% full: 65.91 t/s summed over four streams, peak 22,687 MiB | 448k all-GPU, cold=0, re-quantized GGUF. |
| Offloaded context | 524k: prefill 1,100.02 tok/s and decode 36.4 tok/s with four Q8_0 layers on the CPU | 524k offloaded, shallow fill, one stream (Phase-3). |
| Live KV precision | Logit KL 4.49e-03 with the sliding-window cache in FP16, against 1.53e-02 with all Q4_0 | Running bit-exact engine, fixed prompt set. Measured alone. |
| KV compression | WHT-KV4 logit KL 0.001543 against 0.010482 for Q4_0, at 8.25 KiB/tok | Captured activations, one prompt. Measured alone (M10). |
| Session restore | 100k tokens from DRAM in 67.79 ms, against 701.63 ms from NVMe | 524k offloaded engine (M9), Q4_0 cartridges. |
| Pinned hot-swap | A whole 128k slot set back onto the GPU in 69.8 ms | One populated slot, hot-swap tool. Measured alone. |
| Warm pool and NVMe tiering | 3,121,472 tokens of pages at 8,194 MiB process memory | Synthetic pages, host only. Measured alone (M10). |
| Scheduler and tool-yield | A tool-calling session yields its GPU cells in 25.93 ms and swaps back from DRAM in 6.84 ms | Scheduler run (M12). Measured alone. |
| KV infill | 100,130 pre-encoded tokens injected from DRAM in 205.35 ms, against 350.9 s to prefill them | Infill run (M14). Measured alone. |
| Systems traps | Page eviction from 84,836.4 ms to 10.71 ms | Before-and-after pairs, one per trap. |
Model, hardware, and methods
Inkling 2 Mini has two structural features that shape every number in this report. First, it runs its core layers (layers 6 to 17) three times per token and mixes in earlier block outputs (AttnRes) at every step, so naive execution emits a long chain of small GPU kernels. Second, it keeps two kinds of attention cache: 8 global full-attention passes with no rotary position encoding (NoPE), whose cache grows with every token and dominates VRAM at long context, and 40 sliding-window passes of 1,024 tokens, whose cache is fixed in size. This paper measures how far one 24 GB RTX 3090 Ti can be pushed across four layers of the stack — faster GPU decode kernels and smaller weights, larger live context (all-GPU and offloaded), compressed warm-session parking in DRAM and NVMe, and multi-agent KV sharing — while keeping the desktop usable (VRAM under 22,500 MiB with at least 2,048 MiB free, and host pool memory under 12,288 MiB).
The model is Inkling 2 Mini, published by the thinkingmachines organization on Hugging Face (model card, licence Apache-2.0 as stated on that card). The GGUF file is Inkling-2-Mini-IQ4_NL from ggml-org/Inkling-2-Mini-GGUF, run on llama.cpp (MIT) with this repository's patches.
The table below lists every measurement family in this report, its input, and how many runs sit behind it.
| Result | Input | Evidence | Run |
|---|---|---|---|
| Decode kernels patched against stock | 4k context, B=1, B=4 and B=8 | Measured on GPU. Logit KL and greedy-token match over a fixed prompt set, against stock FP16. | Engine runs |
Long-context decode patch 0005 against stock fattn-vec in the same build | Saved cartridges filled to 65,760, 124,742, 241,396 and 416,582, plus four 32k slots, B=1, shipped GGUF | Measured on GPU. Logit KL against the 0004 build (stock fattn-vec): 0 with 160/160 tokens identical on the 10-prompt short-context set; parity at depth is described under the long-context table. | Long-context runs |
| Re-quantized GGUF | The four coda MoE layers and the output head re-quantized | Measured on GPU. The same prompt-set comparison. | Engine runs |
| All-GPU and offloaded context | Saved cartridges at 50% and 90% fill, the same cartridges for patched and stock | Measured on GPU. One serving hold per cell. | Context runs |
| Q8_0-first offload 524k and 786k | A baseline and three offload layouts; one short needle prompt, shallow fill | Measured on GPU. One run per layout. | Phase-3 |
| Codec fidelity WHT-KV4 against Q4_0 | Real model activations, 2,048 captured tokens of one prompt | Measured on GPU. One prompt, one next-token comparison per variant. | M10 |
| Session restore to GPU DRAM and NVMe | Real sessions of 32,417, 100,056 and 241,483 tokens, Q4_0 cartridges | Measured on GPU. One timing per size; 3/3 continuations exact. | M9 (the session-restore run) |
| Page store capacity 3,121,472 tokens | Synthetic content-hashed pages in WHT-KV4 size, not prefilled model cache | Measured on the host: memory, dedup and read-back. No GPU restore. | M10 |
| Page scan WHT-2bit sketches | Generated page sketches with a planted needle page | Measured on GPU. Three needle depths per size. | M10 |
| Hot-swap, scheduler, board and infill | Real populated slots and sessions | Measured on GPU. Each primitive in its own run. | Hot-swap tool, M11, M12, M4, M14 |
| Systems traps | Before-and-after pairs | Measured; one pair per trap. | Traps benchmark |
The engine results ran the patched llama.cpp build against the same version unpatched, on the same card and the same saved cartridges. "Bit-exact" mode is an opt-in switch that makes the AttnRes fusion reproduce stock output exactly (160/160 greedy tokens matched against stock FP16). "Fast" mode is the default, where that fusion takes a faster floating-point path; this report carries no separate fidelity figure for fast mode. A match against stock here means against stock output of the same configuration, not against stock FP16 KV unless the table says so. Every timing is a single run unless the table says otherwise.
Decode speed: fewer kernel launches per token
Because Inkling 2 Mini loops its core three times per token and mixes in earlier block outputs at every step, stock llama.cpp launched 7,319 kernels per token. On Windows the gap between kernel launches costs more than many of those kernels take to run, and stock 4k decode at B=1 was 56.5 t/s.
Three patches cut launches first to 3,265 (Arm 4) and then to 2,617 (Arm 5, -64.2%). The first keeps one captured CUDA graph per batch shape instead of recapturing whenever the batch size changes (patches/0001-cuda-graph-multi-shape-key.patch). The second adds opt-in switches that choose which matrix-vector kernel serves a given batch width (patches/0002-batch-kernel-parity-optin.patch). The third fuses runs of small operations into single kernels — norm and clip, AttnRes, and the short convolutions (patches/0003-inkling2-cuda-fusions-and-graph-opt.patch). The first fused AttnRes kernel spilled 56 B per thread to local memory; a narrower specialization spilled 0 B at 62 regs. Before that specialization, Arm 5 all-Q4_0 ran at 74.9 t/s in bit-exact mode (logit KL 0.0000 against stock Q4_0) and 85.0 t/s in fast mode. The convolution fusions are bit-exact, and with AttnRes on its bit-exact path the fused engine matched stock FP16 with logit KL 0.0000 and 160/160 greedy tokens.
| Configuration | Launches per token | B=1 | B=4 | B=8 | 4k prefill |
|---|---|---|---|---|---|
Stock llama.cpp, all Q4_0 | 7,319 | 56.5 t/s | 158.7 t/s | 237.7 t/s | 1,431 t/s |
| Patched, bit-exact, all Q4_0 | 2,617 | 79.5 t/s | 189.8 t/s | 275.9 t/s | 1,832 t/s |
| Patched, bit-exact, SWA FP16 | 2,617 | 83.5 t/s (+47.7%) | 196.4 t/s | 284.2 t/s | 1,832 t/s |
| Patched, fast, SWA FP16 | 2,617 | 91.2 t/s (+61.4%) | 203.4 t/s | 299.2 t/s | 1,832 t/s (+28.1%) |
| Patched, fast, SWA FP16, re-quantized GGUF | 2,617 | 92.58 t/s (+63.8%) | 210.5 t/s | 313.7 t/s | not measured at 4k |
With the whole cache in FP16, fast mode reached 93.4 t/s at B=1. In bit-exact mode the re-quantized GGUF ran at 86.80 t/s at B=1 and 298.4 t/s at B=8. Prefill at 4k went from 2.86 s to 2.24 s.
Re-quantizing the parts the GGUF left at Q8_0
The published Inkling-2-Mini-IQ4_NL file stores most mixture-of-experts layers in IQ4_NL but leaves the four coda layers and the output head in Q8_0. A coda layer in Q8_0 takes 1,032.8 MiB of VRAM, against 546.8 MiB for a layer in IQ4_NL. A streaming re-quantizer (src/hive_engine/gguf_stream_requant_multi.cpp, with the single-tensor version in src/hive_engine/gguf_stream_requant.cpp peaking at 115.7 MiB for the output head alone) rewrites only those tensors — the coda layers to IQ4_NL and the output head to Q6_K — reading the file in pieces: peak host memory 115.3 MiB, wall time 292.5 s.
| Quantity | Value |
|---|---|
| Model size, published | 16.42 GiB |
| Model size, re-quantized | 14.41 GiB |
| VRAM saved | 2.00 GiB |
| Logit KL, all re-quantized tensors | 4.76e-04 |
| Logit KL, coda layers only | 4.47e-04 |
| Logit KL, output head only | 9.21e-05 |
| Greedy tokens matched | 160/160 |
| Top-1 agreement | 10/10 |
The saving matters twice. On the GPU it is the room that lets 448k fit with no layers offloaded, below. On the CPU, when the coda layers are offloaded, smaller weights decode faster: with four coda layers on the CPU at B=4, IQ4_NL ran at 28.08 t/s per stream against 24.01 t/s for Q8_0, +17.0%.
Live context: 448k all-GPU, 524k–786k offloaded
Spending the 2.00 GiB reclaimed above alongside the mixed live-KV setting (sliding window FP16, global Q4_0) lets 448k live tokens fit 100% on the card. Past 24 GiB, mixture-of-experts layers move to the CPU (cold=N). Because all-GPU 448k, Phase-3 shallow 524k, and the filled four-stream offloaded envelope are distinct configurations, they are kept apart below.
All-GPU: 1x128k and 448k with nothing offloaded
Every number in the two tables below is from the all-GPU configuration: cold=0, meaning no mixture-of-experts layer runs on the CPU, with the re-quantized GGUF and the mixed KV setting. Decode speed at long context depends on how full the context is, not on how much was allocated. A 1x128k allocation holding a few hundred tokens decoded at 88.49 t/s, close to the 4k figure. So each point below was measured from a saved cartridge filled to the stated depth, and patched and stock loaded the same cartridge.
| Fill | Patched | Stock | Gain | Time to first token, patched / stock | Peak VRAM, patched |
|---|---|---|---|---|---|
| Shallow probe, published GGUF | 86.15 t/s | not measured | not computed | not measured | 20,406 MiB |
| Shallow probe, re-quantized GGUF | 88.49 t/s | not measured | not computed | not measured | 18,356 MiB |
| 50% full | 46.40 t/s | 38.25 t/s | +21.3% | 674.0 ms / 864.8 ms | 19,093 MiB |
| 96.7% full | 32.51 t/s | 27.82 t/s | +16.9% | 973.2 ms / 1049.6 ms | 19,262 MiB |
Long-context B=1 decode after the fattn-vec change (patch 0005)
At long context the decode step is dominated by attention over the cached keys and values. Patch 0005 changes the fattn-vec kernel in three ways. It loads each mask and relative-position tile once instead of repeating the load, it skips a tile that is entirely masked out, and it handles the three query heads that share one key-value head together (GQA-3) instead of one at a time. It applies to a head size of 128 with a group ratio divisible by 3. GQA-3 is on by default for a batch of one token (INKLING_FATTN_VEC_GQA3_MAX_B=1); larger batches are opt-in and are not reported here, because their logit parity has not been checked.
These runs differ from the two tables around them. They use the shipped IQ4_NL GGUF, not the re-quantized one, with the sliding window in FP16 and global attention in Q4_0 under the Rademacher-signed rotation above, in bit-exact mode (GGML_CUDA_INKLING_EXACT_ATTNRES=1), every cell all-GPU. The fills are saved cartridges of 65,760, 124,742, 241,396 and 416,582, so the first two are close to, but not the same points as, the 50% and 96.7% fills of the 1x128k table. Each result is one run of 48 measured CUDA-graph steps at B=1, and the gain column is the ratio of mean per-stream tokens per second. "Stock" here means stock fattn-vec in the same patched build (patches 0001 to 0004), not the unpatched llama.cpp of the other tables.
The 262,144-cell row is the nearest to 240k that the saved cartridges allow. The last row is the largest context one stream holds entirely on the GPU: a search in steps of 4,096 cells found 438,272 cells to fit with a guard of 256 MiB free, while the next size up left 228 MiB free and was rejected. It was filled to 416,582 and decoded with 290 MiB of VRAM free, so headroom there is thin. The four-stream 448k runs below hold more cells in total (458,752) because they use the re-quantized GGUF.
Parity. The reference is the 0004 build, which has stock fattn-vec. On the 10-prompt, 16-token set at short context, logit KL against it was 0 with 160/160 greedy tokens identical. That is a statement about the kernel change, not a claim that output matches stock FP16 KV: that comparison is the KL in the live-KV table below. At depth, a separate check loaded the saved cartridges and compared 16 greedy steps with the 0004 build. The mask hoist and warp skip with GQA-3 off had KL 0, 0, 0 and 0 at the four depths. With GQA-3 on, KL was 0 at 65,648, then 1.05e-03 at 124,630, 6.09e-04 at 241,284 and 2.05e-04 at 416,470, with every greedy token identical (16/16, 16/16, 16/16 and 16/16). So GQA-3 is not bit-exact at depth: it drifts slightly, which we attribute to the split of the attention work across blocks changing with the GQA-3 layout under FP16 partial sums. That is a hypothesis from the kernel structure and was not isolated. One cartridge was checked per depth, and the 4 x 32k row has only the short-context check.
| Context | Stock fattn-vec | Mask hoist and skip, GQA-3 off | Patch 0005, GQA-3 on | Gain over stock |
|---|---|---|---|---|
| 65,760 | 43.87 t/s | 65.48 t/s | 67.72 t/s | 1.54× |
| 124,742 | 31.61 t/s | 56.91 t/s | 64.00 t/s | 2.03× |
| 4 x 32k, 90% full | 31.22 t/s | 62.00 t/s | 64.62 t/s | 2.07× |
| 241,396 in 262,144 cells, 2,686 MiB free | 20.49 t/s | 45.09 t/s | 53.36 t/s | 2.60× |
| 416,582 in 438,272 cells, the largest all-GPU context for one stream, 290 MiB free | 13.25 t/s | 34.29 t/s | 43.87 t/s | 3.31× |
What this changes in the 1x128k table above: its patched speeds of 46.40 t/s at 50% fill and 32.51 t/s at 96.7% fill are the earlier build (patches 0001 to 0003) on the re-quantized GGUF, and the stock column there is unpatched llama.cpp. The new table is the faster measured configuration at comparable depth, on a different GGUF and KV setting, so the two are not subtracted from each other. On the shipped GGUF, stock fattn-vec reads 43.87 t/s at 65,760 and 31.61 t/s at 124,742 in this build, and the kernel change takes that to 67.72 t/s and 64.00 t/s. The gain over stock grows with depth, from 1.54× at 65,760 to 3.31× at 416,582, as expected when attention is the larger share of the step. The 4 x 32k row sits at a similar gain to the 1x124k row. The 448k four-stream tables below are B=4 runs of the earlier build and are not re-measured with this kernel.
The 2.00 GiB freed by re-quantization lets four streams of 112k fit with nothing offloaded: 458,752 cells in all, with 1.62 GiB of private host memory at 90% full.
| Fill | Arm | Per stream | Four streams summed | Time to first token | Peak VRAM |
|---|---|---|---|---|---|
| 50% full | Patched | 23.54 t/s (+17.6%) | 94.15 t/s | 1,245 ms | 22,683 MiB |
| 50% full | Stock | 20.02 t/s | 80.08 t/s | 1,404 ms | 22,646 MiB |
| 90% full | Patched | 16.48 t/s (+12.8%) | 65.91 t/s | 2,170 ms | 22,687 MiB |
| 90% full | Stock | 14.60 t/s | 58.41 t/s | 2,177 ms | 22,652 MiB |
One stream alone at 90% full decoded at 13.27 t/s.
Crossing 24 GiB: where the cold experts sit
When a context pushes past 24 GiB, which layers move to the CPU matters as much as how many. Because the core layers (6 to 17) run three times per token (see hive/arena.py), moving the once-per-token prelude and coda (layers 0 to 5 and 18 to 23) instead of layers 0 to 11 keeps the hot experts on the GPU. In the M9 run, decode rose from 24.879 tok/s to 29.865 tok/s (1.2004x), while the earlier E55 run measured prefill at 0.8525x of the old placement's speed. Those two runs differed in host-cache flags; a later controlled traps benchmark ran both placements with identical flags and no host cache, measuring decode from 27.27 tok/s to 32.06 tok/s (1.1757x) and prefill at 0.828x of the old placement's speed.
Q8_0-first placement at 524k: one stream, shallow fill
On the published GGUF, the four coda layers sit in Q8_0 at 1,032.8 MiB each against 546.8 MiB for an IQ4_NL layer, so moving only those four layers first frees the most VRAM per layer moved. The Phase-3 run compared that cold=4 placement with the earlier cold=12 layout at a 524k context. Each run read one short needle prompt and generated a short reply, so the context was nearly empty: these are shallow-fill numbers, from the published GGUF, one stream.
| Layout | Prefill | Decode | Peak VRAM |
|---|---|---|---|
Earlier layout, cold=12, batch 128 | 266.4 tok/s | 28.97 tok/s | 17,139 MiB |
Q8_0 coda only, cold=4, batch 512 | 1,100.02 tok/s (4.1292x) | 36.4 tok/s (1.2565x) | 21,805 MiB |
Full coda, cold=6, batch 512 | 1,004.18 tok/s | 35.3 tok/s | 20,713 MiB |
786k context, cold=12, batch 256 | 459.86 tok/s | 28.74 tok/s | 20,597 MiB |
The four-layer placement prefilled 4.1292x faster and decoded 1.2565x faster than the cold=12 layout, using 21,805 MiB of VRAM. The batch size changed too, so this compares two configurations, not one variable.
The four-stream envelope from 262k to 786k: filled cartridges
A second set of runs served four streams from cartridges filled to 50% and 90%, patched against stock on the same cartridges. Figures are per stream. These are the offloaded counterparts of the 448k all-GPU table above, and they use the published GGUF and an all-Q4_0 cache except where a row says otherwise.
| Context | Cold layers | 50% full, patched / stock | 90% full, patched / stock | Peak VRAM | Private host memory |
|---|---|---|---|---|---|
| 262k | 4 | 16.69 t/s / 13.82 t/s | 15.07 t/s / 13.94 t/s | 18,704 MiB | 5.43 GiB |
| 524k | 4 | 14.91 t/s / 14.32 t/s | 11.22 t/s / 10.80 t/s | 22,325 MiB | 5.71 GiB |
| 624k | 6 | 12.36 t/s / 11.89 t/s | 10.15 t/s / 9.31 t/s | 22,736 MiB | 6.79 GiB |
| 624k, re-quantized GGUF, SWA FP16 | 4 | 16.53 t/s (+33.7% vs cold=6) | 11.04 t/s | 22,959 MiB | 4.05 GiB |
| 786k | 10 | 10.58 t/s / 9.54 t/s (+11.0%) | 7.88 t/s (stock pair not used) | 22,786 MiB | 9.20 GiB |
The kernel gains shrink as layers move to the CPU: at cold=10 the CPU-side layers set the pace. Re-quantizing the GGUF let 624k run with four cold layers instead of six, +33.7% faster per stream at 50% full. Figure 3 above draws both the all-GPU and the offloaded tables.
Compressing the KV cache: live precision and WHT-KV4
Compressing the cache sits at two boundaries: what the running GPU engine attends over today (live KV precision), and what sits parked in host memory or on NVMe (offline WHT-KV4 and Tiered-SWA). Live attention currently uses Q4_0 for global passes; WHT-KV4 is measured on captured activations and in the host page store.
Live KV precision: what the running engine stores
In the running engine, the global passes grow with context while the sliding-window passes are fixed in size. A separate set of runs varied the precision of each part and compared the model's output with stock FP16. Keeping the global cache in Q4_0 and the fixed-size sliding-window cache in FP16 cut logit KL by 3.4× against an all-Q4_0 cache. That mixed setting is what the decode and all-GPU context results above use (upstream default rotation; the Rademacher-signed live WHT-128 variant is the last mixed row).
| Live KV configuration | Logit KL | Greedy tokens matched | KL vs all-Q4_0 |
|---|---|---|---|
| All Q4_0, upstream Hadamard rotation off | 1.70e-02 | 122/160 | not computed |
| All Q4_0, upstream default | 1.53e-02 | 126/160 | baseline |
| All Q4_0 with a live 128-point WHT rotation | 7.74e-03 | 141/160 | not computed |
| Sliding window FP16, global Q4_0 | 4.49e-03 | 150/160 | 3.4× lower |
| Sliding window FP16, global Q4_0, Rademacher-signed WHT-128 (patch 0004) | 2.35e-03 | 160/160 (10/10 sequences) | 6.5× lower |
| Sliding window Q8_0, global Q4_0 | 3.64e-03 | 149/160 | 4.2× lower |
| All Q8_0 (reference; costs more VRAM) | 2.81e-03 | 158/160 | not computed |
The sliding-window Q8_0 row had the lower KL of the two mixed settings and matched one token fewer. Upstream llama.cpp already rotates Q4_0 KV by default; turning that off raised KL to 1.70e-02. The live WHT rotation lowered KL against the default, but the mixed-precision setting lowered it further, and the live path does not use WHT-KV4's Lloyd-Max codebooks.
The last mixed row adds one change to the live rotation: fixed random signs. The unsigned Sylvester transform has an all-ones first row, so any non-zero mean across a vector's channels is concentrated 11.31× into coordinate 0. We attribute the gain to this: the spike would inflate the Q4_0 scale of the first block, and multiplying by a fixed pattern of ±1 signs on both sides (D·H·D, which is its own inverse) would spread it out. That mechanism is consistent with the measured drop but was not isolated: no block-0 scales or channel means were measured, and the measured result is the KL. The signs are compile-time constants applied in registers, so the change costs no VRAM and no memory bandwidth. It lowered KL from 4.49e-03 to 2.35e-03 (1.9×; 10 prompts, one run each), below the all-Q8_0 reference of 2.81e-03 at 158/160 tokens, with all 160/160 greedy tokens matching stock. It is off unless INKLING_LIVE_WHT_RADEMACHER=1 is set. It shares the prompt set and the one-run-each protocol of the rows above.
Offline storage: WHT-KV4 rotates first, then spends four bits
A 4-bit quantizer has sixteen levels. Attention vectors have a few dimensions far larger than the rest, so Q4_0 limits the damage by giving every block of 32 dimensions its own scale, at 72 B per 128-dimension vector. WHT-KV4, designed by Eris, removes the outliers instead: each vector is multiplied by a fixed pattern of random signs and passed through a 128-point Walsh-Hadamard transform, spreading any large dimension evenly over all 128 outputs. One scale then serves the whole vector, at 66 B (8.3% smaller than Q4_0). Across 8 global passes and 8 key-value heads, keys and values come to 8,448 B/tok, or 8.25 KiB/tok. The measured implementation uses trained Lloyd-Max codebooks and lives in src/ikv_wht/wht_kernels.cu with a Python reference in hive/ikv_wht.py.
| Variant | B / vector | KiB / token | Cosine | MSE | Logit KL | KL vs Q4_0 | Top-1 kept |
|---|---|---|---|---|---|---|---|
| Q4_0 | 72 B | 9.00 KiB/tok | 0.99784 | 0.003097 | 0.010482 | baseline | True |
| WHT-KV4 | 66 B | 8.25 KiB/tok | 0.99853 | 0.002087 | 0.001543 | 6.79x lower | True |
| WHT-KV4 + DC_mean | 66 B | 8.25 KiB/tok | 0.99864 | 0.001887 | 0.001878 | 5.58x lower | True |
| WHT-KV4 + Tiered-SWA | 66 B | 8.25 KiB/tok | 0.99853 | 0.002087 | 0.001982 | 5.29x lower | True |
| Combined | 66 B | 8.25 KiB/tok | 0.99864 | 0.001887 | 0.001865 | 5.62x lower | True |
Uncompressed FP16 would be 256 B per vector and 32.00 KiB/tok. DC_mean sink folding (also Eris's design) subtracts each channel's mean before coding and stores it once in the attention-sink entry; the fold was exact to 5.11e-15 and lowered vector error from 0.002087 to 0.001887 MSE, though on this one prompt plain WHT-KV4 had the lower logit KL (0.001543 against 0.001878).
The local-window tail: 26.25 MiB in place of 188.0 MiB
The 40 sliding-window passes each keep the last 1,024 tokens. That cache does not grow with context, but every parked session carries one. Tiered-SWA stores the nearest 256 tokens at 4 bits and the outer 768 at 2 bits, for 26.25 MiB per session against 160.0 MiB in FP16 and 188.0 MiB in padded Q4_0, a 7.16x reduction. With the tiered tail in the loop, logit KL was 0.001982, slightly above plain WHT-KV4 and still 5.29x below Q4_0.
Parking, hot-swapping, and the 3.12M-token warm pool
Once a session leaves the GPU, every restored byte crosses PCIe. Two transport paths serve different jobs: a small page-locked staging ring for many sessions parked in ordinary pageable DRAM, and direct page-locked hot-swap for a few slots kept ready to jump back onto the card. Beyond live Q4_0 restores, the two-tier WHT-KV4 page store holds millions of warm tokens across DRAM and NVMe under a tight host-memory cap.
Staged session restore from pageable DRAM and NVMe
On Windows a large page-locked host buffer is mapped into the GPU's address space and counts against VRAM, while handing CUDA ordinary pageable memory forces the driver to lock pages on every call. The M9 path separates storage from transport: parked sessions live in ordinary pageable DRAM capped at 6,144 MiB, and transfers stream through one small page-locked ring of 256 MiB split into 16 slots (src/kv_arena/kv_arena_cli.cpp).
| Session | Tokens | Cartridge | From DRAM | From NVMe |
|---|---|---|---|---|
| 32k | 32,417 | 334.0 MiB | 21.62 ms | not measured |
| 100k | 100,056 | 929.2 MiB | 67.79 ms | 701.63 ms |
| 241k | 241,483 | 2,173.8 MiB | 173.47 ms | not measured |
At 100k tokens the DRAM path was 10.35x faster than the NVMe cartridge. Saving the 32k session took 84.25 ms. After each restore the model continued generation, and the continuation matched the uninterrupted run in 3/3 cases. Cartridges drop the 8-token throwaway prefix that Eris's sink trick prepends. The M9 run peaked at 21,852 MiB of VRAM with 2,458 MiB free and 10,655 MiB of process memory, passing 16/16 verifier checks.
Pinned hot-swap of a whole slot
A second tool, src/hive_engine/state_swap_cli.cpp, moves a populated slot's whole state (KV and recurrent) with llama.cpp's own state get and set calls, verifying next-token parity after every swap. Raw page-locked transfers reached 26.85 GB/s host to device and 26.39 GB/s device to host, against 13.18 GB/s from pageable memory.
| Slot | State size | Get, pinned | Set, pinned | Set, pageable |
|---|---|---|---|---|
| 128k | 1.37 GB | 59.2 ms | 69.8 ms (19.65 GB/s) | 174.6 ms |
| 240k | 2.43 GB | 103.3 ms | 132.6 ms | 343.6 ms |
Because Windows counts large page-locked buffers against VRAM (measured in the traps section below), pinned hot-swap suits a few slots kept ready to resume, while M9's staged ring suits many sessions parked in ordinary DRAM.
The two-tier WHT-KV4 page store
To measure warm capacity at scale, the M10 verifier generated synthetic content-hashed pages of 64 tokens in WHT-KV4 size (8.25 KiB/tok) for 16 simulated multi-turn sessions and pushed them through hive/wht_pool.py. No model produced these pages; the test measures capacity, deduplication, host memory and read-back. At 8,448 B/tok, 3,121,472 unique tokens come to 25,148.6 MiB (24.56 GiB) — about twice the 12,288 MiB host cap. The store keeps a least-recently-used hot set in pageable DRAM (under a 6,656 MiB Tier-1 cap) and writes the bulk to NVMe in 256 MiB files opened without OS buffering so cold pages do not count against host memory a second time.
| Tier or budget | Tokens | Pages | Size |
|---|---|---|---|
| Tier 1, pageable DRAM | 762,496 | 11,914 | 6,143.2 MiB (5.999 GiB) |
| Tier 2, NVMe (75 unbuffered files of 256 MiB) | 2,358,976 | 36,859 | 19,005.4 MiB (18.56 GiB) |
| Total stored payload | 3,121,472 | 48,773 | 25,148.6 MiB |
| Host memory and system headroom | |||
| Process RSS outside Tier 1 (not broken down further) | – | – | 2,050.8 MiB |
| Peak process RSS (verifier cap 12,288 MiB) | – | – | 8,194 MiB (4,094 MiB headroom) |
| System RAM left free / GPU phase peak VRAM | – | – | 13,591 MiB / 21,829 MiB |
Identical pages shared between sessions were stored once (240 deduplication hits), and 201/201 sampled pages (100.0%) read back byte-identical, including a planted page evicted to NVMe. Host-side read-back (no GPU upload) took 1.13 ms for a 240k session in Tier 1, 292.42 ms for 100k from NVMe, and 752.69 ms for 240k from NVMe; note that M10's 292.42 ms is host-only page reassembly, whereas M9's 701.63 ms restores a real Q4_0 cartridge into GPU attention (an earlier failed E55 timing is recorded in Appendix A). The run passed 20/20 verifier checks. At 127,100 warm tokens per GiB (12.71M per 100 GiB of NVMe), larger capacities are straight-line payload arithmetic; see Appendix A for the full scaling table and where the line bends.
Finding the right pages: a 2-bit sketch scan
A parked context is cut into pages, and each page gets a 2-bit sketch in the rotated basis. To decide which far pages a step needs, the GPU scores every sketch against the current queries.
| Context | Pages | Tokens / page | Scan time | Pages selected | Needle rank |
|---|---|---|---|---|---|
| 256k tokens | 4,096 | 64 | 0.352 ms | 26 | #1 |
| 1M tokens | 8,192 | 128 | 1.353 ms | 18 | #1 |
The two rows use different page sizes, so they are not one curve. This measures the scan kernel and whether a planted page ranks first; it does not measure answer quality on a task with sparse paging switched on.
Multi-agent primitives on one card
Several agents on one card spend most of their time not decoding: waiting on a tool, or reading a document another agent already read. Four primitives in the engine address that. Each was measured alone, in its own run, and none of these runs combines them.
| Primitive | What it does | Measured | Peak VRAM |
|---|---|---|---|
| Tool-yield M12 | A session waiting on a tool call gives back its GPU cells, and comes back when the tool returns. | Yield in 25.93 ms; swap back in from DRAM in 6.84 ms, from NVMe in 63.57 ms | 17,291 MiB |
| Arena carve-up M11 | One KV arena split live between specialist sessions of different sizes, with sessions created and dropped repeatedly. | 516,096 of 524,288 cells in use; 60 cycles of churn | 19,191 MiB |
| Shared board M4 | Workers share one band of KV that all of them attend over, in place of each re-reading the others' posts as text. | 101.6 s against 171.0 s appending text (1.68×) and 881.2 s re-prefixing (8.67×); 48/48 solved; mean distribution 3.01 ms | 21,410 MiB |
| KV infill M14 | A document encoded once is injected into a live session's global cache, with no prefill. | 100,130 tokens from DRAM in 205.35 ms (1,708.7×) and from NVMe in 693.09 ms (506.3×), against 350.9 s directly timed cold prefill | 18,142 MiB |
Infill and the shared board rest on one property of the model: its global attention carries no rotary position encoding, so a block of global KV encoded in one place can be placed in another session's cache without re-encoding. Unlike the derived cold-prefill reference in Figure 2, M14 directly timed a real 100k cold prefill at 350.9 s. The speedups are against prefilling the same tokens in the same run, not against another system.
Systems traps and what failed first
Platform traps fixed
Several costs on this machine came from the platform rather than the model. Each row is a before-and-after pair from the traps benchmark, measured in the configuration its row names.
| Trap and fix | Before | After | Change |
|---|---|---|---|
| Page eviction scanned every page once per victim; sorted once per batch instead | 84,836.4 ms | 10.71 ms | 7,924× |
| Large page-locked host pools counted against VRAM on Windows; pageable DRAM behind a small page-locked ring instead (peak VRAM, two earlier runs compared) | 22,647 MiB | 21,852 MiB | 795 MiB less |
| Restore from pageable DRAM with no staging ring; with a page-locked staging ring (a prefilled 30,000-token session) | 27.94 ms | 21.72 ms | 1.29× |
| Infill scratch allocated on first use; pre-committed at start-up (first infill, M14, same cartridge) | 103.34 ms | 70.25 ms | not computed |
Attention-mask buffers sized for batch 512; batch 128 instead (peak VRAM, 524k offloaded, cold=12) | 17,390 MiB | 17,040 MiB | 350 MiB less |
| Layers 0 to 11 on the CPU; layers 0 to 5 and 18 to 23 instead (decode, 524k offloaded) | 27.27 t/s | 32.06 t/s | 5,220 MiB VRAM saved |
The placement row is the change described in the live-context section, with the VRAM it saved. The batch-size row and the Phase-3 runs point different ways on batch size: a smaller batch saved memory in the twelve-layer layout, and the Q8_0-first layout spent that memory on a larger batch for prefill speed.
Ideas that failed first
Several of these paths failed their verifiers before they passed. The failed result files remain in the repository.
- The first codec run (E56) was worse than Q4_0. On a 1,993-token prompt, WHT-KV4 logit KL was 0.14458 against 0.07852 for Q4_0, and both WHT-KV4 variants changed the top-1 token (DC_mean raised KL to 0.31466 despite lower MSE). Adding 1/√dk scaling and restricting DC_mean to the 8 global passes in M10 brought KL down to 0.001543; full E56 figures and provenance caveats are in Appendix A.
- The first DRAM cache (E55) broke the VRAM budget and parity. Putting the whole host cache in page-locked memory gave faster raw loads (16.84 ms at 32k, 48.24 ms at 100k) but peaked at 22,647 MiB of VRAM and failed continuation parity (0 matches). M9's staged ring is slower per restore and stays inside the envelope.
- Two passes through the looped core broke the output. Running the core twice per token instead of three times gave logit KL 0.525 and matched 57/160 greedy tokens. Four passes gave 0.236 and ran slower. The change was dropped.
- Suffix speculation slowed decode down. Drafting tokens from repeated suffixes was accepted 16.7% of the time, ran at 0.898× of normal speed and produced 28 mismatches (19 prompts). It was dropped.
Caveats and limits
- Live attention still stores Q4_0. WHT-KV4 is measured on captured activations and used as a storage format. The GPU attention path holds 9.00 KiB/tok today, and a fused WHT-KV4 attention kernel is not built.
- Each optimization was measured alone, not end to end. The kernel, re-quantization, context, codec, scan, restore, store, scheduler and trap results come from separate runs in separate configurations. Gains are not additive, and no run solves a task over a multi-million-token context.
- The 3.12M page store is synthetic, and larger sizes are arithmetic. The store held synthetic content-hashed pages (real sessions may deduplicate differently from 240 hits), and the scaling table divides a byte budget by 8,448 B/tok with nothing larger than 3,121,472 tokens built or timed.
- Two context configurations, kept apart. The 448k figures are all-GPU (
cold=0) with the re-quantized GGUF. The 524k–786k figures have layers on the CPU, and the Phase-3 ones are shallow fill with one stream, so they are not comparable with the filled four-stream envelope. - Fidelity checks are narrow, not task benchmarks. The WHT-KV4 codec table is one prompt (2,048 captured tokens, one next-token comparison per variant), and the engine, re-quantization and live-KV KL tables use a fixed prompt set against stock FP16 rather than downstream tasks. The kernel parity check against the 0004 build covers 10 prompts of 16 tokens at short context, plus one cartridge per depth at the long depths.
- Figure 2's cold re-prefill bar is derived, not timed. It divides token counts by 487.48 tok/s from a shorter run (≈ 66.5 s, ≈ 205 s and ≈ 495 s); only M14 directly timed a 100k cold prefill (350.9 s).
- One machine, one operating system. Every number is from a single RTX 3090 Ti on Windows, with single-run timings and no variance reported.
Replicate on your GPU
Everything is in github.com/godspede/construct-llama-hive. The fast checks need no GPU and no model weights.
- Run the CPU-only checks for both verifiers.
python bench/verify_m9_staged_dram_ikv.py --unit-only python bench/verify_m10_wht_3m_pool.py --unit-only - Point the repository at your model file and llama.cpp build, as its README describes, then build the two CUDA targets. The build scripts are Windows batch files.
src\kv_arena\build.cmd cuda src\ikv_wht\build.cmd cuda - For the decode-speed results, apply the five patches to llama.cpp in order and build it with the flags in
patches/README.md, which also names the base commit and every switch the patches add.
Patches 0004 and 0005 add switches. Setgit apply patches/0001-cuda-graph-multi-shape-key.patch git apply patches/0002-batch-kernel-parity-optin.patch git apply patches/0003-inkling2-cuda-fusions-and-graph-opt.patch git apply patches/0004-rademacher-live-wht128.patch git apply patches/0005-fattn-vec-gqa3-and-warp-skip.patchINKLING_LIVE_WHT_RADEMACHER=1for the Rademacher-signed rotation (default 0).INKLING_FATTN_VEC_GQA3defaults to 1, andINKLING_FATTN_VEC_GQA3_MAX_Bdefaults to 1, the only batch width whose logit parity was checked (bit-exact at short context, with a small drift at depth; see the long-context parity paragraph). The long-context rows also usedINKLING_KV_TYPE_SWA=f16,INKLING_LIVE_WHT_KV=globalandGGML_CUDA_INKLING_EXACT_ATTNRES=1. - For the re-quantized GGUF, build
src/hive_engine/gguf_stream_requant_multi.cppand pass it the published file, an output path and oneregex=typepair per tensor group.--dry-runlists the tensors it would rewrite. - Run the full verifiers on a 24 GB card. Each prints its checks and writes a
summary.json; expect 16/16 and 20/20.python bench/verify_m9_staged_dram_ikv.py python bench/verify_m10_wht_3m_pool.py - Compare your output with
results/m9_staged_dram_ikv/summary.json,results/m10_wht_3m_pool/summary.json,results/phase3_q8first/summary.json, and the systems-run JSON files underresults/. Every number on this page names the file and key it was read from.
The page store needs about 19,005.4 MiB of free NVMe space for Tier 2. Timings depend on your drive, your PCIe link and your driver's memory model.
Compared with Eris's Inkling-IKV
The codec ideas here are Eris's. They published WHT-KV4, DC_mean sink folding, the 8-token BOS strip and 2-bit page sketches for this model, with results on a 48 GB unified-memory Apple laptop: their report and their code. This work asks whether the same designs hold on a discrete 24 GB card, where the cache has to cross PCIe and host memory is a separate, smaller budget.
The implementation measured here is a reimplementation under Apache-2.0, written from Eris's published report rather than their code. Eris's code is GPL-3.0, and none of it was copied. The two machines have different memory layouts, so the table sets results side by side without ranking them. Eris's column quotes their report as published; this project has not re-run their experiments.
| Dimension | This work | Eris, as published |
|---|---|---|
| Hardware | One RTX 3090 Ti, 24 GB, over PCIe; host memory capped at 12,288 MiB; NVMe | Apple M5 Pro, 48 GB unified memory |
| WHT-KV4 size | 8.25 KiB/tok | 8.25 KiB/tok; also a 3-bit key, 2-bit value variant at 5.25 KiB/tok |
| WHT-KV4 fidelity | Logit KL 0.010482 with Q4_0, 0.001543 with WHT-KV4, one prompt | measured differently; not compared here |
| DC_mean sink fold | Fold exact to 5.11e-15; lower MSE, no KL gain on one prompt | Quantization KL 0.0319 down to 0.0181 |
| BOS strip | 8 tokens; 3/3 exact continuations | 8-token prefix stripped before saving |
| Page sketch scan | 0.352 ms at 256k, 1.353 ms at 1M, CUDA | about 1.6 ms at 256k, Metal |
| 3-bit / 2-bit codec | not implemented | 5.25 KiB/tok |
| Multi-file synthesis task | not run | 89/100 on 20 stitched files |
| 25-task suite with sparse paging | not run | 25/25 |
| 10M-token needle | not run | needle page ranked #1 of 81,918 at three depths |
| Two-tier page store | 3,121,472 tokens of synthetic pages, 8,194 MiB RSS | not in their report |
The task-level rows matter most and are the ones this project has not run. Eris has shown these codecs holding up on real long-context tasks. This paper shows the storage and transport pieces working on a discrete GPU.
Appendix: Storage scaling arithmetic & historical E55/E56 notes
Storage scaling arithmetic
A warm token costs a fixed 8,448 B/tok of WHT-KV4 for all global passes. A page is 64 tokens of those bytes, so a tier holds as many tokens as its payload budget divides into:
warm tokens = payload bytes / 8,448
= 127,100 tokens per GiB of payload (rounded down)
Both measured tiers obey it: Tier 1's 6,143.2 MiB and Tier 2's 19,005.4 MiB divide into 762,496 and 2,358,976 tokens. Doubling a tier doubles its tokens; the two tiers add. The table applies the formula to other sizes.
| Tier and budget | Warm tokens |
|---|---|
| Tier 1: DRAM payload budget | |
| 6 GiB | 762,600 |
| 12 GiB | 1,525,201 |
| 32 GiB | 4,067,203 |
| Tier 2: NVMe payload budget | |
| 100 GiB | 12,710,012 |
| 500 GiB | 63,550,060 |
| 1 TB (1012 bytes, not TiB) | 118,371,212 |
The 3,121,472 figure marks where this run stopped: its verifier required at least 3,120,000 tokens and the run reached 3,121,472. Where the straight line bends:
- Payload is not the whole cost. Process memory was 2,050.8 MiB above the Tier 1 payload; the result file does not break down how much of that grows with page count.
- Each parked session carries a fixed tail. The sliding-window tail is 26.25 MiB per session (420 MiB across 16 sessions), growing with session count rather than tokens.
- Read-back and scan were tested at fixed sizes. NVMe read-back was timed at 100k (292.42 ms) and 240k (752.69 ms), and the sketch scan at 8,192 pages of 128 tokens (1.353 ms) on generated sketches.
- Real capacity is below raw capacity. File-system overhead is not subtracted, and none of the table represents attended context (the largest real session restored to GPU is 241,483 tokens in Q4_0).
Historical failed runs: E55 and E56
Both earlier runs failed their verifiers and are retained for provenance. E56 used a 1,993-token prompt (different from M10's 2,748-token prompt), and both runs' code and result files entered the repository in one commit, so commit history cannot isolate the fix; the author's account is that E56 omitted 1/√dk scaling and applied DC_mean outside the 8 global passes.
| Run and metric | Value | Note |
|---|---|---|
| E55 peak VRAM | 22,647 MiB | Exceeded desktop VRAM budget due to large page-locked host cache. |
| E55 swap parity | 0 | Restored continuations failed exact-match check. |
| E55 32k / 100k DRAM restore | 16.84 ms / 48.24 ms | Faster raw loads from all-pinned host memory. |
| E55 100k NVMe restore | 582.18 ms | Earlier failed run; retained for provenance against M9 and M10. |
| E55 Prelude+Coda decode / prefill ratio | 1.2349x / 0.8525x | Measured with host cache enabled on the new placement only. |
| E56 Q4_0 logit KL / top-1 | 0.07852 / True | Baseline on 1,993-token prompt. |
| E56 WHT-KV4 logit KL / MSE / top-1 | 0.14458 / 0.000388 / False | Worse than Q4_0 before 1/√dk scaling fix. |
| E56 WHT-KV4 + DC_mean logit KL / MSE / top-1 | 0.31466 / 0.000361 / False | Lower MSE but higher KL before restricting fold to global passes. |
Exact byte sizes behind derived MiB totals
The MiB figures in the body are derived from these exact byte counts recorded in the M9 and M10 result files.
| Quantity | Exact bytes | Derived MiB |
|---|---|---|
| M9 pinned DMA staging ring | 268,435,456 B | 256 MiB |
| M9 32k / 100k / 241k cartridge payloads | 350,178,520 B / 974,351,212 B / 2,279,439,568 B | 334.0 MiB / 929.2 MiB / 2,173.8 MiB |
| M10 Tiered-SWA tail per slot | 27,525,120 B | 26.25 MiB |
| M10 FP16 / padded Q4_0 SWA tail per slot | 167,772,160 B / 197,132,288 B | 160.0 MiB / 188.0 MiB |
| M10 NVMe cartridge size | 268,435,456 B | 256 MiB |
| M10 Tiered-SWA tails across all 16 sessions | 440,401,920 B | 420 MiB |