TL;DR
HiMA is a hierarchical memory management framework designed for "hybrid" AI models (like Qwen3.5 and Kimi Linear) that combine standard attention with recurrent layers. By replacing static memory partitions with a dynamic allocation system and a novel "loss-per-byte" eviction metric, HiMA boosts throughput by up to 94% and slashes tail latency (P99 TTFT) by up to 64% in complex agentic workloads.
What Problem Does This Paper Address?
Modern Large Language Models (LLMs) are increasingly "hybrid," interleaving standard Transformer attention layers with linear attention or State Space Model (SSM) layers (e.g., Mamba). This architecture is great for performance but a nightmare for memory management.
Existing serving systems like vLLM or SGLang were built for pure Transformers, which only need a KV cache pool. Hybrid models introduce a second pool for recurrent-state snapshots. Current systems treat these pools as fixed-size silos and use simple "Least Recently Used" (LRU) policies to manage them.
This creates two major inefficiencies in "agentic" applications:
- The Asymmetry Problem: One byte of a recurrent state is "worth" more than one byte of KV cache because it saves significantly more re-computation time, yet LRU treats them as equal.
- The Partition Bubble: Agentic workloads are unpredictable. An "agent swarm" (many parallel agents) might starve the recurrent pool, while a "long-horizon agent" (one agent with a massive history) might starve the KV pool. Static partitions leave memory sitting idle in one pool while the other is overflowing, causing unnecessary delays.
Methods
The authors introduce HiMA (Hierarchical Memory Management), which tackles these issues at two levels:
- Intra-pool (Loss-per-Byte): Instead of LRU, HiMA uses a new metric called Loss-per-Byte (LPB). It calculates the GPU time required to recompute a block if it's evicted, divided by its size in bytes. This allows the system to compare the "value" of a KV block against a recurrent snapshot on a level playing field.
- Inter-pool (Dynamic Allocation): HiMA treats memory allocation as a continuous optimization problem solved across two timescales:
- The Budgeter (Slow): Every 30 seconds, it looks at overall traffic trends and re-balances the total memory budget between the two pools.
- The Admitter (Fast): For every incoming request, it chooses the cheapest of five actions: admit to free space, evict from its own pool, transfer space from the other pool, evict from the other pool, or defer the request.
- The Actuator: To make these transfers fast and "atomic" (all-or-nothing), HiMA uses CUDA Virtual Memory Management (VMM). This allows the system to remap physical memory pages between pools in microseconds without moving actual data or breaking existing computation graphs.
Datasets
The researchers evaluated HiMA using three production-grade hybrid models: Qwen3.5-35B, Qwen3-Next-80B, and Kimi-Linear-48B. They tested these models against four distinct workloads:
- Long-horizon agents: Simulating a single session with massive conversation history (KV-heavy).
- Agent swarms: Simulating hundreds of parallel sub-agents (Recurrent-heavy).
- Traffic perturbation: A "stress test" that rapidly switches between the two extremes.
- Claude Code trace replay: Real-world data from coding agent sessions (SWE-Bench-Pro).
Key Insights and Ideas
- Compute-Memory Asymmetry: The most striking insight is that recurrent snapshots are "fixed-size" regardless of prefix length. Caching a single snapshot can save the computation of thousands of tokens, making it exponentially more valuable per byte than a standard KV block.
- The "Shadow Price" Bridge: The authors use a Lagrange multiplier ($\nu^*$) as a "shadow price" for memory. This single value allows the slow Budgeter and the fast Admitter to stay mathematically synchronized, ensuring that per-request decisions align with long-term efficiency goals.
- LPB Inverts Recency: In a radix tree (prefix cache), LPB often protects "internal nodes" (shared system prompts) that LRU might accidentally evict during a burst of new, random requests.
Key Results
HiMA consistently outperformed standard SGLang and vLLM baselines:
- Throughput: Delivered 7–94% improvements in output tokens per second. The biggest gains were seen in "traffic perturbation" scenarios where static systems fail to adapt.
- Latency: Reduced P99 Time to First Token (TTFT) by 25–64%. This is crucial for agents that need to feel responsive.
- Efficiency: Reclaimed 16–30% of memory that was previously wasted as "bubbles" in static partitions.
- Theoretical Soundness: The authors proved that their per-arrival admission rule tracks the optimal offline allocation with "second-order regret," meaning it stays very close to the theoretical best-case performance even with noisy traffic.
Limitations and Future Work
- Two-Pool Focus: While the math supports any number of pools ($|I| \ge 2$), the current implementation is only tested on the KV/Recurrent split. Future work could include pools for speculative decoding or multi-modal states.
- Hardware Tiers: The current model assumes all memory is on the GPU (HBM). Extending HiMA to manage transfers between HBM, System RAM (DRAM), and Disk (NVMe) would require accounting for the much higher latency of those interconnects.
- Engine Integration: HiMA was implemented as a plugin for SGLang. While the design is modular, deep integration into other engines like vLLM would require significant engineering effort to handle their specific scheduling pipelines.
Summary updated