Skip to content

perf(pytorch): add rolling Mooncake checkpoints across prefill and decode - #5211

Open
silencelamb wants to merge 13 commits into
InternLM:mainfrom
silencelamb:feat/mooncake-prefill-checkpoint-interval
Open

silencelamb wants to merge 13 commits into
InternLM:mainfrom
silencelamb:feat/mooncake-prefill-checkpoint-interval

Conversation

@silencelamb

@silencelamb silencelamb commented Nov 29, 2026 •

Copy link
Copy Markdown
Collaborator

Hybrid attention can resume at a shared prefix when both its attention KV and its recurrent state are available. A new turn can branch inside the previous prompt or reuse some of its generated tokens. This PR lets Mooncake Store publish recurrent and convolution state on one absolute token grid across prefill and accepted decode. As a conversation advances, older checkpoints become eligible for reclamation once other readers and conversations release them.

Configuration

export LMDEPLOY_STORE_CHECKPOINT_INTERVAL=4096
export LMDEPLOY_STORE_CHECKPOINT_KEEP=2
Variable Default Meaning
LMDEPLOY_STORE_CHECKPOINT_INTERVAL 0 Tokens between grid points, counted from the sequence start. 0 disables the grid.
LMDEPLOY_STORE_CHECKPOINT_KEEP 2 Maximum grid points per conversation across prefill and accepted decode. -1 = unlimited, 0 = zero points, positive N = at most the latest N points.

At interval 4,096 and KEEP=2, a 5,000-token sequence has one candidate at 4,096. At 13,000 tokens, the latest two candidates are 8,192 and 12,288. Reuse requires a safe published state and matching KV.

Use compact state with --prefill-save-last-only. Bounded retention across chat turns requires a single-node kv_both service and a stable X-Correlation-ID. The local HBM decode flags are independent of the Store grid. English guide · 中文文档

AgentX performance

C120 with and without #5211

We added #5211 to the same eight-PR stack using a 4,096-token grid with KEEP=2. Both sides of each comparison use MTP3 and the same local decode settings.

  • With both local decode options off, decode throughput rose 3.49% and SLO goodput rose 25.56%. Peak Store occupancy fell 32.17% and cumulative PUT volume rose 37.52%.
  • With both local decode options on, decode throughput rose 4.34% and SLO goodput rose 41.83%. Peak Store occupancy fell 40.47% and cumulative PUT volume fell 34.87%. Store evictions fell from seven batches to zero.

“Off” omits both CLI options. “On” enables --prefix-cache-decode-save-first and sets --prefix-cache-decode-state-interval 1024. All nine-PR rows below use the 4,096-token grid. All rows use MTP3 except the row marked MTP5.

Configuration Completed / errors RPS Decode tok/s TTFT p50 / p95 (ms) TPOT p50 / p95 (ms) SLO goodput (req/s)
8 PRs · off 4,635 / 1 2.519 2,202.21 764 / 4,045 27.12 / 43.43 0.944
8 PRs · on 4,617 / 0 2.509 2,198.68 772 / 4,342 27.71 / 43.20 0.878
9 PRs · KEEP=2 · off 4,756 / 1 2.585 2,278.97 753 / 3,468 25.31 / 40.33 1.185
9 PRs · KEEP=2 · on 4,761 / 0 2.587 2,294.13 746 / 3,541 24.91 / 41.29 1.246
9 PRs · KEEP=1 · off 4,701 / 0 2.555 2,255.36 762 / 3,838 26.29 / 41.82 1.039
9 PRs · KEEP=2 · off · MTP5 4,955 / 0 2.693 2,372.72 780 / 3,508 24.00 / 40.80 1.395
Configuration Peak occupied GiB PUT GiB State in PUT GiB GET GiB Eviction batches Uncached input tokens
8 PRs · off 1,075.01 896.12 637.50 68.54 0 30,252,405
8 PRs · on 1,216.54 1,864.62 1,564.40 217.42 7 30,902,668
9 PRs · KEEP=2 · off 729.18 1,232.30 948.76 155.48 0 26,135,071
9 PRs · KEEP=2 · on 724.25 1,214.44 932.81 276.87 0 26,847,733
9 PRs · KEEP=1 · off 686.89 1,154.31 877.13 98.75 0 28,225,744
9 PRs · KEEP=2 · off · MTP5 752.46 1,295.27 1,002.93 137.56 0 26,489,214

Each replay uses one cold 1,800-second Weka 256K window, seed 20260707, eight H200s, TP1/DP8/EP8, BF16 KV and sticky least-loaded routing. SLO goodput counts requests with TTFT ≤3 s and per-user output ≥40 tok/s. Store peak is whole-pool allocated memory sampled about every two seconds. PUT and GET sum successful transfers during scoring and drain. Uncached input tokens include both new input and repeated input that required computation.

C120 uses FlashMLA, 48,000 KV blocks/rank, DP prefill period 4 and a 1,280 GiB Store. The baseline includes #5186, #5187, #5212, #5216, #5221, #5222, #5223 and #5224 (44eab704). For the nine-PR measurements we added #5211 at 43962b92 to the same stack (9606bd50). These windows predate the subsequent merge of upstream main at 06c6d224.

C70 on the QA deployment

The November 11 QA report recorded 1.25 RPS, 1,206.72 decode tok/s, TTFT p50 997.50 ms and 0.6978 SLO goodput (2,297 completions, 55.9% attainment). TPOT percentiles and Store bytes were unavailable in that report.

The three replays use the documented QA image at a0102d47, router 0.0.9, MTP5, BF16 KV and 1,024 GiB of RDMA Store (128 GiB/rank). The deployment guide enables both local decode options. Only the third replay applies #5211 to that runtime. The QA report gives no full client command or seed.

Effect of the local decode flags. On the stock QA image, turning both off changed RPS by +0.51%. In the same pair, decode throughput fell 2.35% and SLO goodput rose 3.78%. Peak Store occupancy fell 44.98% and cumulative PUT volume fell 53.44%.

Effect of #5211 at C70. With both local decode options off, decode throughput rose 8.10% and SLO goodput rose 14.01%. Peak Store occupancy fell 36.58% and cumulative PUT volume rose 33.01%. RPS changed by +4.79% and TTFT p95 fell from 3,454 to 2,816 ms. Uncached input changed from 15,063,516 to 13,083,143 tokens. Each setting had one formal window.

Configuration Completed / errors RPS Decode tok/s TTFT p50 / p95 (ms) TPOT p50 / p95 (ms) SLO goodput (req/s)
QA baseline · local on 2,139 / 0 1.162 1,178.98 927 / 3,487 19.47 / 65.99 0.733
QA baseline · local off 2,150 / 0 1.168 1,151.26 927 / 3,454 18.68 / 71.76 0.760
QA + #5211 · 4K/KEEP=2 · local off 2,253 / 0 1.224 1,244.55 854 / 2,816 18.08 / 46.57 0.867
Configuration Peak occupied GiB PUT GiB State in PUT GiB GET GiB Eviction batches Uncached input tokens
QA baseline · local on 972.23 918.00 767.97 11.36 2 15,091,011
QA baseline · local off 534.93 427.45 295.59 5.07 0 15,063,516
QA + #5211 · 4K/KEEP=2 · local off 339.28 568.55 420.14 38.47 0 13,083,143

Choosing the interval, cap and MTP depth

  • 4K spacing. In an earlier prefill-only implementation, 4K and 8K spacing gave similar C120 goodput (1.325 vs 1.323 req/s). Across 4,792 shared turns with equal output lengths, 4K reduced the lower bound on repeated input from 2.78M to 2.24M tokens. Peak Store rose from 798.83 to 844.03 GiB. That experiment used a different implementation from the unified grid above.
  • KEEP=2 versus KEEP=1. On the current MTP3 stack with both local options off, keeping a second grid point reduced uncached input by 2.09M tokens, raised SLO goodput 14.07% and cost 42.29 GiB more peak Store. This is the measured reason to use two points for this workload.
  • KEEP=2 versus unlimited. A matched pair on the earlier unified-grid revision measured 733.50 vs 1,215.78 GiB peak Store and zero vs six eviction batches. KEEP=2 delivered 0.81% less decode throughput and 4.87% less SLO goodput. The current spelling for unlimited retention is KEEP=-1.
  • MTP5 versus MTP3. At 4K/KEEP=2 with both local options off, changing only the draft depth raised decode throughput 4.11%, RPS 4.18% and SLO goodput 17.65%. TTFT p50 rose from 753 to 780 ms and peak Store rose by 23.27 GiB.

Validation

  • On the benchmarked PR runtime, 1,207 GPU regression tests passed for decode checkpointing, compact scheduling, paging and the KV connector. Coverage includes KEEP values of -1, 0, 1 and 2, short inputs, cancellation, failed or late writes, and shared prefixes.
  • A cross-rank decode test recovered a confirmed decode checkpoint with both local decode flags off and verified reclamation of the older prefill grid point.
  • In a 12-pair cross-rank replay, consumers diverged at token 25,000 of a 26,001-token prompt. With the grid disabled, median reuse was 0 tokens and consumer p50 was 2,096.2 ms. At 4K/KEEP=2, median reuse reached 24,576 tokens and p50 fell to 316.8 ms (84.9% lower). Each request generated one token.
  • After merging main at 06c6d224, the focused CPU-accessible suite passed 676 tests (9 CUDA skips). It covers the joint Store key formats and the interaction between pending-write limits and ordinary checkpoint reservations. Ruff passed for the changed Python files.
  • The request tracing and rolling registry suites passed together (138 tests). Repository-wide pre-commit hooks and the 70% docstring coverage check also passed locally.
  • On PR head e5b250f0, the expanded GPU regression suite passed 1,895 tests with 0 skipped.

@silencelamb silencelamb changed the title perf(pytorch): publish intermediate prefill checkpoints to Mooncake Store perf(pytorch): support rolling Mooncake prefill checkpoints Dec 2, 2026
@silencelamb silencelamb changed the title perf(pytorch): support rolling Mooncake prefill checkpoints perf(pytorch): use a shared rolling checkpoint grid for Mooncake Store Dec 2, 2026
@silencelamb silencelamb changed the title perf(pytorch): use a shared rolling checkpoint grid for Mooncake Store perf(pytorch): add rolling Mooncake checkpoints across prefill and decode Dec 3, 2026
@silencelamb
silencelamb requested review from RunningLeon and caikun-pjlab and removed request for RunningLeon December 3, 2026 11:01

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant