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

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
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 \
--jsonLimitations
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
👀 See Also

OpenGauge: 로컬에서 LLM 에이전트 비용을 추적하는 오픈소스 도구
OpenGauge는 OpenClaw와 같은 LLM 에이전트의 API 호출을 모니터링하는 오픈소스 도구로, 토큰 사용량, 비용, 지연 시간을 로컬 SQLite 데이터베이스에 기록합니다. 자동 로깅을 위한 프록시 모드, 상세한 비용 통계, 그리고 무한 루프를 방지하는 서킷 브레이커 기능을 포함합니다.

AI 에이전트의 이메일 및 Google 드라이브 접근 문제 해결
AWS에서 AI 봇을 위한 이메일 및 Google Drive 접근 설정 시 계정 차단이 발생할 수 있습니다. Gmail과 Workspace 도메인을 활용한 해결 방법을 소개합니다.

오픈소스 다중 에이전트 프레임워크, Claude 코드 유출에서 추출됨
한 개발자가 Claude Code의 유출된 소스 코드에서 다중 에이전트 오케스트레이션 시스템을 추출하여 모델에 구애받지 않는 MIT 라이선스의 오픈소스 프레임워크로 재구축했습니다. 8,000줄의 TypeScript 프레임워크에는 작업 스케줄링, 에이전트 간 메시징, 내장 도구가 포함되어 있습니다.

클로드의 무음 드롭오프: AI 에이전트가 비즈니스 사이트에서 겪는 액션 레이어 실패
Claude는 비즈니스 사이트(가격, 예약 흐름, 양식)를 읽을 수 있지만, 호출 가능한 엔드포인트가 없어 예약, 제출, 라우팅 등의 실행 계층에서는 실패합니다. 이는 분석 신호 없이 보이지 않는 사용자 이탈을 초래합니다.