Architecture
~8 min readUpdated: December 2026

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

Attention Routing Kernels Ark Dual-Memory Routing Architecture in Smoke Monkey

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.

Technical Review: Smoke Monkey Core Architecture Team
Tested on Node.js 18+ & BunTypeScript 5.x
Quick Answer & Executive Definition

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.

Key Architectural Takeaways
Quick Implementation Exampleark-long-context-agent.ts
ark-long-context-agent.tstypescript
import { createAgent } from '@smoke-monkey/harness';
// Long-horizon agent serving an Ark-routed 64K checkpoint with minimal KV footprint
const 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);
Video Guides

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/ RoPE234.9M79.0 / 11.058.3 / 3.229.2 / 7.140.4
Hybrid GLA 1:445.7M (3.8+41.9)19.5 / 4.646.9 / 41.025.8 / 3.736.3
Hybrid GDN 1:445.7M (3.8+41.9)47.3 / 17.132.1 / 19.334.8 / 19.140.6
Hybrid GDN 1:637.5M (3.9+33.6)18.6 / 24.851.3 / 44.734.4 / 18.040.9
Ark (Learned Routing)25.3M (1.8+23.5)59.2 / 45.459.3 / 60.335.7 / 23.839.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:

bash
# 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 2b

Key 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.

Google Search Questions & Answers

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 guides

Build with Smoke Monkey Harness

Zero dependencies. 24 built-in tools. Human-in-the-loop safety. 100% open source under the MIT License.

npm install smoke-monkey-harness