Due to Inkling 2 Mini not possessing RoPERotary Position Embeddings — bakes each token's absolute index into its saved Key vector via rotation, which normally breaks moving cached KV blocks to new positions., it is possible to process prefillThe initial forward pass where the model reads your prompt or files and fills its KV cache before generating the first output token. for your files
ahead of time and simply place them into the model's KV cacheThe saved Key and Value attention vectors for every token the model has already read, so it doesn't have to re-read them on every new output token. directly with no additional
processing required. This processing can be done in the background while your agent executes
things like compiles, or processed on other machines in a massively parallel fashion. By doing
this, file reads and TTFTTime to First Token — how long you wait after sending a prompt or tool output before the model starts streaming its reply. can be reduced significantly, sometimes upwards of a 50x speedup —
for both entire file reads as well as partial reads, such as sed. Additionally,
optionally combined with WHT-KV4 cache optimizations, this can greatly increase the context
length you can utilize by sharply reducing memory consumption, allowing Inkling to ~succeed at
a needle retrieval task up to 10 million tokens of context at five tokens per second decodeThe token-by-token generation phase after prefill — usually memory-bandwidth bound on Apple Silicon since every new token reads the weights and active KV cache. on
an M5 Pro.
This began with doing some work with Gemini Neon trying to optimize the size of Inkling 2 Mini's cache size — my laptop only has 48 gigabytes of memory, and Inkling's cache size meant that I could only just barely fit 128k or so tokens of context, and doing things like batch processing many agents would hit hard and low limits for each context's size. A paper search turned up two possible fixes: KVCOMM (NeurIPS 2025, arXiv:2510.12872) and TokenDance (Apr 2026, arXiv:2604.03143, PKU & SJTU). KVCOMM lets agents reuse each other's KV caches even when they have different prefixes before the shared text, by undoing/redoing RoPE and estimating the cache shift from an online pool of anchor examples instead of re-prefilling. TokenDance tackles the same overlap from the memory side, keeping one master copy of the shared KV blocks and storing each agent's differences as small sparse diffsOnly storing the ~2–10% of tokens whose KV vectors drifted past a threshold compared to the shared master copy, leaving the rest as pointers. — only recomputing the few tokens that drift too far — instead of duplicating the whole cache for every agent.
When we actually tested these ideas on Inkling 2 Mini — running 5 agents with different private prefixes (shifting a shared ~4k-token block by up to 588 tokens) — we got a surprise. Both papers spend a lot of effort compensating for RoPE position shifts, which Inkling doesn't have (and 40 of its 48 layers are 1,024-token sliding windowsSliding Window Attention — attention layers capped to only look back at the most recent 1,024 tokens, keeping their memory fixed regardless of context length. anyway). As a result, simply pasting the first agent's KV cache verbatim into the other four with 0% recompute, 0% diffs, and zero KVCOMM offset math already hit 95/96 exact next-token matches (mean KLKL divergence — measures how much the output token probability distribution drifts from exact uncompressed FP16. Under ~0.02 is nearly indistinguishable. 0.0081, and 24/24 with KL 0.0065 on the held-out agent with the 588-token shift). Adding TokenDance's sparse diffs pushed that to 96/96 at 2% diff and dropped KL further (0.0072 at 5% diff, 0.0049 at 10% diff), while shrinking 64-agent 256k memory by 15–28x and running the fused GPU attention kernelA single Metal shader that reads the shared master KV and overlays each agent's tiny sparse diff in registers without copying a full cache into RAM. 1.19–1.28x faster than independent caches thanks to cache sharing. Meanwhile, pure KVCOMM anchor offsets were actually slightly noisier than direct pasting (KL 0.0078 vs 0.0065) since there wasn't much RoPE drift left to fix, though pairing it with 5% TokenDance recompute brought KL down to 0.0061 at ~6x projected prefill speedup. In parallel, combining WHTWalsh-Hadamard Transform — a fast sign-flip and butterfly rotation that spreads spiky outlier channels evenly across dimensions so low-bit quantization barely loses accuracy. rotated quantization, QuestQuery-Aware Sparsity — summarizes blocks of KV cache into compact page bounds so decode only opens the top-K relevant pages. Top-K page retrieval, and NVMeYour Mac's internal flash SSD — ~6–8 GB/s sequential reads, fast enough to stream cold KV pages on demand when RAM fills up. cold storage shrank single-context 256k RAM from 8.16 GiB down to ~172 MiB, letting 64 independent 256k streams fit in 10.5 GiB (337 tok/s) and 128 streams fit in 11.9 GiB instead of ~1 TB. Seeing that direct KV paste worked with basically zero recompute or offset math is what sparked the next leap: if you can drop a cached KV block into a completely different position and context for free, you don't even need live multi-agent sync — you could just pre-process repository files into KV caches ahead of time and feed them straight into an agent when it reads them.
At first glance, pre-computing a file's KV cache by itself and pasting it into a totally different conversation sounds like it should break attention immediately. It works on Inkling 2 Mini because three things line up at once:
server.rs, almost everything it computes for line 400 comes from earlier lines
of server.rs, not from your system prompt or chat history. Later, when you ask
a question at the end of the prompt, the question's attention queries (Q) reach
straight back into those saved (K, V) vectors — the file never needed to know
what you were going to ask ahead of time. 0, 1, 2...) into every saved Key vector via rotary embeddings, so
sliding a pre-processed file from token 0 to token 50,000 corrupts
every key. Inkling doesn't use RoPE at all: its relative position biasAn additive score bias computed from the distance between two tokens during attention, rather than baking absolute positions into stored Key vectors. is added dynamically
at attention time only within 1,024 tokens, and is literally zero beyond 1,024. Its saved global KV blocks are position-free out of the box and can be
dropped in at any offset without re-rotating anything. 1,024 tokens of a file, 40 of Inkling's 48 layers are mathematically
blind to whatever prefix or other files came before it. Only the 8 global full-attention
layers (plus the tiny 3-token conv seam at the boundary) ever see across files — and as the
probe above showed, those 8 global layers barely drift when pasted behind a different
prefix. There was one real gotcha we had to fix: attention sinksEarly tokens that soak up large amounts of leftover softmax attention mass so the remaining heads stay numerically stable.. If you prefill a
file completely on its own, token 0 of that file turns into a makeshift BOSBeginning-of-Sequence token — the very first token of a prompt, which transformers use as a dumping ground for leftover attention weight. attention sink. Stitch five standalone files together into one session and you've just dropped
five bogus attention sinks into the middle of the context. The fix turned out to be dead
simple and completely free at query time: during offline preprocessing, we prepend a throwaway
8-token BOS prefix, run prefill, and strip those 8 tokens out before saving the .ikv file. That alone cut blind multi-file stitching KL in half (0.029 down to 0.015). Weirdly enough, trying to recompute a small boundary seamRecomputing a small strip of tokens right after a stitched file boundary to try to smooth out transition drift — surprisingly hurt KL here. at read
time (seam = 16) actually hurt KL (0.046 vs 0.032)
compared to just pasting cleanly at seam = 0.
That's also why this dodges the usual trade-offs in existing KV-stitching papers. Systems built for RoPE-everywhere, full-attention-everywhere models are stuck picking their poison: CacheBlendA EuroSys 2025 KV-stitching system for RoPE models that fixes cross-chunk drift by selectively recomputing 15–20% of tokens at query time. has to re-rotate RoPE and recompute 15–20% of tokens at query time, EPICA position-independent chunk caching system that recomputes a short LegoLink boundary window on each stitched chunk at query time. still recomputes boundary tokens on the fly to fix sink shifts, and approaches like TurboRAGFine-tunes a model with block-diagonal attention masks so retrieved document chunks can be pre-cached independently without cross-chunk drift. or Block-Attention have to fine-tune the model to tolerate standalone chunks. With a hybrid SWASliding Window Attention — local attention layers that only attend within a fixed trailing window of 1,024 tokens. + NoPENo Positional Encoding — global attention layers that store raw Keys with zero positional rotation, making them position-independent across arbitrary offsets. architecture, you get blind zero-recompute stitching with zero fine-tuning.
There are really two separate ideas in this project that happen to stack nicely together: pre-processing files into KV caches ahead of time (this section), and optimizing the live KV cache itself (Innovation 2). They are distinct things — you can use .ikv files completely on their own with a normal, uncompressed FP1616-bit half-precision floating point — the standard uncompressed KV cache format, costing 32 KiB per token across Inkling's 8 global layers. KV cache and
still get instant file reads.
The right mental model for a .ikv file isn't a text compressor — raw UTF-8 source
code is around 4 bytes per token, whereas even a compressed KV cache is a few kilobytes per
token. Think of .ikv like a compiled .o object file instead: you
spend a bit of disk space upfront to avoid paying the prefill tax every time an agent touches
the file.
Each IKV1 file stores the 8 global full-attention layers in 64-token pages (using
the same rotated quantization as our live cache so
files stay 3.88x–6.10x smaller than FP16 on disk), along with the file's final 1,024-token sliding-window tail and short-convA tiny 3-token causal depthwise convolution before attention — its entire state across all 48 layers fits in just 1.83 MiB in FP16. state. Every section is 4
KiB-aligned for F_NOCACHEA macOS fcntl flag that bypasses the OS unified file cache during disk reads, stopping macOS from quietly filling RAM back up with cold pages read off SSD. reads off SSD so mounting big archives doesn't quietly
bloat macOS unified memory. Because .ikv cartridges are just static, content-hashedKeyed by a fast hash of the file's exact bytes — if even one character changes on disk, the old .ikv is automatically bypassed until recompiled. binary blobs, you can compile a whole codebase ahead of time — or farm it out
across other machines in parallel — and drop the results into any session.
To make this invisible to an actual coding agent, we built a small TUITerminal User Interface — an interactive terminal coding-agent frontend running directly in your shell. harness
(inkling-ikv) that maintains a hidden .shadow-ikv/ cache alongside
the workspace. Whenever the GPU is idle — while you're reading output, typing a prompt, or
waiting on something like cargo test — a background worker quietly compiles any
new or modified files into .ikv and yields the moment the agent needs the GPU
again. When the agent calls read_file, the harness checks the file's content hash
and stitches the .ikv straight into the model's KV cache instead of raw-prefilling
the text (and if the file was just edited and hasn't recompiled yet, it safely falls back to
normal prefill). The harness also runs shell commands inside a macOS SeatbeltmacOS's kernel-level sandbox-exec confinement — locks shell commands to the working directory, denies network access, and blocks writes to .git and .shadow-ikv. sandbox by
default so the agent can't touch .git, .shadow-ikv, or the network.
One thing we noticed pretty quickly in real coding runs is that agents don't just read_file whole files — they constantly slice files with shell commands like sed -n '200,600p', head, tail, and cat.
Without handling those, every sed still fell back to slow raw prefill. The nice
trick is that you don't have to change the .ikv format at all to support slicing:
cat, tail, sed -n 'A,$p'): Since the slice ends at the end of the file, the .ikv's saved SWA tail and conv
state are already valid. We just slice the global KV pages from t_start..EOF and load the saved tail directly — zero prefill. In GPU KL verification on
a 33.5k-token source file, EOF tail ran 8.9x faster on dense (4.2x on sparse vs dense raw) with mean KL = 0.014 and 16/16 exact next-token matches.sed -n 'A,Bp', head, large ranged read_file): Here the slice stops in the middle of the file, so the saved EOF sliding-window/conv state
doesn't match line B. For any slice longer than 1,152 tokens, we
use a hybrid path: stitch the precomputed global KV for [t_start .. t_end - 1024] straight from .ikv, and raw-prefill only the last 1,024 tokens to rebuild exact SWA and conv states right at the cut point. On that same 33.5k-token file,
mid-file sed ran 3.04x faster on dense with mean KL = 0.020 and 16/16 exact next-token matches.The shell interceptor uses a strict allowlist (plain cat, sed -n, head, tail, and &&-chained combinations with
literal echo headers); anything with pipes, redirections, globs, or edits falls
straight through to the normal sandboxed shell.
Completely independent of .ikv files — you can run this with plain raw prefill
and no shadow cache at all — is the live KV cache work (Kv256kPool). It splits
into two distinct pieces: shrinking how much memory the cache takes, and cranking the effective context length the model can actually use without
choking on bandwidth or attention noise.
Throughout the rest of this report, "dense" and "sparse" refer to which live KV cache engine is running underneath the harness:
inkling-engine attention.
Every token's global KV cache sits uncompressed in RAM as FP16 (32 KiB/tok),
and every generated token attends over 100% of the context. At short contexts it's super
fast (~60 tok/s decode, fast raw prefill), but both memory and decode cost grow linearly
(O(N)) as context fills up.Kv256kPool —
rotated quantization + F_NOCACHE disk tiering + per-token Top-K sparse paging.
It pays a small upfront overhead at short contexts (starting around ~45 tok/s decode and
~2.2x slower raw prefill because of page quantization and sketch scoring), but its
sharp attention stays capped at a fixed budget while the page-sketch scan scales only as O(N / P) (where P is the page size, 64–128 tokens) — keeping decode nearly flat around ~29–31 tok/s through 256k and
memory tiny all the way out to millions of tokens (until the O(N / P) page scan
finally bends decode down to ~20 tok/s at 1M and 5 tok/s at 10M).In plain FP16, a single 256k context on Inkling 2 Mini takes 8.16 GiB of RAM
(8.00 GiB for the 8 global full-attention layers at 32 KiB/tok, plus 0.16 GiB for the 40 sliding-window layers). We crush that down in two layers:
WHT-KV4 / WHT-K3V2): Before quantizing any Key or Value vector, we rotate it with a fast Walsh-Hadamard Transform
(WHT-128 with Rademacher signsRandom +1 and -1 sign flips multiplied before the Hadamard rotation to decorrelate fixed channel spikes across heads.) so outlier channels spread smoothly into a
near-Gaussian curve, then quantize with optimal Lloyd-Max levelsNon-uniform quantization buckets optimized for a Gaussian bell curve — puts finer resolution near zero where most rotated values live, beating uniform rounding. (WHT-KV4 =
4-bit K & V at 8.25 KiB/tok, 3.88x smaller than FP16; WHT-K3V2 = 3-bit K / 2-bit V at 5.25 KiB/tok, 6.10x smaller). For Keys, we also subtract the per-head DC meanThe constant per-head average offset of Key vectors across a sequence; subtracting it before quantizing frees up bit range, and its dot product folds cleanly into the attention sink. (DC_mean) before
quantizing and fold -q · μ straight into the attention sink — cutting
quantization KL nearly in half (0.0319 down to 0.0181) for just 16 KiB of metadata. On the 40 sliding-window layers, we tier precision (newest
~256 tokens in WHT-KV4, outer ~768 tokens in WHT-K2V2) and store
the short-conv state in FP16 (3.66 MiB down to 1.83 MiB).F_NOCACHE disk tiering: For a single active coding session up
through 256k context, hot compressed pages stay right in RAM (~1.06 GiB full-KV payload at 128k or ~2.11 GiB at 256k in WHT-KV4, vs 4.0–8.0 GiB in FP16). Once you go past the hot-RAM cap — either running dozens
of concurrent 256k agents or pushing a single session out to 1M–10M tokens — cold pages
spill onto SSD through macOS F_NOCACHE file handles (bypassing the OS file
cache so macOS can't quietly pull cold pages back into unified memory). Only tiny page index
cards, the active working desk, and the recent 1k window stay resident in RAM: roughly 109–172 MiB per 256k stream, 3.37 GiB at 1M tokens (vs 32 GiB FP16), and 5.21 GiB at 10M tokens (vs 320 GiB FP16).Shrinking memory alone isn't enough to actually use 256k, 1M, or 10M tokens. Even if all those compressed pages fit, dense full attention still kills you twice: first, streaming gigabytes of KV cache on every single output token murders decode speed; second, dumping hundreds of thousands of irrelevant tokens into softmaxConverts raw attention dot products into probabilities that sum to 1 — adding hundreds of thousands of irrelevant tokens dilutes the needle's probability mass. attention drowns out the needle you actually care about.
Sparse paging attacks both at once. We divide the 8 global full-attention
layers into fixed pages (64 tokens per page up through 256k
context; 128 tokens per page above 256k) and maintain a lightweight "index card"
for every page: compact 2-bit rotated key sketches (WHT-2bit-sketch) plus a
compressed (k_mean, v_mean) background centroidThe mean Key and Value vector of an entire cold page — lets the model keep a rough summary of unopened pages in softmax without loading all 64 or 128 tokens.. On every single output token, the GPU scans those index cards across the entire context
(~1.6 ms at 256k) and computes sharp attention over only three things:
Top-K = 128 at 64-token
pages, or 64 at 128-token pages — keeping a steady budget of 8,192 sharp far-attention tokens).+ ln(page_size) so the softmax denominator stays balanced even for pages we
didn't open.At 256k context, each output token only attends over ~11,200 KV slots instead of 262,144 (23.4x less attention work), keeping decode
fast all the way to 1M (~20 tok/s) and 10M (5 tok/s) tokens. Just as
importantly, because the index scan runs fresh on every generated token, nothing is
permanently discarded — token 1 can pull pages from file A and token 2 can pull pages from
file B — while filtering out 97%–99.9% of far-context noise before softmax ever sees it (see Extreme-context stress tests).
You can mix and match these cleanly: run .ikv on top of plain dense FP16
attention, run sparse paging on top of normal raw prefill, or stack both together. When you
stack them, .ikv stores its 64-token pages using the exact same rotated
quantization and 2-bit page sketches that sparse paging uses, so mounting a pre-compiled file
takes zero format conversion and plugs directly into the sparse pool — giving you instant file
reads and fast, low-memory long-context decode at the same time.
Combining them did expose one nasty interaction bug early on. Originally, we ran WHT-K3V2 (3-bit K / 2-bit V) both in .ikv files on disk and in the live sparse RAM pool. Mounting a .ikv into the sparse pool dequantizedUnpacking compressed 2–4 bit integers back into 16-bit floats; re-quantizing an already 2-bit Value back to 2 bits compounds rounding noise. K3V2 → FP16 and re-quantized back to K3V2,
double-quantizing the 2-bit Values. In real multi-file coding runs, that showed up as 0.197 mid-file slice KL and subtle attribution blurWhen noisy low-bit Values cause the model to mix up which function or line number came from which mounted file. (the agent mixing up which
lines belonged to which file). Switching the live sparse pool default to WHT-KV4 slashed mid-file slice KL 16.3x (0.197 down to 0.012, 16/16 argmaxGreedy top-1 token match — 16/16 argmax means every single generated token matched exact uncompressed FP16 ground truth.) and cut almost 100
seconds off wall-clock time; using WHT-KV4 both on disk and in the pool
eliminated attribution blur completely for only +14–34 ms (+2–5%) of stitch
overhead (see Real-world coding benchmarks).
Microbenchmarks are easy to accidentally flatter, so we ran a controlled 9-run matrix
(matrix_v2) testing both innovations independently and stacked together on a real
multi-file Rust coding task: adding a 6-requirement LIFOLast-In, First-Out stack — each /undo pops the most recently recorded file edit in reverse order. edit-history stack, /diff, atomicWriting to a temp file and renaming into place so a crash mid-write can never leave a half-written source file. /undo with ShadowStore invalidation, /help docs, and CPU unit tests into inkling-ikv's own TUI harness
(effort = 0.1, macOS Seatbelt sandbox on, zero new crates). All 9 runs finished
cleanly with 0 test failures and 0 timeouts.
| Run | Configuration | Wall | TTFT Sum (Max) | Decode (start → end) | Turns | Rubric |
|---|---|---|---|---|---|---|
M1 | Dense 128k + K3V2-.ikv + slice | 551.5 s | 27.6 s (3.5 s) | 31.8 tok/s (60.4 → 29.9) | 42 | 5.5 / 6 |
M2 | Dense 128k control (--no-ikv) | 402.3 s | 39.7 s (23.9 s) | 39.4 tok/s (62.2 → 37.6) | 14 | 5.5 / 6 |
M3 | Sparse 128k KV4-pool + K3V2-.ikv + slice | 366.4 s | 28.7 s (8.4 s) | 31.1 tok/s (45.6 → 30.9) | 22 | 5.0 / 6 |
M4 | Sparse 128k KV4-pool control (--no-ikv) | 467.7 s | 112.2 s (53.4 s) | 31.2 tok/s (45.5 → 30.7) | 17 | 6.0 / 6 |
M5 | Sparse 128k KV4-pool + K3V2-.ikv (--no-slice-ikv) | 747.7 s | 39.2 s (7.1 s) | 30.2 tok/s (45.3 → 29.7) | 39 | 5.5 / 6 |
M6 | Sparse 128k old K3V2-pool + K3V2-.ikv + slice | 465.8 s | 45.4 s (8.6 s) | 32.0 tok/s (45.0 → 30.8) | 30 | 5.5 / 6 |
M7 | Sparse 256k (P64·K128 KV4-pool) + K3V2-.ikv + slice | 489.5 s | 32.9 s (4.3 s) | 29.1 tok/s (38.8 → 28.8) | 29 | 5.5 / 6 |
M8 | Sparse 128k KV4-pool + K3V2-.ikv + slice (--greedy) | 477.1 s | 58.0 s (8.8 s) | 29.0 tok/s (39.2 → 29.3) | 37 | 4.5 / 6 |
M9 | Sparse 128k KV4-pool + KV4-.ikv + slice | 488.1 s | 24.9 s (4.0 s) | 29.2 tok/s (45.5 → 29.3) | 24 | 6.0 / 6 |
Five things stood out immediately from the matrix:
.ikv gave a 54x file-ingestion speedup and let Sparse beat both controls on wall clock. On the exact same 3-file read (tools.rs + tui.rs + shadow.rs, 46.4k tokens), M3 and M9 ingested everything in 1.76 s (0.57 s stitch + 1.19 s TTFT) compared to 94.57 s of raw prefill in Sparse control M4 —
saving 92.8 s upfront. End-to-end, M3 finished in 366.4 s, beating Sparse control M4 by 101.3 s (-21.7%) and even beating Dense control M2 (402.3 s) by 35.9 s (-8.9%) (though M3 dropped a rubric point for using
non-atomic std::fs::write on /undo).WHT-KV4 end-to-end (M9) was the cleanest overall configuration. Every K3V2-on-disk run that mounted all four core files (M1, M5, M7, M8) showed explicit file-boundary confusion
in its thinking trace. Matching WHT-KV4 on disk with WHT-KV4 in
the live pool (M9) mounted 101.4k tokens across five files in 1.23 s with zero attribution blur, zero pre-edit raw re-reads, the lowest total TTFT of all 9 runs (24.9 s, 4.5x faster than M4),
and a clean 6.0/6 zero-warning patch. Its wall clock (488.1 s)
only trailed M4 slightly because the agent wrote a cleaner standalone history.rs plus extra tests (+2,438 generated tokens) and made one
duplicate tui.rs read..ikv and
under ~70k context, Dense (M2: 39.4 tok/s, 39.7 s TTFT) beats Sparse (M4: 31.2 tok/s, 112.2 s TTFT).
Once .ikv is on and context pushes past ~85k–100k tokens, .ikv wipes out Sparse's slower raw prefill (24.9–28.7 s vs Dense 27.6 s),
while Dense's linear O(N) decode collapses from 60.4 down to 29.9 tok/s (M1) — dipping below Sparse's much gentler O(N / P) curve (29.3–30.9 tok/s, and 28.8 tok/s even at 256k in M7). sed slicing paid off across 25 live slices (75.5k tokens in 1.21 s, 62.4k tok/s). EOF slices landed at 245–548 ms TTFT (38x faster than raw on a
7k-token slice), while mid-file slices paid a flat 1.4–2.4 s right-boundary
warm-up regardless of span size (4.4x–7.9x faster on 5k–9k token slices; in --no-slice-ikv M5, raw sed calls took 6.5–7.1 s each).M7) is genuinely usable, and --greedyZero-temperature sampling that always picks the single highest-probability token — surprisingly got stuck looping on overlapping slices here. (M8) hurt everything. Keeping 64-token pages (Top-K = 128) and KV4-pool at 256k cut wall
clock by 31.9% (~719 s pre-fix down to 489.5 s), cut
TTFT by 65.1% (94.2 s to 32.9 s), and raised quality
from 4.0/6 to 5.5/6 for only a 6.6% decode dip vs
128k (29.1 vs 31.1 tok/s). Meanwhile, --greedy (temp = 0) ran 110.7 s slower than M3, looped through
five overlapping tui.rs slices, and got the worst rubric score of the matrix
(4.5/6).Coding tasks spend most of their wall clock writing code and running tests, which partially
hides how big the read speedup actually is. To isolate pure multi-file browsing and
synthesis, we ran a read-only --notoolsRead-only harness mode that exposes only list_files and read_file — no grep, search_files, or shell — forcing the model to browse whole documents directly. benchmark on Ziz's blog writings (47 markdown files, 1.01 MB, 243.4k tokens total, including a 42.3k-token
glossary and a 49.0k-token essay): ask the model to map out all the undead types
discussed across Ziz's writings and Ziz's thoughts on each one, with a shared 262k context ceiling (effort = 0.1, temp = 1.0).
Pre-compiling all 47 files offline took 194.1 s (2.49 GiB) in K3V2 and 199.1 s (3.81 GiB) in KV4.
| Run | Configuration | Files / Read | .ikv Stitch | TTFT Sum (Max) | Read Wait | Wall | Grade |
|---|---|---|---|---|---|---|---|
M3 | Sparse 256k KV4-pool + K3V2-.ikv | 11 (298 KiB / 72.3k tok) | 1.19 s | 4.71 s (0.87 s) | 5.90 s | 143.7 s | B- (78) |
M9 | Sparse 256k KV4-pool + KV4-.ikv | 20 (488 KiB / 118.1k tok) | 1.99 s | 7.36 s (1.08 s) | 9.35 s | 214.2 s | A- (89) |
M4 | Sparse 256k KV4-pool control (--no-ikv) | 9 (264 KiB raw) | — | 128.64 s (90.6 s) | 128.64 s | 278.7 s | A (93) |
M2 | Dense 256k FP16 control (--no-ikv) | 19 (355 KiB raw) | — | 84.96 s (40.7 s) | 84.96 s | 338.3 s | A (94) |
13.8x–21.8x less read wait, and ~99x faster on giant files. In M9, stitching 20 full essays totaling 118.1k tokens took 1.99 s plus 7.36 s total TTFT across 10 turns
(9.35 s total wait — 12.6k tok/s effective ingestion, with a 1.08 s worst-case turn TTFT past 100k tokens). On the single 42.3k-token glossary, .ikv stitched in 410 ms vs 40.7 s of raw prefill in Dense M2 and a 90.6 s stall in Sparse control M4. Per byte read, M9 ingested 25.5x faster than M4 and 12.5x faster than M2, spending 96% of its wall clock actually writing instead of
waiting on prefill.KV4 on disk mattered visibly for fine-grained recall. Comparing against the ground-truth essays, M3 (K3V2 on disk)
covered the full 8-type taxonomy in 143.7 s but blurred concrete proper nouns
into smoother paraphrases and swapped Adrian Veidt (cited in 24_spectral-sight-and-good.md as durable good) into a Death Knight
(78/100). Switching on-disk cartridges to WHT-KV4 (M9)
eliminated entity-alignment swaps and restored verbatim names and quotes across all 20
stitched files (89/100, right behind the raw controls' 93–94/100,
with the main remaining blemish being a few swapped file citations in the final sources
appendix at 118k context).M9 run
went completionist and stitched 43 of the 47 files (238.7k tokens in 4.39 s), then tried to re-read two large essays past the 262k cap — exposing a harness footgun where an oversized .ikv silently fell back
to 64 KiB raw prefill (41.4 s) before overflowing. Adding a context-budget guardChecks remaining context headroom across queued tool calls before mounting .ikv files, returning a short budget error instead of silently falling back to slow raw prefill. in the harness fixed that cleanly.To push both innovations past normal coding-session lengths — and make sure sparse paging
wasn't silently dropping far-away facts — we ran two stress tests: a 25-task multi-hop eval
(every target fact buried 3.9k–34.3k tokens past the 1,024-token SWA window) and
a 1M / 10M token needle-in-a-haystackBurying a single unique random fact at a chosen depth inside massive distractor text to test whether the model can still pull it out verbatim. run on the M5 Pro.
| Category | Direct (effort=0) FP16 / .ikv / Sparse | CoT (effort=0.1) FP16 / .ikv / Sparse |
|---|---|---|
| Real codebase — 5 files, 34.4k tok (15 tasks: single-hop, multi-hop, logic) | 15/15 · 14/15 · 14/15 | 15/15 · 14/15 · 15/15 |
| RULER Multi-Needle + 4-Hop Var-Track — 3 synthetic logs, 14.7k tok (10 tasks) | 6/10 · 3/10 · 3/10 | 10/10 · 2/10 · 10/10 |
| Overall (25 tasks) | 21/25 · 17/25 · 17/25 | 25/25 · 16/25 · 25/25 (100%) |
Two really clear takeaways fell out of this split:
25/25 (100%) while pruning
87.8%–90.8% of far pages on every step. Because the 1.6 ms WHT-2bit-sketch scan runs fresh on every output token, each reasoning
hop in a 4-hop variable-tracking chain dynamically pulls the next page it needs..ikv (seam = 0, K3V2) hit 14/15 (93.3%) on the real 5-file codebase at 29.7x faster TTFT (41.1x prefill), and exposed its
exact edge case on the synthetic RULERA synthetic long-context stress benchmark testing multi-needle retrieval and multi-hop variable tracking across distractors. logs (2/10): when three nearly identical
synthetic log files are stitched blindly with no transition header or manifest, the model
explicitly reported that the other two log files weren't included. Real source files have
distinct symbols, imports, and structure so blind stitching handles them cleanly; homogenous
repeated logs need either a short manifest prefix or a 2–5% check-layer refresh.To test how far sparse paging can actually
stretch on a 48 GB laptop, we built a needle-10m stress harness using 32 unique real 4k source chunks (131k unique tokens)
tiled across physically distinct KvPageWht2 DRAM slots (208 MiB at 1M, 2.08 GiB at 10M), with exact position alignment and
a single unique needle planted once at 10%, 50%, and 90% depth (effort = 0, Top-K = 64 over 128-token pages):
1M, 8,190 far pages, 0.78% active per token, 3.37 GiB RAM vs 32 GiB FP16): cent = OFF): 3/3 (100%) exact verbatim recall at 10% (942k tokens back), 50% (523k back), and 90% (104k back) at 19.7–19.8 tok/s (needle page ranked #1, #1, and #17 out of 8,190).cent = ON): 2/3 exact verbatim at 17.2 tok/s.10M, 81,918 far pages, 0.078% active per token, 5.21 GiB RAM vs 320 GiB FP16 = 61x smaller): 5.0 tok/s (cent = ON)
and 7.8–8.1 tok/s (cent = OFF).WHT-2bit-sketch scanner ranked the single needle page #1 / 81,918 (top 0.0012% of 10M tokens) at all three depths (9.44M, 5.24M, and 1.05M tokens back).CRANE-749 (vs CRANE-7491), RIVER-382 (vs RIVER-3826), and DENVER-44 straight from
5M–9.4M tokens back, missing exact-match (0/3) by the final 1–2 digits.
Because the 10M haystack tiled 32 real chunks ~80x, 6–7 of the 8 KV heads got crowded
out by 80 identical-looking distractor copies inside the Top-64 budget.log(pos) attention temperature (tau) down to tau(256k) or tau(9k) actually degraded 10M retrieval
compared to leaving native uncapped tau(10.48M) active — Inkling's own
log-scaled temperature keeps helping even 40x past its normal context length.A few real limitations and trade-offs worth being upfront about:
WHT-K3V2 is still fine for cold archival compression (6.1x), but
running it in the live sparse pool caused double-quantization on .ikv mounts
(16.3x worse slice KL). Likewise, 128-token pages (Top-K = 64)
should stay strictly for >256k contexts — keeping 64-token pages
(Top-K = 128) through 256k was night-and-day sharper.seam = 0 stitching: As the RULER
log split showed, blind .ikv stitching works cleanly on real source files with
distinct symbols and structure, but pasting multiple nearly identical synthetic logs
back-to-back with no manifest or transition tokens blurs file identity..ikv is ~5.3–8.3 KiB/tok (626 MiB in WHT-KV4 for four large
Rust files totaling 55k tokens). That's totally fine as a local .shadow-ikv/ build cache on modern NVMe SSDs, just don't mistake it for a text
compressor.Despite the cheeky heading earlier, none of this actually depends on some weird one-off quirk
of Inkling 2 Mini. It only needs two architectural traits: majority sliding-window (or local) layers and Zero-RoPE (NoPE) on the global full-attention layers. That exact hybrid local
+ global-NoPE layout is showing up across modern frontier and open models too — Llama 4 (Scout / Maverick) uses 3:1 iRoPEInterleaved RoPE — Meta's Llama 4 pattern alternating chunked local RoPE layers with global NoPE layers. (chunked local RoPE +
global NoPE), Cohere Command A (111B) uses 3:1 SWA-RoPE + global
NoPE, and SmolLM3 (3B) uses 3:1 RoPE + global NoPE (making
SmolLM3 a great fast cross-model validation target, alongside RoPE-everywhere models like
Qwen3 or global-RoPE Gemma 3 as controls).
As for where this goes next:
--kv-bits 4 on as the default
(matching M9), deduplicating repeat read_file mounts of the same
file within a session, and landing the /diff + /undo stack into
the main harness.inkling-engine into the harness so multiple agents working on the same repo
share both .ikv files and live round context in a few GiB of RAM..ikv patching: Instead of recompiling a
whole file after a 5-line edit, reuse the pre-edit KV, re-prefill only the edited span plus
a 1,024-token SWA healing zone, and stitch the untouched tail back on.(K, V) slots across different
files can be merged into shared + ln(count) slots (cutting real KV token counts 3x–5x at link time), and huge static corpora like stdlib docs can be distilledTraining a tiny synthetic KV cache via gradient descent to compress hundreds of thousands of tokens of static docs into a few thousand virtual KV slots. into tiny synthetic .ikv cartridges that mount right alongside normal repo
files.