Repository navigation
feat: add round-robin scheduling for chunked PD prefill - #26
Conversation
| enable_chunked_prefill_round_robin: A[ | ||
| bool, | ||
| "Round-robin chunked prefill for non-overlap PD prefill (TP8, page size 64).", | ||
| ] = False |
There was a problem hiding this comment.
Perhaps it should be placed below chunked_prefill_size?
| @@ -68,6 +68,7 @@ class SchedulerInvariantChecker: | |||
| # The chunked-prefill request parked between chunks is in neither batch; | |||
| # its uncached tokens must still be counted. | |||
| get_chunked_req: Callable = field(default=lambda: None) | |||
| get_rr_requests: Callable = field(default=lambda: ()) | |||
There was a problem hiding this comment.
rr maybe means round_robin? Need better varaible name or left comments here.
|
|
||
| supported = ( | ||
| get_disagg().disaggregation_mode == "prefill" | ||
| and not self.enable_overlap |
There was a problem hiding this comment.
[P0] why not suppot enable overlap?It should be enable unless set --disable-overlap-scheduler, which shouldn't be set since it can introduce CPU overhead.
58dcacc to
2ab413c
Compare
| if not self.enable_overlap: | ||
| if ( | ||
| not self.enable_overlap | ||
| or self.enable_chunked_prefill_round_robin |
There was a problem hiding this comment.
Why need this here? it makes the logic completly complex than it should be. it seems the whole diffs for source_transfers is caused by here.
Maybe can just change it back and only retry the not success bootstrap req like without round-robin prefill scheduling. So the code should be much clean.
| @@ -1194,7 +1266,11 @@ def process_prefill_chunk( | |||
| elif self.has_bootstrapped_waiting_req(): | |||
| # optimistic request yields to waiting requests | |||
| self.chunked_req = None | |||
| if not self.enable_overlap: | |||
| if not self.enable_overlap or ( | |||
| self.enable_chunked_prefill_round_robin | |||
There was a problem hiding this comment.
I still wonder why make enable_chunked_prefill_round_robin to behave different from merely enable_overlap.
| @@ -507,7 +510,7 @@ def set_buf(self, req: Req): | |||
| top_logprobs_len = len(req.logprob.output_top_logprobs_val[0]) | |||
| max_top_logprobs_len = self.output_top_logprobs_val.shape[1] | |||
| if top_logprobs_len > max_top_logprobs_len: | |||
| raise RuntimeError( | |||
| raise InvalidDisaggregationMetadata( | |||
| @@ -539,7 +542,7 @@ def set_buf(self, req: Req): | |||
| mask_len = len(sampling_mask) | |||
| max_mask_len = self.output_token_sampling_mask_idx.shape[1] | |||
| if mask_len > max_mask_len: | |||
| raise RuntimeError( | |||
| raise InvalidDisaggregationMetadata( | |||
There was a problem hiding this comment.
The same. Not introduce new InvalidDisaggregationMetadata
| @@ -333,7 +338,7 @@ def __init__( | |||
| hidden_size: int, | |||
| hidden_states_dtype: torch.dtype, | |||
| max_sampling_mask_tokens: int, | |||
| max_top_logprobs_num: int = 128, | |||
| max_top_logprobs_num: int = MAX_DISAGGREGATION_TOP_LOGPROBS, | |||
There was a problem hiding this comment.
no need here. Just maintain 128 and the comment below.
| @@ -563,6 +567,8 @@ def resolve_waiting_queue_bootstrap(self: Scheduler) -> None: | |||
| failed = set() | |||
| for req, poll in zip(candidates, polls): | |||
| if poll == KVPoll.Failed: | |||
| if not self.enable_overlap: | |||
There was a problem hiding this comment.
maybe need enable round robin prefill scheduling?
|
Under a mixed workload of approximately 8k-token requests at 3 QPS and 80k-token requests at 0.1 QPS, each generating 512 tokens, the round-robin run showed substantially lower TTFT than the baseline. The dashboard’s time-averaged p50, p90, and p99 TTFT values decreased from 8.79 s to 428 ms, 15.4 s to 756 ms, and 19.8 s to 1.16 s, respectively—approximately 95%, 95%, and 94% reductions. Average prefill queue depth also dropped from 6.44 to 0.067. These observations are consistent with reduced blocking of short requests by long prefills; attributing the full improvement to scheduling requires matching cache state, deployment settings, and measurement windows between runs. |
This reverts commit bcfddbfb9be1aa3ca2025722932c85f9f7ddc3ee.
3afda06 to
f208483
Compare
* feat: add round-robin scheduling for chunked PD prefill * fix: relax round-robin TP and page size restrictions * refactor: clarify round-robin names and group prefill options * feat: support overlap and DSPARK in chunked prefill round robin * test: consolidate core prefill round-robin regressions * refactor: reuse native overlap prefill retry flow * refactor: reuse Mooncake transfer drain accounting for prefill abort * refactor: route round-robin client abort through prefill retirement * refactor: restore native transfer handling for prefill round robin * test: simplify prefill round-robin test helpers * refactor: preserve native overlap bootstrap retry behavior * fix: gate bootstrap detachment on prefill round robin * fix: skip prefill sequence reset when round robin is disabled * perf: batch queue removal for failed prefill bootstrap requests * Revert "perf: batch queue removal for failed prefill bootstrap requests" This reverts commit bcfddbfb9be1aa3ca2025722932c85f9f7ddc3ee. * refactor: batch prefill ready queue removal * fix: validate required prefill round robin configuration * fix: handle prefill resume rejection, paused aborts and suspended timeouts * fix: read resolved disaggregation config during prefill initialization * fix: complete round robin abort tracing and cache cleanup --------- Co-authored-by: yifei she <[email protected]>


Summary
Long requests can occupy consecutive prefill chunks, delaying shorter requests. Add optional round-robin scheduling between chunks so other ready requests can make progress.
--enable-chunked-prefill-round-robin(disabled by default).Based on
online_base_0914(75a9980f84). The rebase preserves the base branch's arrival-token accounting on the retry path. Design documents are excluded.Supported configurations
PD prefill with PP1, one attention TP group, FCFS without priority scheduling, fixed chunks, and an independent paged full-KV allocator. Both non-overlap and overlap scheduling are supported; overlap requires Mooncake or the fake transfer backend. Speculation is supported for DSPARK only. TP size and page size are not hardcoded.
Startup validation excludes LoRA, DLLM, PDMux, dynamic/mixed chunks, hybrid SWA, unified memory, and MLX overlap.
Validation
test/manual/chunked_prefill/test_prefill_round_robin.py: 14 passing CPU checks covering FIFO rotation, a single unfinished chunk per batch, KV/row pressure, reservation accounting, disabled behavior, cancellation, deferred retry, and source-transfer release ordering.Run the core checks with Python 3.10+:
CI States
Latest PR Test (Base): ❌ Run #35104878866
Latest PR Test (Extra): ❌ Run #35104878395
Latest PR Test (AMD ROCm 10): ➖ No AMD PR run found for this commit.