Open-Source Ultra-Scale MoE Inference Architecture: Managing Attention State Spaces

    This article breaks down the architecture of open-source ultra-scale Mixture-of-Experts (MoE) inference systems, focusing on why attention cache state management—not raw compute or memory—is the primary bottleneck. It explains the limits of traditional per-layer KV management, surveys key mechanisms such as shadow prefix trees, multi-level compressed pools, lightweight TopK, multi-step prediction, and expert parallelism, and outlines deployment patterns including PD disaggregation, context parallelism, and sparse offloading. Readers will find a practical checklist for memory budgeting, latency testing, and cache hit-rate monitoring.

    1. Background: The Hard Part Is the Attention State Space, Not Just Scale

    Over the past two years, open-source communities have released Mixture-of-Experts (MoE) models ranging from hundreds of billions to trillions of parameters. The first instinct is usually “not enough VRAM, not enough compute.” But in real inference serving, the first thing to break is often not compute—it is state management for the attention cache.

    Take a recent open-source ultra-scale MoE series as an example. Its structural traits are: every layer uses sliding window attention (SWA), and it switches between two compressed attention variants (CSA / HCA). This means the inference engine can no longer treat the KV cache as a simple “one raw KV per layer” structure. Instead, it must simultaneously maintain:

    • Global coordinates for all tokens;
    • A physical cache pool for the sliding window;
    • Two compressed cache pools with different compression ratios;
    • An indexer cache pool;
    • A compress state pool;
    • And the mappings among these pools across prefix caching, CUDA Graph, PD disaggregated deployment, and sparse offloading.

    Using a general-purpose inference framework’s implementation approach as a guide, this article discusses how to wire such new structures into a runnable system.

    2. Core Challenges: Why Traditional KV Management Falls Short

    The traditional approach is per-layer raw KV plus a single token slot mapping. Under the new structure, all of these assumptions break down:

    1. Inconsistent coordinates: Global token positions no longer map one-to-one to physical slots; a slot in a compressed pool may represent multiple original tokens.
    2. Inconsistent lifecycles: SWA slots are evicted quickly, while compressed pools are evicted slowly, so their invalidation boundaries differ during prefix reuse.
    3. Graph capture constraints: CUDA Graph requires stable addresses and shapes, but dynamic swapping in and out of multi-level pools can easily break static assumptions.
    4. Disaggregated deployment constraints: When prefill and decode are separated, compress states must be serializable and migratable.

    A schematic pool management abstraction:

    1. class MultiLevelKVPool:
    2. def __init__(self):
    3. self.full_index = {} # Global token coordinates
    4. self.swa_pool = RingBuffer()
    5. self.c4_pool = CompressPool(ratio=4)
    6. self.c128_pool = CompressPool(ratio=128)
    7. self.indexer_pool = IndexerPool()
    8. self.compress_state = StateCache()
    9. def alloc(self, token_pos, layer_kind):
    10. # layer_kind in {"swa", "csa", "hca"}
    11. ...

    3. Key Mechanisms at a Glance

    3.1 Shadow Index Tree and Prefix Reuse

    Under hybrid caching, prefix matching cannot rely on the token sequence alone; it must also verify physical consistency across pools. A common approach is to maintain a “shadow” prefix tree whose nodes record handles for each pool. On a hit, the whole set is reused; on a miss, partial reuse happens at pool granularity.

    3.2 Multi-Level Cache Pools and Compressors

    Compressors reduce long contexts into lower-resolution representations. Higher compression ratios save more VRAM but cause greater precision loss. In engineering practice, they are usually combined in layers: lower-ratio pools preserve precision, while higher-ratio pools preserve length.

    3.3 Lightweight TopK and Sparse Retrieval

    Sparse attention performs coarse filtering first and fine computation second. Lightweight TopK uses low-precision scoring to select candidate blocks, avoiding the bandwidth pressure of full scoring.

    3.4 Multi-Step Prediction (MTP)

    Predicting multiple tokens in a single forward pass can improve decode throughput, but it requires additional cache slots and rollback logic.

    3.5 Expert Parallelism and Communication Orchestration

    The bottleneck in ultra-scale MoE is often All-to-All communication. Tensor parallelism, data parallelism, and context parallelism must be orchestrated together with expert parallelism to reduce bubbles.

    4. Deployment Patterns: Disaggregated and Collaborative

    • PD disaggregation: Prefill and decode scale independently, and compress states must support migration.
    • Context parallelism (CP): Long sequences are split, with attention to halo exchange when attention windows cross boundaries.
    • Sparse offloading (HiSparse-style approaches): Cold data is pushed down to host memory or object storage, while hot data stays in VRAM.

    5. Practical Recommendations Checklist

    1. Build a VRAM budget table first: estimate pool by pool, not just weights.
    2. During stress testing, record prefill and decode latency distributions separately.
    3. Monitor prefix hit rate and compressed pool hit rate separately, and establish baselines with logging services and monitoring/alerting systems.
    4. Validate graph capture paths and dynamic paths separately to avoid post-launch rollbacks.
    5. When selecting model structures, include “cache state complexity” as an evaluation dimension.

    6. Conclusion

    Bringing ultra-scale MoE inference into production is essentially translating new attention structures into a cache and communication system that is schedulable, observable, and migratable. Understanding the state space matters more than memorizing a particular parameter count.