rednote-machine-learning/RedKnot
Efficient Long-Context LLM Serving with Head-Aware KV Reuse and SegPagedAttention
What it solves
RedKnot addresses the high computational and memory costs associated with serving Large Language Models (LLMs) over long contexts. It specifically targets the reduction of Time to First Token (TTFT) and arithmetic compute overhead without significantly sacrificing model quality.
How it works
RedKnot is a model-aware execution framework that combines three primary mechanisms:
- Head Decomposition and Aggregation: It classifies attention heads based on their long-context behavior. Local heads are prepared offline for reuse, while global, retrieval, or recovery heads remain online, and their contributions are merged back into the model.
- Sparse FFN and MoE Execution: It uses token-level importance to determine which rows enter Feed-Forward Network (FFN) work and employs adaptive expert Top-K selection for Mixture-of-Experts (MoE) models, assigning more experts only when necessary.
- SegPagedAttention: This organizes KV pages and visibility per head and segment, allowing different types of heads (global, local, retrieval) to consume different context scopes without requiring a uniform cache layout.
Who it’s for
It is designed for developers and researchers deploying long-context LLMs (such as DeepSeek V4, Mistral, Qwen, and Llama) who need to optimize inference speed and compute efficiency on high-end GPU hardware (e.g., NVIDIA H200/B300).
Highlights
- Significant Performance Gains: Targets a 2–5× speedup in hot-state TTFT and 70–90% savings in arithmetic compute.
- Minimal Quality Loss: Aims for quality regression within 1 percentage point.
- Broad Model Support: Includes adapters and benchmarks for DeepSeek V4 Flash, Mistral, Qwen3, Qwen3.5 MoE, and Llama 3.3.
- SGLang Integration: Built on top of SGLang and currently migrating core code to vLLM.
Related
- Project
- Project
- Project
- Dispatch
- Project