Repository navigation
[Perf] mooncake: Group and parallelize direct linker layer-wise loads - #45106
Merged
hzh0425 merged 7 commits intoNov 9, 2026
Merged
Conversation
alphabetc1
marked this pull request as ready for review
October 22, 2026 03:40
alphabetc1
requested review from
huangtingwei9988 and
stmatengss
as code owners
October 22, 2026 03:40
This was referenced Oct 28, 2026
This was referenced Nov 9, 2026
4 of 5 tasks
This was referenced Nov 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
The Mooncake direct linker loads an L3 hit with one synchronous
batch_get_into_multi_buffer_rangescall per layer per pool, on a single thread. Each ranged op costs roughly 3 us serialized, so a DSA page-layer (a 72 KB KV range plus an 8 KB indexer range) moves at about 12-14 GB/s per rank, well below the NIC line rate. With a short new suffix on a long cached prefix (the common multi-turn / agentic shape) the load cannot hide behind compute, so it is directly on TTFT.A standalone Mooncake microbenchmark with the GLM-5.2 page geometry (64K tokens, 6.6 GB, one GPU and its PIX NIC) shows where the time goes:
Concurrency is the main lever; reading several layers of a page per call adds more on top.
Modifications
load_layer_wisereadslinker_load_layer_grouplayers per call (default 8) and splits each call's keys overlinker_load_threadsworkers (default 4). All groups are submitted up front; layers are still published toLayerWiseLoadCounterin order, group by group, so the forward keeps overlapping with later groups.batch_get_session_end, since they still write into device rows.--hicache-storage-backend-extra-config;{"linker_load_layer_group": 1, "linker_load_threads": 1}reproduces the previous request pattern.The UMBP direct linker already groups layers per call (
UMBP_LAYER_GROUP, default 8); this brings the Mooncake linker to the same shape.Speed Tests
GLM-5.2-FP8, 8xH200, TP8, page 64, Mooncake RDMA store on the same node over 8 NICs. L3-hit TTFT (median of 3, ms), prefix flushed from device before each measurement,
cached_tokenschecked on every request. G = layers per call, T = threads; G1/T1 is the previous behavior.Short suffix (prefix + 64 new tokens):
Same, with
--enable-linker-mla-dedup:Long suffix (prefix + 8192 new tokens), with dedup: 32K 257 -> 177 ms, 64K 431 -> 283 ms (G8/T4).
Without dedup, all 8 ranks read the same replicated MLA pages and the store's aggregate bandwidth becomes the limit, so the gain is smaller; with dedup a single reader benefits fully. Threads without grouping (G1/T4) are slower than the baseline at TP8, and loading the whole page in one call (G78) gives up the layer overlap, which is why G8/T4 is the default.
Accuracy Tests
test_unified_cache_linker_kl_inkling.py(bit-exact, threshold 1e-9),test_unified_cache_linker_kl_glm52.pyandtest_unified_cache_linker_kl_dsv4.pypass with the new defaults.0xA5before each load:test_mooncake_direct_linker_load.pycovers range merging per key, in-order layer publication when later groups finish first, and session end after in-flight reads on failure; each test fails under a matching mutation of the implementation.End-to-end: agentic trace replay (measured together with #46168)
Arms: main
985837b6ffvs main + #46168032273dcdc+ #451063f21e6c619(the combination builds new rows in_group_range_metainstead of extending the shared size/offset rows). The two PRs were measured together, so the gain below is not split between them.Setup: 4 x TP4 aggregated servers on GB300 behind a cache-aware router, Mooncake RDMA store on every node, Mooncake direct linker in
layer_wisemode,--max-total-tokens 2097152per server so most prefix hits come back from L3, DSPARK with a fixed acceptance length, InferenceX AgentX trace replay at 64 concurrent conversations for 900 s. One run per arm; across separate jobs TTFT p90 varies by about 8%.MiniMax-M3.1-Flash (TP4/EP4, 600 GB of L3 per node; no Mooncake put failures or evictions, so both arms reach the same hit rate):
L3 reload of a 480K-token prefix on an idle single TP4 server (
load_layer_wiseinstrumented, 3 rounds):load_layer_wisewall timeThe remaining ~1.5 s of the request is outside the linker and is the same in both arms.
DeepSeek-V4.1-Flash, same setup: throughput and TTFT stay within run-to-run noise (25,865 vs 25,462 tok/s/GPU, TTFT p90 2.66 vs 2.84 s, both at 96.7% hit rate). Its compressed/sparse KV makes a 529K-token reload only 0.87 GB per rank, so main's load already takes just 0.12 s of a 1.2 s request. The gain grows with the bytes read per rank; dense-KV models such as MiniMax-M3.1 (60 layers of full GQA KV) are where the serial per-layer path dominates TTFT.
Checklist
Related: #38639 (page-wise Mooncake loads behind an object-count threshold, plus ReadPlan and metrics).
CI States
Latest PR Test (Base): ✅ Run #42359402217
Latest PR Test (Extra): ❌ Run #42359402202
Latest PR Test (AMD ROCm 10): ✅ Run #42359402206
Tip
Base CI only covers the core cases, and its workload may not exercise your change. Use
/rerun-testto run the tests your change touches, or copy this prompt for an agent: