Skip to content

perf(schedule): interleave busy prefill with decode and align admission across DP ranks - #5187

Open
silencelamb wants to merge 7 commits into
InternLM:stack/pr-5186-sm90-megamoefrom
silencelamb:pr/glm53-dp-prefill-alignment
Open

silencelamb wants to merge 7 commits into
InternLM:stack/pr-5186-sm90-megamoefrom
silencelamb:pr/glm53-dp-prefill-alignment

Conversation

@silencelamb

@silencelamb silencelamb commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Scheduling policy

In an MTP3 test, 24 uncached 8K prompts arrived while 32 requests were streaming. The median of the streams’ longest output gaps was 1,810 ms. Capping new prefill work at 4,096 tokens on busy ranks and giving decode or verification a turn between prefills cut that gap to 535 ms.

When ranks admit prefills in different rounds, more collective rounds have to wait for a rank doing prefill. Aligning admission to the existing collective round number (period 2) kept the median gap at 614 ms and let all 24 new requests finish in 2.38–2.54 s, down from 3.20–3.25 s with local interleaving alone. Streaming timeline

Idle ranks can use the full engine prefill budget. This policy supports autoregressive generation, including speculative verification. Starting a dLLM with a positive busy prefill budget raises a configuration error before worker creation. This PR is stacked on #5186 at fb433c7d.

Setting Default Effect
LMDEPLOY_INTERLEAVED_PREFILL_TOKENS 0 (off) Sets the busy-rank prefill budget up to --max-prefill-token-num. Existing multimodal chunk rules can expand a chunk to accommodate an indivisible span.
LMDEPLOY_DP_PREFILL_PERIOD 0 (off) With a positive busy budget and DP > 1, a period of 2 or more aligns admission across ranks. Pending prefill can also proceed after a full period of local decode submissions.

Performance

GLM-5.3-Flash, 8×H200, DP8/EP8/TP1, MTP3. The fixed-length and incremental-stack results below are historical. The three C100 scheduler configurations below were measured on the same commit, d987c93b, before the correctness follow-up.

Fixed input/output. Each request had 8,192 input and 256 output tokens at C64. Throughput is total output tokens divided by total elapsed time across four runs per policy. Latency ranges are across service launches. Methodology and ablations · Reproduction tools and data

Metric Original scheduler Aligned (4,096 tokens, period 2)
Output throughput (tok/s) 1,122.39 1,454.05 (+29.55%)
TTFT P95 (s) 4.78–5.35 5.32–5.43
TPOT P95 (ms) 76.21–80.14 53.55–54.52

AgentX. Weka 256K, seed 20260707, RDMA Mooncake, 1,800 seconds per window. C90 used MegaMoE and FlashKDA on both sides and shows the best observed aligned throughput. At C100 the baseline includes #5186, #5211, #5212 and #5216. Both admission periods use a 4,096-token busy prefill budget.

C Scheduler Output tok/s Completed requests/s TTFT P50 / P95 (ms) TPOT P50 / P95 (ms)
90 Original 1,360.57 1.5815 764 / 3,380 22.87 / 68.45
90 Aligned, period 2 1,479.86 (+8.77%) 1.6679 734 / 3,603 21.75 / 53.21
100 Original 1,640.66 1.8560 730 / 2,554 20.64 / 47.81
100 Aligned, period 2 1,695.13 1.9033 721 / 2,629 20.02 / 45.26
100 Aligned, period 4 1,754.58 (+6.94%) 1.9739 709 / 2,926 19.03 / 33.45

Alignment improved output throughput and TPOT P95 in both workloads. AgentX TTFT P95 increased by 223 ms at C90 and 372 ms at C100 with period 4. C90 deployment · FlashKDA integration · C90 configurations · Raw C90 measurements · Five-PR AgentX report

AgentX C100 on scheduler head d987c93b

Each policy ran once from a cold start on the same unmodified commit and image. We used 8×H200, DP8/EP8/TP1, MTP3, MegaMoE, FlashKDA, and RDMA Mooncake. All windows used the Weka 256K workload, seed 20260707, concurrency 100, 1,800 s injection, an 8,192-token engine budget, 48,000 KV blocks/rank and identical DEBUG logging. The enabled policies used a 4,096-token busy prefill budget.

Scheduler Output tok/s Completed requests/s TTFT p50 / p95 (ms) TPOT p50 / p95 (ms)
Off 1,440.16 1.6554 790.91 / 3,255.97 24.28 / 75.29
Period 2 1,515.28 1.7299 761.40 / 4,002.96 23.22 / 61.14
Period 4 1,675.28 1.8831 748.61 / 4,172.72 21.51 / 38.71

Completed requests/s comes from the client’s request throughput for each scored window, including drain. Rank counts below use the 1,800 s injection interval. The worker on rank zero logs the number of non-dummy prefill ranks after each real collective containing prefill.

Scheduler Prefill rounds Mean prefill ranks/round Even rounds Rounds divisible by 4 1 rank 2 ranks 3 ranks 4 ranks 5 ranks 6 ranks 7 ranks 8 ranks
Off 4,068 1.224 50.9% 25.1% 3340 575 125 24 4 0 0 0
Period 2 5,413 1.430 84.5% 42.1% 3593 1382 376 57 5 0 0 0
Period 4 4,661 1.770 97.8% 97.4% 2308 1428 665 219 32 9 0 0

The per-round CSVs include round number, timestamp, measurement phase, active prefill rank count, and per-rank query-token counts.

Full report · Off rounds · Period 2 rounds · Period 4 rounds

Accuracy and validation

GSM8K on GLM-5.3-Flash FP8 with native experts, scored at b45dad94. All 1,319 questions, five-shot greedy decoding, C32, 1,024 output-token limit. Per-run counts and scoring details

Scheduler Initial accuracy Three follow-up runs
Disabled — 91.74% / 91.66% / 91.58%
Period 2 91.81% 92.34% / 92.57% / 92.27%
Period 4 92.34% 91.51% / 92.49% / 91.89%

At b072bc25, a real-scheduler regression verifies that serving a 64-token tail after a multimodal prefix hit preserves the other request’s 288 pending tokens through its final chunk and transition to decode. Startup tests cover dLLM with the policy disabled and with positive budgets below and equal to a denoising block. The CPU suite passed 755 tests (10 skipped, 32 CUDA cases deselected), and all pre-commit hooks passed. With the policy disabled, the default and chunked-prefill paths each matched the comparison base across 72 replayed scheduling decisions.

@silencelamb
silencelamb force-pushed the pr/glm53-dp-prefill-alignment branch from 0a0ce34 to 6a1b635 Compare November 23, 2026 16:12
@silencelamb
silencelamb changed the base branch from main to stack/pr-5186-sm90-megamoe November 23, 2026 16:13
@silencelamb silencelamb changed the title [Perf] Align busy prefill admission across data-parallel ranks perf(schedule): interleave busy prefill with decode and align admission across DP ranks Nov 30, 2026
@silencelamb
silencelamb marked this pull request as ready for review December 1, 2026 02:43
@yidingcheng0206

Copy link
Copy Markdown
Collaborator

Need real DP timing and performance validation for the current version.
The new tests cover round feedback, idle recovery, and preemption, but collectives, RPC outputs, etc. use stubs, so they cannot demonstrate the alignment behavior under actual asynchronous delivery. The PR also explicitly states that the GPU performance data predates the latest scheduling fix, so the historical gains cannot be directly attributed to the current head.

@silencelamb

silencelamb commented Dec 3, 2026 •

Copy link
Copy Markdown
Collaborator Author

@yidingcheng0206 We measured the same unmodified d987c93b in independent 1,800 s AgentX C100 windows on 8×H200, with the same image, seed and worker logging.

Scheduler Output tok/s Completed requests/s TTFT p50 / p95 (ms) TPOT p50 / p95 (ms)
Off 1,440.16 1.6554 790.91 / 3,255.97 24.28 / 75.29
Period 2 1,515.28 1.7299 761.40 / 4,002.96 23.22 / 61.14
Period 4 1,675.28 1.8831 748.61 / 4,172.72 21.51 / 38.71

Compared with off, period 4 changed output throughput by +16.33%, completed requests/s by +13.76%, TTFT p95 by +916.8 ms and TPOT p95 by -36.58 ms.

Actual rank-zero metadata during injection (Off: 4,068 rounds, 1.224 mean prefill ranks/round; Period 2: 5,413 rounds, 1.430 mean prefill ranks/round; Period 4: 4,661 rounds, 1.770 mean prefill ranks/round). The PR includes the 1–8 rank histogram and the fraction of prefill rounds on each admission phase. Full report · Off rounds · Period 2 rounds · Period 4 rounds

@RunningLeon RunningLeon left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the updated DP measurements. I reran the two scheduling cases on d987c93: both pass on the stacked base and with the policy off, but fail with it enabled.

if len(running) == 1 and maker.long_context_chunker.is_long_context(running[0]):
maker.long_context_chunker.set_seq(running[0])
if len(running) == 1 and maker.long_context_chunker.is_long_context(running[0], self.token_budget):
maker.long_context_chunker.set_seq(running[0], self.token_budget)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With a busy budget of 32, a multimodal prefix hit can leave a 64-token tail that fits in one forward. set_seq replaces the chunker for the already-running request, then clear() drops it: in my scheduler test that request had 288 prompt tokens left and no subsequent forward. Could we use the admission result (kv_token_limit) to identify a non-final chunk before replacing the owner, and test that the original request finishes?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reproduced the lost continuation on d987c93b and fixed it in b072bc25. The input maker now starts a chunk chain only when admission returns a non-final kv_token_limit. A cache-hit tail that fits in one forward goes through normal prefill and leaves the active chunker owner in place.

The regression uses the real prefix trie and scheduler with a busy budget of 32. B reuses a 64-token image prefix and submits its 64-token text tail in one forward. A keeps ownership, submits its remaining 288 tokens in order, and enters decode. Regression test

A separate chunk-sizing behavior predates this PR: an image span already covered by a prefix hit can still enlarge the chunk capacity for the remaining text. We’ll address that separately so cached images no longer expand the text budget and only an indivisible image span that still needs computation can raise the chunk limit. Existing base regression

return None
if not any(seq.status == MessageStatus.RUNNING for seq in self.running_seqs):
return None
return min(budget, self.config.max_prefill_token_num)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With a dLLM block length of 4 and a busy budget of 3, a 12-token prompt produces a 3-token chunk. The unmasker then fails at unflatten(0, (-1, 4)); the same prompt passes with the policy off. Please align the effective budget to whole denoising blocks and reject budgets smaller than one block, or reject this policy for dLLM at startup if it is not supported.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took the startup-rejection option in b072bc25. Interleaved prefill in this PR supports autoregressive models, including speculative verification. Once the host resolves the target model as dLLM, a positive LMDEPLOY_INTERLEAVED_PREFILL_TOKENS raises a ValueError before the executor or workers are created. The error tells the operator to unset the variable or set it to zero.

The regression covers the reported block length 4 / budget 3 case and an aligned budget of 4. Both are rejected because dLLM is outside this policy’s scope. With a zero budget, dLLM startup proceeds, including when a DP period is configured by itself. Startup regression

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.

3 participants