Monarch v3: NES-Inspired KV Paging for 78% Faster LLM Inference

✍️ OpenClawRadar📅 公開日: April 13, 2026🔗 Source
Monarch v3: NES-Inspired KV Paging for 78% Faster LLM Inference
Ad

What Monarch v3 Does

Monarch v3 is an open-source implementation of NES-inspired memory paging for transformer inference that addresses the linear growth of KV cache with sequence length. By 4K tokens, most KV cache sits unused while consuming VRAM at full precision.

How It Works

The system splits KV cache into two regions:

  • Hot region: Recent tokens kept at full precision
  • Cold region: Older tokens compressed to ~20 bytes each (vs 64-128 bytes hot)

Four components work together:

  • TurboQuant Compression: Quantizes KV to 4-bit integers with polar encoding and residual correction, achieving ~97% size reduction with ~0.3% perplexity loss
  • Sliding Window Eviction: Recent N tokens stay hot by default, old tokens compress to cold storage
  • Attention-Weighted Promotion: High-attention tokens move back to hot with sticky mechanism to prevent thrashing
  • Page Swaps: Small batches of cold tokens materialize on access with local decode loop replacing batch matmul

Benchmark Results

Setup: TinyLlama-1.1B fp16, 50 generated tokens

  • Standard: 17.01 tok/s, 2112 MB VRAM
  • Monarch-v3: 30.42 tok/s, 2131 MB VRAM, 512 hot tokens, 1024 cold tokens
  • Gain: +78.7% throughput, +0.9% VRAM
Ad

Simplified Decode Loop

for step in 1..100:
    q = project_query(next_token)
    # Compute attention: hot only (fast)
    scores_hot = q @ kv_hot.T
    # Access cold if high attention (rare)
    if max(scores_hot) < threshold:
        kv_cold_promoted = decompress(cold_pages)
        scores_cold = q @ kv_cold_promoted.T
        # Move to hot for next step
    # Aggregate, softmax, apply attn ...
    # Evict old tokens from hot → cold
    if len(kv_hot) > window_size:
        evict_oldest_to_cold()

Current Status

  • Implementation: Working on Hugging Face Transformers with custom cache backend
  • License: Apache 2.0
  • Paper: Full technical spec available
  • Next: CUDA kernel fusion for cold decompression planned

How to Try It

git clone https://github.com/JohannaWeb/Monarch.git
cd Monarch
pip install -r requirements.txt
python train_tinyllama_fp16.py
python src/benchmark_monarch.py \
    --model models/tinyllama_fp16 \
    --mode both \
    --max-new-tokens 100 \
    --promotion-threshold 0.15 \
    --sticky-threshold 3 \
    --json

Limitations

The approach relies on recency (recent tokens = high attention), which works for most tasks but may not for retrieval-heavy workloads. Attention extraction is available in base models but not chat variants; fallback uses window-only paging.

📖 Read the full source: r/LocalLLaMA

Ad

👀 See Also

クラウドのコードダッシュボード、GitHubで1900万以上のAI生成コミットを追跡
Tools

クラウドのコードダッシュボード、GitHubで1900万以上のAI生成コミットを追跡

開発者が、GitHubのパブリックリポジトリでClaude Codeによって生成された1,900万件以上のコミットを追跡するダッシュボードを構築しました。主要言語としてTypeScript(35.3%)、Python(19.2%)、JavaScript(10.3%)が示されています。このシステムはNext.js、Recharts、PostgreSQLを使用しており、GitHubのAPIレート制限に対応するETLパイプラインを備えています。

OpenClawRadar
ApexClaw:85以上のツールを備えたWeb自動化、音声、メール対応のオープンソースTelegram AIエージェント
Tools

ApexClaw:85以上のツールを備えたWeb自動化、音声、メール対応のオープンソースTelegram AIエージェント

ApexClawは、Goで書かれたオープンソースのTelegram AIエージェントで、ヘッドレスChromeによるウェブ閲覧、音声ノート処理、Gmail連携、シェルスクリプト実行など、85以上の組み込みツールを提供します。セルフホスト型で、推論にはz.aiエンジンを使用しています。

OpenClawRadar
OpenTidy: Claude Codeを活用した管理タスクのためのオープンソース背景アシスタント
Tools

OpenTidy: Claude Codeを活用した管理タスクのためのオープンソース背景アシスタント

OpenTidyは、請求書処理、フォーム入力、コミュニケーションのトリアージなどの管理タスクを処理するために、永続的なClaude Codeセッションを生成するオープンソースのmacOSサービスです。最大10個の並列ジョブを実行し、機密性の高いアクションにはTelegram通知を送信します。

OpenClawRadar
エージェントルーム:Claudeコードエージェントチーム可視化デスクトップアプリ
Tools

エージェントルーム:Claudeコードエージェントチーム可視化デスクトップアプリ

Agents Roomは、.claude/agents/フォルダをスキャンし、フロントマターを読み取り、エージェント間の関係をキャンバス上に自動接続線で可視化するElectronデスクトップアプリケーションです。マークダウンファイルを編集する代わりに、UIから直接エージェント、スキル、コマンドを作成・編集できます。

OpenClawRadar