Inference Serving Architecture for Ultra-Large Parameter Models: Design and Practice

    This article presents a practical architecture for serving inference on ultra-large parameter models that combine sliding-window and compressed attention. It explains why runtime state space, rather than raw compute or memory, becomes the main bottleneck, and how to manage it through a dedicated cache subsystem with global logical addressing. The article covers a five-layer system design, four performance optimization tracks (prefix reuse, tiered offloading, graph capture, and parallelism), a repeatable capacity evaluation workflow, and common pitfalls to avoid. Readers will gain a structured approach to delivering stable long-context inference on limited hardware.

    1. Background: The Hard Part Is the State Space, Not the Size

    Once models reach the trillion-parameter scale and adopt hybrid structures that mix sliding-window attention with several compressed attention variants, the bottleneck in an inference system is often no longer raw compute or memory capacity. Instead, it is the complexity of the state space that the runtime must maintain. Conventional inference frameworks typically treat the key-value cache as a simple structure: one raw tensor per layer. That assumption breaks down for this class of models.

    Concretely, a deployable inference runtime must manage the following at the same time:

    • Coordinate mapping for all tokens (the correspondence between logical positions and physical slots);
    • The physical cache pool for sliding-window attention;
    • Compressed cache pools for multiple compression levels (a separate pool for each compression ratio);
    • The intermediate state pool used by the compression process itself;
    • The index pool required for sparse retrieval;
    • The mapping and lifecycle of all the above pools under four mechanisms: prefix cache reuse, graph capture, disaggregated prefill and decode deployment, and tiered offloading.

    An inconsistency in any single mapping shows up as accuracy anomalies, a sharp increase in memory fragmentation, or graph capture failures. The first principle of architecture design therefore follows: abstract cache management into an independent, addressable subsystem instead of implicit state scattered across per-layer operators.

    2. Three Impacts of Hybrid Attention on the Runtime

    2.1 Layer Heterogeneity: Multiple Attention Types Coexist in One Model

    A hybrid structure typically means that most layers use local window attention while a few layers use global or compressed attention. Different layers therefore have completely different cache access patterns: local layers only need to retain recent tokens within the window, while global layers must reach across a long history. A uniform allocation strategy wastes a large amount of space in local layers and overflows in global layers.

    The engineering solution is to partition pools by attention type and build a static mapping table between layers and pools. This table is determined once during model loading, avoiding repeated decisions at runtime.

    2.2 State Consistency Under Compression

    Compressed attention condenses a long history into a shorter representation, but compression itself is stateful: it needs to record which ranges have already been compressed, how compression boundaries are aligned, and how to update on incremental writes. In design terms, compression state should be treated as a first-class citizen and persisted, sharing the same lifecycle management as the cache pools. Otherwise, stale state easily appears during request switching or prefix reuse.

    2.3 Additional Index Overhead from Sparse Retrieval

    To control computation over very long contexts, a common approach is to add a lightweight retrieval module that first selects a small number of key history segments before running exact attention. This introduces new index caches and scoring buffers whose capacity and access frequency are often underestimated, so they need to be budgeted separately in capacity planning.

    3. A Practical Layered Architecture

    It is recommended to split the system into five layers that communicate through explicit interfaces:

    1. Access and scheduling layer: request queuing, batching strategy, priority and timeout control;
    2. Cache management layer: unified addressing, allocation, reclamation, and statistics, hiding pool differences from the layers above;
    3. Execution layer: attention operators, expert routing, graph capture, and operator fusion;
    4. Parallel communication layer: communication orchestration for tensor parallelism, pipeline parallelism, and context parallelism;
    5. Resource and observability layer: collection of metrics such as memory watermark, throughput, latency percentiles, and hit rate.

    A schematic cache handle abstraction is shown below (it expresses design intent only and is not a specific implementation):

    1. class KVHandle:
    2. def __init__(self, pool_id: str, logical_pos: int):
    3. self.pool_id = pool_id # points to a specific physical pool
    4. self.logical_pos = logical_pos # global logical coordinate
    5. def resolve(self, allocator) -> int:
    6. return allocator.translate(self.pool_id, self.logical_pos)

    The key point is that logical coordinates are globally unique and physical slots are translated by the allocator. Prefix reuse, offloading, and migration then only change the translation rules, not the logic in the upper layers.

    4. Four Main Tracks for Performance Optimization

    4.1 Prefix Reuse and Tree-Based Indexing

    In multi-turn conversations and scenarios with shared system prompts, prefix reuse can significantly reduce repeated computation. The implementation hinges on a stable tree index whose nodes store a content fingerprint, a cache handle, and a reference count. Eviction should make a joint decision based on recency of use and reference count, so that hot prefixes are not deleted by mistake.

    4.2 Multi-Level Caching and Tiered Offloading

    Memory, host memory, and external storage form a natural hierarchy. The strategy is to push cold data down and keep hot data resident, using asynchronous prefetch to hide transfer latency. Hit rate and migration bandwidth should be monitored at each level; when the hit rate falls below a threshold, adjusting the eviction policy is preferable to blindly adding capacity.

    4.3 Graph Capture and Batching Stability

    Static graphs can greatly reduce scheduling overhead but require stable shapes and cache layouts. In practice, fix a few batch-size tiers and fall back to dynamic execution beyond those tiers, while ensuring that cache pool addresses are not rearranged during capture.

    4.4 Combining Parallelism Strategies

    Tensor parallelism reduces per-device weight pressure, context parallelism splits very long sequences, and disaggregated prefill and decode deployment lets the two types of workload choose suitable resource ratios. A recommended tuning order for the combination is: first set the context parallelism degree to meet the length requirement, then tune tensor parallelism to fit memory, and finally use disaggregated deployment to balance throughput and latency.

    5. Capacity Evaluation and Tuning Workflow

    A repeatable evaluation loop is recommended:

    1. Define the workload profile: average and tail input length, output length, and peak concurrency;
    2. Estimate cache demand: compute per pool as “number of layers x bytes per token x concurrency x length”, with compressed pools scaled by the compression ratio;
    3. Set metric targets: time to first token, time per output token, throughput, and an upper bound on the memory watermark;
    4. Run load tests and collect percentile data to locate whether the bottleneck is the cache, communication, or scheduling;
    5. Adjust one variable at a time, changing a single parameter per iteration and recording the result;
    6. Lock in the configuration and add it to regression testing to prevent later versions from regressing.

    6. Common Pitfalls

    • Using only the average length for capacity planning and ignoring the long tail, which causes overflow at peak times;
    • Excluding compression state from persistence, which leads to accuracy drift after a restart;
    • Prefix caching without reference counts, so hot data is repeatedly evicted;
    • Allowing cache rearrangement during graph capture, which causes intermittent failures;
    • Raising the parallelism degree blindly, so communication overhead exceeds the compute gains.

    7. Conclusion

    Serving inference for ultra-large parameter models with hybrid attention structures is essentially a systems engineering problem of state management plus resource orchestration. Abstracting the cache into an addressable subsystem, bringing compression and index state under a unified lifecycle, trading throughput and latency through tiered offloading and combined parallelism, and continuously tuning with a data-driven loop are what make it possible to deliver long-context capability reliably on limited hardware. The methods above are general engineering practices and should be adapted to your own environment in