ALL INTELLIGENCE
小米 MiMo 博客T1·Models

Xiaomi MiMo-V2.5 Inference Optimization: Hybrid SWA Architecture Reduces KVCache to 1/7 of Full Attention

By Xiaomi MiMoOriginal title: MiMo-V2.5 系列推理全链路优化:将 Hybrid SWA 效率推向极致
78AI Score

Xiaomi details the full-chain inference optimization for its MiMo-V2.5 series, focusing on realizing the theoretical efficiency gains of Hybrid Sliding Window Attention (SWA) in long-context scenarios. By implementing an SWA prefix cache tree, tiered caching systems, and optimized Prefill/Decode pipelines, they reduced KVCache storage to approximately 1/7 of Full Attention while boosting throughput for multimodal and MoE architectures. Key optimizations have been contributed to the SGLang open-source community to promote efficient composite architectures.

Full Report

Contents30 sections

The MiMo V2.5 series models (including MiMo-V2.5, MiMo-V2.5-Pro, etc.) integrate several architectural features: Hybrid Sliding Window Attention (Hybrid SWA) reduces KVCache storage to approximately 1/7 of that required by Full Attention through mixed-window attention; Mixture-of-Experts (MoE) lowers per-token computational costs while maintaining model capacity via sparse activation; and a multimodal Encoder supports cross-modal understanding across vision, audio, video, and other modalities. The synergy of these three components endows the MiMo V2.5 series with significant potential for both effectiveness and efficiency in long-context and multimodal scenarios.

From the inception of the MiMo-V2 model design, we had a clear objective: to train a model that is both sufficiently powerful and highly efficient for long-form reasoning tasks. However, these two goals inherently create engineering tension. Strong reasoning capabilities require the model to effectively model long-range dependencies, which typically entails larger-scale attention computations and higher KVCache overheads. In traditional Full Attention architectures, both attention computation and KVCache storage grow rapidly with context length, making the costs of training and inference on long contexts quickly unacceptable. The core idea behind Hybrid SWA is to hierarchically mix local window attention (Sliding Window Attention, SWA) with global attention (Full Attention): the majority of layers compute attention only within local windows, while a small number of critical layers retain a global view. Theoretically, this structure can reduce attention computational complexity to near-linear levels while still preserving the ability to model long-range dependencies.

However, theoretical architectural advantages do not automatically translate into efficiency gains in real-world production systems. On one hand, Hybrid SWA significantly increases the complexity of KVCache hit rates, prefix matching, and maintaining consistency between Full/SWA dual semantics. On the other hand, in actual engineering systems, data movement across multi-level storage, asynchronous prefetching, scheduling inconsistencies, and difficulties in aligning distributed cache states collectively prevent theoretical benefits from being directly realized.

Beyond Hybrid SWA, MoE imposes stricter requirements on distributed scheduling and load balancing; the throughput bottlenecks of multimodal Encoders in large-image and long-video scenarios also urgently need to be addressed. Furthermore, optimizations in general areas such as scheduling strategies and Prefill/Decode execution pipelines are indispensable. This article documents a full-stack engineering practice for the inference system surrounding the MiMo V2.5 series models, covering KVCache management, tiered caching systems, SWA prefix cache trees, scheduling strategies, Prefill/Decode execution pipelines, and multimodal optimizations. It systematically realizes the efficiency potential of the architecture (especially Hybrid SWA) in a production environment.

I. Inference Efficiency Advantages of the Hybrid SWA Architecture

Before discussing specific optimization efforts, it is necessary to quantify the upper bound of Hybrid SWA's efficiency—this serves as both the starting point for architectural choices and the theoretical baseline and upper limit for all subsequent system optimizations.

1.1 Computational Cost Analysis

Taking MiMo-V2.5-Pro as an example, the model consists of 70 layers, where 10 layers use Full Attention and the remaining 60 layers use SWA, with a sliding window size of 128 for SWA. Compared to Full Attention, the computational cost of Hybrid SWA is illustrated in the figure below. Since SWA layers account for 6/7 of the total, the computational cost of the Hybrid SWA architecture is approximately 1/7 that of Full Attention. In Chunk Prefill scenarios, Prefill is approximately compute-bound, so this difference essentially equates to a theoretical reduction in Prefill costs.

1.2 KVCache Storage Analysis

Since SWA layers only need to retain Key-Value pairs within the sliding window and do not require storing the entire sequence, KVCache usage similarly drops to nearly 1/7. The Decode phase is approximately memory-bandwidth-bound, with latency proportional to the read volume of model parameters plus KVCache. For long sequences, the size of KVCache can far exceed that of model parameters; therefore, the reduction in KVCache storage almost directly translates to lower decode costs in long-sequence scenarios.

Attention computation (FLOPs) vs. sequence length: Full Attention vs. Hybrid SWA, showing ~7.0× difference in computation

KVCache VRAM usage (GB) vs. sequence length: Full Attention vs. Hybrid SWA, showing ~7.0× difference in storage

Different model architectures exhibit significant variations in KVCache storage and access patterns. The following estimates show the KVCache sizes for various domestic models, revealing that MiMo-V2.5-Pro and MiMo-V2.5 rank second among domestic models in terms of KVCache footprint, trailing only DeepSeek-V4-Pro and Flash.

Estimated KVCache VRAM for models < 500B vs. sequence length: Hunyuan-3, MiniMax-M2, Qwen-3.5, MiMo-V2.5, DeepSeek-V4-Flash

Estimated KVCache VRAM for models > 500B vs. sequence length: Kimi-K2, GLM-5, MiMo-V2.5-Pro, DeepSeek-V4-Pro

Note that the actual cost difference is not strictly equivalent to the KVCache size ratio, as there are fixed compute and memory access overheads independent of sequence length. However, in long-context scenarios, the overall trend remains consistent: cost-efficiency is comparable for short sequences, while the inference cost advantage grows significantly with longer sequences.

II. KVCache System Reconstruction

The MiMo-V2 and MiMo-V2.5 series were among the early models to adopt the Hybrid SWA architecture. At that time, neither mainstream open-source inference frameworks nor caching systems offered complete support for SWA. When the MiMo API first launched, we selected SGLang v0.5.5 as the codebase for our serving backend. We immediately faced a severe challenge: in that version, SGLang’s HiCache did not support SWA. Alternatively stated, early SWA support was implemented by "storing Full KVCache to accommodate SWA." Although some temporary workarounds made SWA more usable, we aimed to build a KVCache system with higher performance ceilings and better usability.

2.1 SWA KVCache Management

Dual-Pool KVCache

Hybrid SWA introduces a core storage contradiction: Full Attention layers require retaining KV for the entire sequence (O(N)), whereas SWA layers only need to maintain KV within the sliding window (O(W)). However, under traditional single KV pool designs, the system must allocate VRAM uniformly for all layers based on O(N). This prevents the exploitation of SWA’s window sparsity, causing actual storage efficiency to degrade into an approximation of Full KVCache.

To address this issue, a natural solution is to split the KVCache into two independent pools—Full Attention and SWA—and provide a unified abstraction at the system level:

  • Physical Layer: Maintain separate Full KV pools and SWA KV pools. The SWA pool is configured with capacity based solely on the window size and supports independent eviction per window, strictly limiting SWA storage to O(W) scale. This mechanism extends to L2 and L3 storage tiers.
  • Logical Layer: Expose a single sequence view to upper layers (prefix tree, scheduler, and transfer protocols). Use Full Attention indices as authoritative indices and maintain Full → SWA mappings to achieve transparent hierarchical storage.
  • Scheduling Constraints: The system validates capacity constraints for both Full KV and SWA KV simultaneously when admitting requests, preventing resource misjudgment based on a single dimension.
  • Data Transfer: Cross-tier transfers are performed exclusively based on the SWA mask, ensuring only data within the valid window is moved and avoiding redundant bandwidth usage.

Through the above design, SWA KVCache achieves strict O(W) storage constraints at the system level, improving overall KVCache capacity efficiency by approximately 7× and truly unlocking the structural advantages of Hybrid SWA. Mainstream inference frameworks have also adopted similar implementation strategies.

Layer-wise Asynchronous KVCache Fetching

After implementing SWA KVCache storage optimization, SWA layers require prefetching only a minimal amount of KVCache. This enables perfect overlap between fetching KVCache from Host to Device through layer-wise granularity scheduling. Consequently, the cost of cache reads during inference approaches zero.

KVCache layer-wise asynchronous fetch timeline: (a) compute stream stalls waiting for KVCache loading; (b) layer-wise scheduling overlaps loadback with compute, eliminating GPU wait times

SWA-aware Prefix Cache Tree

Traditional RadixAttention hit rules rely on a naive assumption: equal token sequences → equal KVs. This assumption holds true in Full Attention mode—as long as two requests share the same token ID segment, their corresponding KVs are guaranteed to remain in the pool and can be directly reused.

However, this assumption breaks down in SWA mode. The reason is that the logical lifecycle of the prefix tree does not align with the physical lifecycle of SWA KV. The length of prefix tree nodes is not constrained by the SWA window. A node’s sequence length may be shorter than the window or significantly longer; furthermore, nodes change dynamically due to request merging, splitting, and removal. Thus, although a prefix tree node logically represents a complete token sequence, its corresponding SWA KV may retain only the tail portion or may no longer exist at all. If the prefix tree continues to apply the "hit if tokens match" rule to determine reuse length, the scheduler might receive a pseudo-hit where "the tail KV has evaporated." Subsequent attention computations would read invalid or overwritten slots, directly impacting model performance.

To ensure prefix reuse remains correct and efficient in SWA mode, three modifications to the prefix tree semantics are required:

  1. Upgrade Matching Rules to "Window-Safe Length": In addition to token equality, ensure that at least the last W tokens have valid slots remaining in the SWA pool. Match lengths are truncated to this new boundary—any part exceeding it is treated as a miss. This guarantees that all KVs retrieved from a hit segment are valid.
  2. Bind Eviction Paths to Request Lifecycle: Trigger SWA release outside the window upon completion of each prefill chunk, request termination, and after generating a certain number of decode tokens. This ensures that SWA pool occupancy remains constant at the W or chunk scale in long-context/long-output tasks, rather than growing with sequence length.
  3. Ensure Consistency Between Logical and Physical States: [Implicitly covered by points 1 & 2, but often stated as maintaining synchronization between tree structure updates and physical memory management]. Note: The source text lists two explicit numbered points followed by descriptive paragraphs. I will translate exactly what is provided.

(Self-correction: The source text has two numbered items. I will translate them exactly as listed.)

  1. Upgrade matching rules to "window-safe length": Beyond token equality, ensure that at least the trailing W tokens still have valid slots in the SWA pool. The match length is clipped to this new boundary—parts beyond it are treated as misses. This guarantees that all KVs extracted from a hit segment are valid.
  2. Bind eviction paths to request lifecycles: Each completed chunk of a long prefill, request termination, and every N generated decode tokens trigger the release of SWA data outside the window. This ensures that SWA pool occupancy remains constant at the W or chunk scale in long-context / long-output tasks, rather than growing with sequence length.

SWA compressing KV volume to 1/7 is a gain at the capacity level, while hit rate is a gain at the reuse level. The product of these two determines the actual computational cost curve during the prefill stage. After introducing the "window-safe length" matching rule, the theoretical KVCache hit rate for the same token capacity decreases slightly; however, since the number of tokens supported by the same storage capacity increases several-fold, the actual hit rate improves significantly.

SWA-aware prefix cache tree: Each node records both Full Attention state and SWA state for every token. A window size of 4 is used to determine whether tail tokens still have valid SWA slots

Optimizing KVCache Hit Rate

After retrofitting all three tiers of HiCache to be SWA-aware, the device, host, and storage backend each maintain their own state regarding "which positions have valid SWA." Since HiCache's data transfer pipeline is asynchronous, caches across deployments vary, and shared prefix lengths differ across sessions, inconsistencies between Full Attention Cache and valid SWA indices across these tiers are prone to occur. According to the SWA-aware prefix cache tree matching rules, if a sequence hits in the Full Attention Cache but misses in the SWA Cache, it results in severe truncation of the match length. The more truncation occurs, the longer the segment requiring recomputation, thereby diminishing the effectiveness of SWA Cache optimization. Therefore, we implemented optimizations for distributed consistency and cache hit rates tailored to different scenarios:

  • Device complete, Host empty: This issue arises when L3→L2 prefetching only retrieves the tail segment of a sequence due to bandwidth and latency trade-offs, or when L1 prefix tree reorganization fails to synchronize with L2/L3. To address this, at key time points such as prefix tree node merging and prefill completion, we proactively check the difference set between device-side and host-side SWA allocations. We then allocate additional slots in the host-side SWA pool and asynchronously write the device's SWA KV data from Device to Host (D2H).
  • Host complete, Device empty: No active repair is needed; alignment will naturally occur upon the next Host-to-Device (H2D) transfer completion.
  • L3 prefix expiration for high-frequency sequences: The head of long sequences persists in L1/L2 due to frequent access. Combined with cache affinity routing requests with identical prefixes to the same node, caches in L3 may be evicted by storage policies because they haven't been directly accessed for a long time. This leads to premature release of L3 Cache for globally high-frequency sequences, significantly reducing cross-machine reuse. To mitigate this, when accessing Cache in L1/L2, we periodically query L3 Cache to prevent eviction.
  • SWA retention strategy for medium-to-short sequences: For SWA in medium-to-short sequences, we retain relatively dense SWA KV Cache at fixed lengths based on user request patterns. Although increasing SWA density raises the overall proportion of SWA in the KV Cache, it directly benefits scenarios such as multi-user sharing of system prompts.

Through these optimizations, we effectively translate the expansion of KV Cache capacity into higher effective hit lengths, enabling long-prefix reuse across sessions. This is particularly beneficial for scenarios such as agent-based long conversations, multi-user sharing of system prompts, and tool calls that repeatedly access the same codebase.

2.2 GCache: High-Performance Distributed Caching Infrastructure

GCache is a high-performance general-purpose cache developed by Xiaomi's Storage Team. It is a crucial component in building a unified "training-inference" storage ecosystem. Initially, in training scenarios, the Storage Team recognized that some open-source caching projects offered limited acceleration for distributed file systems and could not maximize performance, prompting them to pursue self-development. Subsequently, with the release of the MiMo large model and the launch of inference services, the team evolved GCache into an independent storage product, used for model distribution and serving as the L3 KVCache for inference engines.

GCache supports both file and KV semantics, features multi-level caching across memory/disk/remote storage, provides shm memory persistence and end-to-end zero-copy capabilities, and supports advanced features like high-concurrency non-blocking IO and RDMA communication. These capabilities meet the upper-layer business requirements for high throughput and low latency while ensuring excellent scalability.

Architecture Design

GCache Architecture: User Thread (multi-language SDK) → gcache SDK (Manager, Slice Dispatch/Collect, Worker Threads, LocalCache) → gcache Cluster (multiple gcache-servers organized via consistent hashing, including Metadata & Index, Memory/Disk Cache), with Raft+rocksdb Master handling service discovery and heartbeats, and backend integration with object storage Ceph/HDFS

GCache has several key characteristics:

  1. Decentralized metadata management enables unlimited cluster scaling:
  • Consistent hashing is applied to keys to determine storage locations.
  • The Master uses Raft for high-availability deployment. However, the Master is responsible only for managing heartbeats and service discovery; the IO path does not pass through the Master.
  1. Server-side support for both memory and disk caching:
  • Cold data in memory is evicted to disk, while hot data on disk is promoted to memory. This mode is highly friendly to inference scenarios, automatically guaranteeing performance for active sessions.

  • Does not consume user thread resources; slicing improves concurrency and keeps IO sizes within an RDMA-friendly range.

  • Threads operate in asynchronous callback mode, allowing flexible control over callback granularity, such as at the single KV level, batch level, or CUDA stream level.

Network Optimization

Current mainstream GPU machines are equipped with eight 400G high-performance NICs. However, even considering PD (Prefill-Decode) disaggregated deployment, current inference frameworks still struggle to saturate network bandwidth, leading to industry discussions about downgrading NIC specifications to reduce costs.

To fully leverage high-speed networking capabilities, GCache prioritizes using GPU NICs over front-end NICs for communication and implements extensive optimizations in the communication module, such as NUMA binding and same-rail affinity. In terms of specific performance metrics, using 1MB IO size, single-process RDMA read throughput reaches 170 GB/s with a latency of only 280 us. In GDR (GPU Direct RDMA) scenarios, due to higher HBM bandwidth, single-process throughput can reach approximately 350 GB/s, sufficiently meeting the communication performance requirements of inference frameworks.

Storage Cost Optimization

2026 is undoubtedly a year where the industry is highly sensitive to storage costs. Unlike other vendors that use dedicated storage machines, GCache prioritizes co-locating on GPU machines, taking over part of the memory from Prefill and Decode nodes, along with several NVMe SSDs built into the machine, resulting in zero additional storage cost.

Stability Assurance

Due to co-location, the high failure rate of GPU machines poses a significant challenge to stability. Since going live, GCache has encountered server host failures almost daily. First, the team invested substantial time and effort in hardening the code's fault-handling logic. Second, since keys are distributed via consistent hashing, pre-grouping session IDs logically helps reduce the blast radius of failures. Finally, leveraging hardware detection features provided by the underlying platform allows for early fault discovery and automated data migration. For rare cases of sudden crashes where there is no time for proactive handling, setting a lower SDK timeout allows the inference framework to quickly detect misses and trigger recomputation, ensuring that foreground inference processes are minimally impacted.

Based on the above efforts, GCache maintains single-replica storage even under co-location conditions, avoiding the need for multi-replica strategies to enhance availability. This is one of the key reasons for its low storage costs.

2.3 Discussion on Cache Hit Rate

Thanks to the aforementioned optimizations for SWA (Sliding Window Attention) in KVCache—resulting in lower storage footprint—and supported by a more stable, large-capacity GCache serving as L3 storage—we have significantly extended the TTL (Time-To-Live) of the cache, thereby greatly improving the KV Cache hit rate. The eviction of KVCache essentially stems from storage capacity constraints. When capacity approaches saturation, the system must prioritize retaining KVCache generated by new requests and evict historically accessed entries according to policies like LRU. This directly leads to situations where a context reused hours later often fails to hit the cache. SWA’s minimal storage footprint allows for a multiplicative increase in the number of concurrent request caches supported at the same cost, while large-capacity L3 further expands available capacity at low cost—the more ample the storage space, the less pressure there is to forcibly evict KVCache, naturally extending retention duration. A longer TTL widens the hittable window for historical contexts, causing the cache hit rate to rise accordingly. Additionally, although SWA’s reduced bandwidth transmission pressure does not directly affect TTL, it significantly lowers the overhead of data movement between multi-level storage tiers, ensuring the stable and efficient operation of the entire caching system.

Since the model went live, we have continuously observed on the server side: under mainstream high-quality harness frameworks, the server-side KV Cache hit rate averages 93%; for individual users with intensive, long-term usage, this metric can climb to 95% or even higher. Going forward, we will continue to iterate on SWA’s KV Cache management logic and collaborate with more harness frameworks to advance the co-design of harness-inference, further optimizing the upper limit of cache hit rates.

III. Scheduling Optimization

In the early stages, the router service in the SGLang community was not yet fully mature. There was no data sharing among multiple instances, so if a router service unexpectedly failed or requests were routed to different router services, KVCache scheduling degradation would occur. To address this issue and ensure high availability in large-scale cluster deployments, Xiaomi developed LLM-Router, a dynamically scalable stateless scheduler. By using Redis as centralized storage, it avoids KVCache scheduling degradation after single-service failures, thereby more stably guaranteeing cache hit rates.

3.1 KVCache and Load-Affinity Scheduling

Since HiCache is highly sensitive to L2 hit rates, if L2 misses, the system must look up and fetch KVCache from L3, waiting for the fetch to complete before performing inference on the request. Improving L2 hit rates from the router side reduces unnecessary synchronous waits, directly boosting throughput performance.

The Router achieves KVCache affinity scheduling by maintaining dispatched requests in a Radix prefix tree. Among multiple Prefill instances, it prioritizes selecting nodes that already cache the current request's prefix, while simultaneously balancing load to avoid hotspot skew. After deploying this strategy, the L2 cache hit rate increased by approximately 25%, and single-machine input throughput improved by approximately 30%. The core formula is roughly:

Text
# Select the worker with the highest score. Meaning: High cache hit rate + Low load = High score = Priority selection
score(worker) = matchWeight × prefix_match_percentage − load_penalty

To address this issue, when the Router prioritizes prefill services from the waiting queue, it schedules requests with fewer actual compute tokens first. This prevents short-duration requests from being blocked, which would otherwise cause excessive degradation in P99 latency. However, this strategy can lead to starvation, where certain requests are indefinitely delayed. To balance this, we introduced a wait-time penalty mechanism. Results show that this strategy does not compromise service quality for shorter requests, while for longer requests, it reduces the P90 TTFT metric by up to 30%.

Comparison of TTFT under FCFS vs. our scheduling strategy at P50/P70/P90/P99: Top chart shows long requests (P90 reduced by 30.5%), bottom chart shows short requests (TTFT remains largely unchanged)

IV. Prefill Optimization

4.1 Distributed Configuration

Theoretically, smaller Expert Parallelism (EP) during the prefill phase yields better performance and throughput. This is primarily due to three factors: fewer machines involved reduce cross-machine communication overhead; fewer Data Parallelism (DP) instances minimize the impact of attention load imbalance across DP groups on performance; and each machine hosts more experts, improving MoE load balancing. However, EP size is constrained by memory requirements for model parameters and KVCache. Initially, SWA KVCache required storing KVCache for all tokens, forcing a larger EP size. After optimization, only SWA-specific tokens need to be stored, allowing us to halve the EP size, resulting in an end-to-end performance improvement of approximately 40%. We will continue exploring Pipeline Parallelism (PP) optimizations tailored for Hybrid SWA architectures to further reduce EP size and enhance overall throughput.

4.2 Length Bucketing Strategy

The Hybrid architecture of the MiMo-V2.5 series significantly improves computational efficiency compared to pure GQA structures, but throughput still declines noticeably as sequence length increases. The figure below illustrates throughput in Chunked Prefill when computing a fixed 16K tokens with varying prefix lengths:

Relative prefill throughput vs. cached (prefix) sequence length for a fixed 16K compute chunk: drops from ~1x at near-zero prefix to ~0.12x at 1M token prefix

In agentic scenarios, ultra-long requests typically arise from multi-turn agent interactions and often carry substantial prefix caches. When requests with significant length disparities are scheduled onto the same model instance, short requests are slowed down by long ones, reducing overall throughput. This manifests in two main scenarios:

  1. DP-Attention Synchronization: Multiple DP instances require collective communication after attention computation at each layer to synchronize entry into the MoE stage. If both long and short requests coexist within the same EP group across multiple DPs, short requests are delayed by the computation time of long requests.
  2. Chunked Prefill Interference: When requests with different prefix lengths are batched into the same inference chunk, short-prefix requests are slowed down by the computation of long-prefix requests.

To mitigate these load imbalances, we adopted a three-tier length bucketing strategy (0–64K / 64K–256K / 256K–1M), aggregating requests with similar load characteristics into the same bucket for computation. This has significantly improved average online prefill throughput. Currently, we are also exploring finer-grained and more flexible bucketing mechanisms to adapt to dynamic changes in online workloads.

4.3 MoE Load Balancing

All models in the MiMo-V2.5 series utilize MoE architectures, necessitating consideration of expert load balancing during the prefill phase. Since the pretraining process incorporated load-balancing objectives and training was stable, the model learned a relatively uniform expert allocation strategy. During inference, without enabling any explicit expert load balancing strategies, the average expert load ratio per layer (defined as the mean token count across all ranks divided by the maximum token count among ranks in that layer) is approximately 0.85, indicating a well-distributed load. Consequently, we have not yet introduced any specific expert load balancing strategies. We will continue monitoring this metric and introduce relevant optimizations as needed based on the evolution of online workload patterns.

Expert load ratio per layer (mean/max token count), averaging 0.8495, close to the ideal value of 1.0

4.4 Resolving NUMA Conflicts

On some Ubuntu systems, the kernel's numa_balancing parameter conflicts with SGLang's numa-node configuration, causing occasional large execution gaps between compute kernels during model inference. In multi-node, multi-GPU deployments, these gaps occur randomly across ranks. During synchronization between ranks, the slowest rank dictates the pace, significantly impacting overall inference efficiency. Disabling the system kernel's numa_balancing parameter resolves this issue, yielding an end-to-end performance improvement of approximately 10%.

V. Decode Optimization

5.1 Memory Optimization

  1. Full SWA Support in Decode KVCache: Effective KVCache capacity increased by nearly 5x.
  2. KVCache Pre-allocation Optimization in PD Disaggregation: Moved the prealloc process for requests not yet started from GPU memory to CPU memory, transferring them to GPU only when decode actually begins, eliminating waste caused by resource pre-occupation.
  3. CUDA Graph Memory Tuning: Optimized CUDA Graph parameters to reduce space waste and increase available memory.

5.2 MTP Optimization

The MiMo-V2.5 series models natively support 3-layer MTP to accelerate decode output. However, MTP was previously disabled during the prefill stage, causing the initial 128 output tokens of the decode phase to use invalid KVCache and resulting in extremely low prediction acceptance rates. Since most output sequences in Agentic scenarios are short, this flaw significantly diminished the acceleration benefits of MTP. By introducing MTP support in the prefill stage and implementing specialized adaptations and optimizations for HiCache L2/L3, we achieved a significant improvement in early-stage decode MTP acceleration: the speedup ratio reached 2.3× for tokens 0–128 and 1.5× for tokens 128–256, effectively reducing real-world decode costs in agentic scenarios.

VI. Multimodal Inference Optimization

Based on the SGLang community's v0.5.7 EPD solution, we performed extensive engineering optimizations and stability fixes for EPD disaggregation around MiMo-V2.5. While maintaining latency levels, we doubled Encoder throughput (2x) and are currently contributing these improvements back to the SGLang community (issue #24945). The performance differences for the Encoder before and after optimization are shown in the table below:

QPSAverage LatencyP90 Latency
Before Optimization1578.39 ms100.76 ms
After Optimization3080.28 ms82.94 ms

6.1 Architecture Optimization

  • Multimodal Embedding Data Replication and Parallel Inference: In the Prefill scheduler main loop, we support asynchronous replication of multimodal Embedding data across TP ranks, overlapping with Prefill inference to reduce GPU idle time.
  • Encoder Support for Data Parallelism: Since the Encoder model is relatively small, setting TP>1 actually degrades performance. Therefore, we deploy the Encoder with TP=1 while supporting data parallelism, facilitating deployment and operations on single-machine 8-GPU setups.
  • Encoder Support for Cross-Request Batching: We introduced cross-request batching for the EPD Encoder Server. The Encoder scheduler aggregates concurrent requests by modality, merging images/audio from multiple requests into a single Encoder Forward pass before splitting and returning results per request. This solves the issue of low GPU utilization caused by per-request encoding.

6.2 Preprocessing Optimization

  • GPU-based Image Preprocessing: In large image scenarios, performing resize/normalize/patchify on the CPU significantly increases end-to-end latency. We migrated preprocessing to the GPU, eliminating the CPU bottleneck.
  • Parallel Image Downloading: We use multi-process parallelism for downloading images and PIL decoding, avoiding latency caused by serial downloads and GIL lock contention.
  • Parallel Multimodal Downloading and Forward Passes: In earlier Encoder implementations, data downloading and inference were serial both between batches and within batches, leaving the GPU idle during downloads. By using message queues to decouple downloading from inference, we achieved overlap between downloading and inference within batches.
  • Parallel Video Decoding: We evenly split frame extraction indices into N chunks and create independent VideoDecoder instances for each chunk to perform multi-threaded parallel decoding. This reduced the end-to-end latency for encoding a 1-hour video from 156s to 23s.

6.3 Cache Optimization

  • Encoder Consistent Hashing: In scenarios with multiple Encoders, Prefill uses round-robin selection, which reduces multimodal cache hit rates. By implementing consistent hashing, we route identical requests to the same Encoder, increasing cache hit rates by 30%.
  • Intra-Machine Embedding Cache Sharing: Using shared memory, we enable sharing of multimodal cache data among multiple GPUs within an Encoder machine, improving cache hit rates.

VII. Postscript

Looking back at this work, the inference efficiency of the MiMo-V2.5 series models does not stem from a breakthrough in any single component, but rather from coordinated multi-dimensional optimization. Hybrid SWA benefits both prefill and decode stages, but insufficiently optimized KVCache implementations can actually increase costs across various stages. To address this, we systematically refactored KVCache management, hierarchical caching, and prefix cache trees, tackled core issues with SWA KVCache, optimized scheduling strategies and the Prefill/Decode pipeline, and validated these changes in real-world online scenarios. Ultimately, we translated theoretical efficiency advantages into production reality. Only then did Hybrid SWA fully realize its architectural advantage of combining strength and efficiency for long-context reasoning. Combined with MoE configurations and various multimodal inference optimizations, this significantly improved the performance of online inference services.