Attention Routing Kernels (Ark): 90% Lower KV Cache & 3.8x Faster 64K Decode

Introduced in arXiv:2612.06276 (goombalab/ark), Attention Routing Kernels (Ark) routes each token per layer and KV group to either a packed exponential softmax KV cache or a fixed-size log-space linear recurrent state. At 2B parameters, Ark uses ~90% less memory than Transformers, 25–53% less than hybrids, and decodes 64K contexts 3.8x faster than FlashAttention-4.
Attention Routing Kernels (Ark): 90% Lower KV Cache & 3.8x Faster 64K Decode: Introduced in arXiv:2612.06276 (goombalab/ark), Attention Routing Kernels (Ark) routes each token per layer and KV group to either a packed exponential softmax KV cache or a fixed-size log-space linear recurrent state. At 2B parameters, Ark uses ~90% less memory than Transformers, 25–53% less than hybrids, and decodes 64K contexts 3.8x faster than FlashAttention-4. Designed as a zero-dependency, open-source TypeScript architecture under the MIT License with native Model Context Protocol (MCP) support and deterministic phase state machines.
- ~90% KV Memory Compression: A 2.275B Ark model uses just 25.3M total state/KV elements (1.8M state + 23.5M KV) versus 234.9M in a 2.091B RoPE Transformer—and 25–53% less than GLA/GDN hybrids.
- 3.8x Faster 64K Decoding: By shrinking decode memory bandwidth, the 2B Ark model decodes 64K sequences 3.8x faster than FlashAttention-4 and 1.8x faster than a GLA hybrid.
- Superior Length Generalization & QA: On 2B models trained at 2K context, Ark beats RoPE Transformers on 8K Variable Tracking (45.4 vs 11.0), 8K FWE (60.3 vs 3.2), and 8K BABILong (23.8 vs 7.1).
- Dual-Memory Readout Every Step: Every query reads both packed exponential attention over retained keys and a log-space chunkwise linear recurrence without per-layer interleaving compromises.
import { createAgent } from '@smoke-monkey/harness';// Long-horizon agent serving an Ark-routed 64K checkpoint with minimal KV footprintconst agent = createAgent({agentId: 'ark-long-context-analyst',provider: 'openai-compatible',baseUrl: 'http://127.0.0.1:8090/v1',model: 'goombalab/ark-2b-instruct',workspacePath: process.cwd(),permissions: {read_file: 'allow',write_file: 'allow',run_command: 'ask',},});async function main() {const result = await agent.run('Analyze the 48K-token service trace log in ./logs/prod-trace.json and pinpoint all cascading timeout root causes.');console.log('Ark Trace Analysis:', result.summary);}main().catch(console.error);
Watch: Related Video Guides
How KV Cache Speeds Up LLMs for Faster AI Models on GPUs
The KV Cache: Memory Usage in Transformers
How Do Attention Routing Kernels (Ark) Decide Which Tokens Keep a KV Cache?
Attention Routing Kernels (Ark) (arXiv:2612.06276) replaces static layer-level hybrid interleaving with a learned per-token router inside every layer and KV group. Each token goes to one of two memories: tokens requiring exact exponential similarity remain in a packed KV cache, while remaining tokens fold into a fixed-size log-space linear recurrent state—and every query reads both.
Training supervises the router via sampled query positions (|Q| cost O(|Q|T)) alongside a sparsity budget, avoiding router collapse (which occurs when |Q|=0). Across 200B-token ~2B parameter evaluations, Ark slashes KV memory by ~90% against standard Transformers while beating RoPE Transformers on long-context recall and tracking:
| ~2B Model (200B Tokens) | Total State+KV (M) | VT (2K / 8K) | FWE (2K / 8K) | BABILong (2K / 8K) | Open-Book QA Avg |
|---|---|---|---|---|---|
| Transformer w/ RoPE | 234.9M | 79.0 / 11.0 | 58.3 / 3.2 | 29.2 / 7.1 | 40.4 |
| Hybrid GLA 1:4 | 45.7M (3.8+41.9) | 19.5 / 4.6 | 46.9 / 41.0 | 25.8 / 3.7 | 36.3 |
| Hybrid GDN 1:4 | 45.7M (3.8+41.9) | 47.3 / 17.1 | 32.1 / 19.3 | 34.8 / 19.1 | 40.6 |
| Hybrid GDN 1:6 | 37.5M (3.9+33.6) | 18.6 / 24.8 | 51.3 / 44.7 | 34.4 / 18.0 | 40.9 |
| Ark (Learned Routing) | 25.3M (1.8+23.5) | 59.2 / 45.4 | 59.3 / 60.3 | 35.7 / 23.8 | 39.5 |
Cloning goombalab/ark and Inspecting Packed Prefill & Log-Space Recurrence
The official implementation in goombalab/ark ships both the Packed Causal Attention Triton/CUDA kernels (which skip evicted tokens in the exponential branch) and Log-Space Chunkwise Recurrence (combining intra-chunk parallel attention, inter-chunk state scan, and query readout without storing token metadata). Clone the repo and run a 64K decode latency check to measure memory-bandwidth gains directly:
# 1. Clone the official Attention Routing Kernels repository
git clone https://github.com/goombalab/ark.git
cd ark
# 2. Install CUDA/Triton runtime dependencies
pip install -e .
# 3. Run unit tests & 64K throughput benchmark comparing Ark vs FlashAttention-4 / GLA
pytest tests/
python benchmarks/decode_throughput.py --seq-len 65536 --model-size 2bKey Empirical Insight: Answer Tokens Belong in the KV Cache
Section 7 of the Ark paper proves that retrieval accuracy hinges on routing answer tokens and high-salience entities to the exponential KV cache while safely compressing filler syntax into the recurrent state—explaining why learned token-level routing outperforms post-hoc training-free KV eviction.
Why Token-Routed KV Memory Transforms Multi-Turn Agent Contexts
Autonomous coding and research agents generate massive multi-turn contexts dominated by boilerplate compiler logs, JSON wrappers, and file listings, punctuated by a few critical stack frames, API signatures, and assertions. Static Transformers waste 90% of HBM bandwidth re-reading every boilerplate token on every decode step.
Combining Ark's token-level KV routing with Smoke Monkey Harness keeps long-horizon agent traces inside single-GPU VRAM at 64K+ context lengths without resorting to destructive context truncation.
Frequently Asked Questions
Q:How much memory does Ark save compared to Transformers and hybrid models?
Across 400M–2B models, Ark stores roughly 90% less state+KV memory than full softmax Transformers (25.3M vs 234.9M elements at 2B) and 25–53% less than 1:4 or 1:6 GLA/GDN layer-interleaved hybrids.
Q:How fast is Ark at 64K context decoding?
At a 64K sequence length, the 2B Ark model achieves 1.8x faster decoding than a GLA hybrid and 3.8x faster decoding than FlashAttention-4 due to drastically smaller KV-cache memory reads per token.
Q:What happens if you train Ark without sampled-query supervision?
Ablations in Section 6 show that with |Q| = 0 (relying solely on the budget loss), the router collapses. Sampled-query supervision keeps routing aligned with actual retrieval demand at O(|Q|T) overhead.
Q:Where is the Ark source code hosted?
The authors released the code and kernels openly on GitHub at https://github.com/goombalab/ark.
Related Alternatives & Comparisons
Related Architecture Guides
View all guidesBest Open Source Coding Agents in 2026: Free, Local & Fully Hackable Harnesses
MCP Server Security Best Practices: Hardening Model Context Protocol Agents in 2026
Open Source Coding Agent Harness: Build a Forkable, Local AI Engineering Runtime
Build with Smoke Monkey Harness
Zero dependencies. 24 built-in tools. Human-in-the-loop safety. 100% open source under the MIT License.