[← Back (Home)](/) # pre-processed kv cartridges & sparse paging [](https://github.com/Eriskii/erisinky) November 27, 2026 research large language models kv cache Due to Inkling 2 Mini not possessing RoPE, it is possible to process prefill for your files ahead of time and simply place them into the model's KV cache 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 TTFT 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](#innovation-2), 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 decode on an M5 Pro. [How did we get here?](#how-did-we-get-here) [No RoPE](#this-only-works-with-inkling) [1. Pre-processed files (.ikv)](#innovation-1) [2. Cache optimizations](#innovation-2) [How they interact](#how-the-two-interact) [Coding benchmarks](#real-world-coding-benchmarks) [Document search](#document-search-benchmark) [1M–10M stress tests](#extreme-context-stress-tests) [Limitations](#what-didnt-work) [What's next](#generalization-and-whats-next) ## How did we get here? 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](https://arxiv.org/abs/2510.12872) (NeurIPS 2025, arXiv:2510.12872) and [TokenDance](https://arxiv.org/abs/2604.03143) (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 diffs — only recomputing the few tokens that drift too far — instead of duplicating the whole cache for every agent. KVCOMM reuse across shifted prefixes AP_Ashared S Blonger prefix Bshifted S- anchor pool (Δ)re-rotate RoPE + Δreused KV (no prefill) TokenDance one master copy + sparse diffs masteragent 1agent 2agent 3ptr → mastersparse diff (~2–10%) KVCOMM estimates KV offsets for shifted prefixes via RoPE re-rotation and an anchor pool; TokenDance stores one master copy plus sparse per-agent diffs fused on-the-fly. 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 windows 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 KL 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 kernel 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 WHT rotated quantization, Quest Top-K page retrieval, and NVMe 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. ## This only works with Inkling (Or: How I learned to stop worrying and hate RoPE) 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: A file mostly depends on itself. When a model reads 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. weak prefix linkprefill: strong intra-file dependencesystem / chatserver.rs · saved (K, V)L400question (Q)query time: Q reaches back into saved (K, V) - Inkling 2 Mini has no RoPE. Most transformers permanently bake each token's position (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 bias 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. standard RoPE position baked into keys compiled @ pos 0move to pos 50,000mounted @ pos 50,000angles mismatchstored vs expected Inkling (NoPE) position-free keys compiled @ pos 0move to pos 50,000mounted @ pos 50,000drop in verbatimbias = 0 past 1,024 - 40 of the 48 layers can't see past 1,024 tokens anyway. Once you're past the first 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. 40 / 48SWA (1,024)blind to prior files1,024 window8 / 48global NoPEsees prefix (low drift)full file attentionprior prefix / other filesfile start+1,024token t There was one real gotcha we had to fix: attention sinks. If you prefill a file completely on its own, token 0 of that file turns into a makeshift BOS 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 seam at read time (seam = 16) actually hurt KL (0.046 vs 0.032) compared to just pasting cleanly at seam = 0. naive standalone pack KL 0.029 - bogus mid-context sinksfile 1file 2file 3 offline BOS-strip KL 0.015 (free at read) 8-tok BOSstripclean .ikvBOS absorbs sinkdropped before saveBOSfile 1file 2file 3 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: CacheBlend has to re-rotate RoPE and recompute 15–20% of tokens at query time, EPIC still recomputes boundary tokens on the fly to fix sink shifts, and approaches like TurboRAG or Block-Attention have to fine-tune the model to tolerate standalone chunks. With a hybrid SWA + NoPE architecture, you get blind zero-recompute stitching with zero fine-tuning. ## Innovation 1: Pre-processed files (.ikv) 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](#innovation-2)). They are distinct things — you can use .ikv files completely on their own with a normal, uncompressed FP16 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](#reducing-memory-footprint) 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-conv state. Every section is 4 KiB-aligned for F_NOCACHE reads off SSD so mounting big archives doesn't quietly bloat macOS unified memory. Because .ikv cartridges are just static, content-hashed 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 TUI 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 Seatbelt 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: Whole files and EOF tails (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](#dense-vs-sparse) (4.2x on [sparse](#dense-vs-sparse) vs dense raw) with mean KL = 0.014 and 16/16 exact next-token matches. - Mid-file slices (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. .ikv on disk64-token global KV pages (0 .. EOF)EOF 1k SWA- cat / tailEOF slicestitch t_start .. EOFreuse tail0 prefill8.9x · KL 0.014sed / headmid-filestitch [A .. B-1k]prefill 1k1k tail only3–8x · KL 0.012 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. ## Innovation 2: Cache optimizations 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. ### Dense vs. sparse mode Throughout the rest of this report, "dense" and "sparse" refer to which live KV cache engine is running underneath the harness: Dense mode (the baseline): Stock 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. - Sparse mode (Innovation 2 turned on): Runs 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). ### Reducing memory footprint (compression and disk tiering) 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: - Rotated KV quantization (WHT-KV4 / WHT-K3V2): Before quantizing any Key or Value vector, we rotate it with a fast Walsh-Hadamard Transform (WHT-128 with Rademacher signs) so outlier channels spread smoothly into a near-Gaussian curve, then quantize with optimal Lloyd-Max levels (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 mean (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). global KV per token (8 layers)FP1632 KiB/tok (1.0x)WHT-KV48.25 KiB/tok · 3.88x (default)WHT-K3V25.25 KiB/tok · 6.10x (archive)- RAM (resident)2-bit sketches + top-K desk + 1k tail109–172 MiB @ 256k · 5.2 GiB @ 10MF_NOCACHE preadbypasses OS page cacheNVMe SSD (cold pages)compressed 64 / 128-token pagesnever balloons unified memory ### Cranking effective context length (sparse paging) 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 softmax 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 centroid. 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: The newest 1,024 tokens in full detail (plus pinned anchor pages at the start of context so system instructions and tool schemas are never evicted). - The Top-K most relevant far pages (Top-K = 128 at 64-token pages, or 64 at 128-token pages — keeping a steady budget of 8,192 sharp far-attention tokens). - One summary centroid per remaining cold page, weighted by + 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](#extreme-context-stress-tests)). query q- page index cardsWHT-2bit · 1.6 ms1. newest 1,024 + pinned anchorsfull local detail & system prompt2. top-K sharp far pages8,192 tokens (refreshed every token)3. cold page centroids1 summary / page · weighted + ln(P)~11,200 slotsvs 262,144 dense23.4x less work ## How the two interact (and the double-quantization bug) 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 dequantized 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 blur (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 argmax) 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](#real-world-coding-benchmarks)). old.ikv (K3V2)dequantFP16re-quant 2b Vpool (K3V2)slice KL 0.197multi-file attribution blurfixed.ikv (KV4)native 4-bit stitch (+14–34 ms)pool (KV4)slice KL 0.012 (16.3x lower)0 attribution blur · 6.0 / 6 rubric ## 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 LIFO edit-history stack, /diff, atomic /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. RunConfigurationWallTTFT Sum (Max)Decode (start → end)TurnsRubricM1Dense 128k + K3V2-.ikv + slice551.5 s27.6 s (3.5 s)31.8 tok/s (60.4 → 29.9)425.5 / 6M2Dense 128k control (--no-ikv)402.3 s39.7 s (23.9 s)39.4 tok/s (62.2 → 37.6)145.5 / 6M3Sparse 128k KV4-pool + K3V2-.ikv + slice366.4 s28.7 s (8.4 s)31.1 tok/s (45.6 → 30.9)225.0 / 6M4Sparse 128k KV4-pool control (--no-ikv)467.7 s112.2 s (53.4 s)31.2 tok/s (45.5 → 30.7)176.0 / 6M5Sparse 128k KV4-pool + K3V2-.ikv (--no-slice-ikv)747.7 s39.2 s (7.1 s)30.2 tok/s (45.3 → 29.7)395.5 / 6M6Sparse 128k old K3V2-pool + K3V2-.ikv + slice465.8 s45.4 s (8.6 s)32.0 tok/s (45.0 → 30.8)305.5 / 6M7Sparse 256k (P64·K128 KV4-pool) + K3V2-.ikv + slice489.5 s32.9 s (4.3 s)29.1 tok/s (38.8 → 28.8)295.5 / 6M8Sparse 128k KV4-pool + K3V2-.ikv + slice (--greedy)477.1 s58.0 s (8.8 s)29.0 tok/s (39.2 → 29.3)374.5 / 6M9Sparse 128k KV4-pool + KV4-.ikv + slice488.1 s24.9 s (4.0 s)29.2 tok/s (45.5 → 29.3)246.0 / 6 prefill vs. decode vs. rubric left = faster prefill · up = faster decode · size = rubric (4.5–6.0/6) pre-fix baselines 283236400s20s40s60s80s100s120s← total prefill + .ikv stitch latency (s)decode (tok/s) →M1M2M3M4M5M6M7M8M9sparse + .ikvsparse controldense + .ikvdense control timelapse race real turn-by-turn timing from matrix_v2 transcripts M3M9M4M2M1M7 play 1x10x20x50x 0:16.0 / 8:08.1 jump: 0:00 start0:16 ikv done reading1:35 sparse ctrl finishes tui.rs6:06 M3 finishes M3 Sparse 128k + K3V2-ikv decoding · 32.2 tok/s read shadow.rs — Let me look at shadow.rs briefly and Cargo.toml. TTFT 10.4s · 188 tok · T4/22M9 Sparse 128k + KV4-ikv decoding · 30.4 tok/s $ grep -n "pub fn" tools.rs shadow.rs worker.rs telemetry.rs — Now look at tools.rs briefly (parse_native_tool_call etc. TTFT 3.8s · 376 tok · T7/24M4 Sparse 128k control prefilling (25.4s) prefill read tools.rs TTFT 13.4s · 104 tok · T3/17M2 Dense 128k control prefilling (24.0s) prefill read tui.rs + read shadow.rs TTFT 12.7s · 188 tok · T4/14 .ikv stitch raw prefill wait decode (thinking / coding) shell / cargo test 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. - Dense vs. Sparse has a clean crossover point. Without .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). decode speed vs. context length measured matrix_v2 trajectories 2030405060tok/s0k64k128k192k256k~85–95k crossoverdense 128k ceilingM2 (37.6)M1 (29.9)M4 (31.2)M3M9 (29.3)M7 256k (28.8)dense FP16 · O(N)sparse Kv256kPool · O(N/P) - Hybrid 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). - 256k Sparse (M7) is genuinely usable, and --greedy (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). ## Multi-file document search (--notools) 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 --notools 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. timelapse race — document search real turn-by-turn timing from Ziz --notools transcripts (47 files, 243k tok) M3M9M4M2 play 1x10x20x50x 1:03.0 / 5:38.1 jump: 0:00 start0:34 M3 starts writing1:03 M9 done (20 files), controls frozen2:24 M3 finishes3:35 M9 finishes M3 Sparse 256k + K3V2-ikv decoding · 29.3 tok/s - writing final guide (1,695 words) TTFT 4.7s · 1,706 tok · T8/8M9 Sparse 256k + KV4-ikv decoding · 27.4 tok/s writing final guide (1,652 words) TTFT 7.4s · 1,658 tok · T10/10M4 Sparse 256k control prefilling (90.6s) prefill read 31_vampires-and-more-undeath.md + read 43_glossary.md TTFT 58.6s · 206 tok · T3/6M2 Dense 256k control prefilling (40.7s) prefill read 43_glossary.md TTFT 43.3s · 864 tok · T7/10 .ikv stitch raw prefill wait decode (thinking / writing) RunConfigurationFiles / Read.ikv StitchTTFT Sum (Max)Read WaitWallGradeM3Sparse 256k KV4-pool + K3V2-.ikv11 (298 KiB / 72.3k tok)1.19 s4.71 s (0.87 s)5.90 s143.7 sB- (78)M9Sparse 256k KV4-pool + KV4-.ikv20 (488 KiB / 118.1k tok)1.99 s7.36 s (1.08 s)9.35 s214.2 sA- (89)M4Sparse 256k KV4-pool control (--no-ikv)9 (264 KiB raw)—128.64 s (90.6 s)128.64 s278.7 sA (93)M2Dense 256k FP16 control (--no-ikv)19 (355 KiB raw)—84.96 s (40.7 s)84.96 s338.3 sA (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). - Real-world edge case caught along the way: An initial 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 guard in the harness fixed that cleanly. ## Extreme-context stress tests (25-task eval and 1M–10M needles) 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-haystack run on the M5 Pro. ### 25-task multi-hop codebase and RULER eval CategoryDirect (effort=0) FP16 / .ikv / SparseCoT (effort=0.1) FP16 / .ikv / SparseReal codebase — 5 files, 34.4k tok (15 tasks: single-hop, multi-hop, logic)15/15 · 14/15 · 14/1515/15 · 14/15 · 15/15RULER Multi-Needle + 4-Hop Var-Track — 3 synthetic logs, 14.7k tok (10 tasks)6/10 · 3/10 · 3/1010/10 · 2/10 · 10/10Overall (25 tasks)21/25 · 17/25 · 17/2525/25 · 16/25 · 25/25 (100%) Two really clear takeaways fell out of this split: - Sparse paging + CoT hit a perfect 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. - Blind .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 RULER 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. ### 1M and 10M token needle stress tests To test how far [sparse paging](#cranking-effective-context-length) 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): 10,486,528 tokens · 81,918 pages5.21 GiB RAM vs 320 GiB FP16 · 0.078% active · 5.0 tok/s- #1 / 81,918CRANE-74910% (9.44M back)#1 / 81,918RIVER-38250% (5.24M back)#1 / 81,918DENVER-4490% (1.05M back) 1,049,344 tokens (1M, 8,190 far pages, 0.78% active per token, 3.37 GiB RAM vs 32 GiB FP16): With background centroids off (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). - With full 1M background centroids on (cent = ON): 2/3 exact verbatim at 17.2 tok/s. - 10,486,528 tokens (10M, 81,918 far pages, 0.078% active per token, 5.21 GiB RAM vs 320 GiB FP16 = 61x smaller): Ran live on the M5 Pro at 5.0 tok/s (cent = ON) and 7.8–8.1 tok/s (cent = OFF). - The 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). - Why the TLDR says "~succeed": the model pulled 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. - Unexpected bonus finding on Inkling's attention temperature: Clamping Inkling's built-in 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. ## What didn't work and honest limitations A few real limitations and trade-offs worth being upfront about: - 2-bit Values in the live sparse pool (and coarse 128-token pages under 256k): 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. - Homogenous files under blind 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. - Disk footprint: Even compressed, .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. ## Generalization and what's next 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 iRoPE (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: - Harness polish: Flipping --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. - Multi-agent swarm support: Wiring TokenDance Master-Mirror sharing from 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. - Incremental edit-diff .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. - Cross-file Zero-RoPE KV deduplication and distillation: Because global KV vectors have no RoPE phase, identical boilerplate (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 distilled into tiny synthetic .ikv cartridges that mount right alongside normal repo files. [LLM-readable markdown version of this page](/research/inkling-ikv/llms.txt)