refactor: eliminate DisaggPDChunkedPrefillScheduler.#2017
Open
weizhehuang0827 wants to merge 1 commit into
Open
refactor: eliminate DisaggPDChunkedPrefillScheduler.#2017weizhehuang0827 wants to merge 1 commit into
weizhehuang0827 wants to merge 1 commit into
Conversation
PD + chunked_prefill now goes through DisaggPDScheduler → ContinuousScheduler::prepare_batch() → PrefillFirstPolicy, which schedules chunk_queue (in-flight) before prefill_queue (fresh). This naturally prevents the hold-and-wait deadlock that the deleted class's pd_prefill_footprint_fits gate was designed to solve. - Delete DisaggPDChunkedPrefillScheduler class and all helper functions - Delete DisaggPDScheduler::prepare_batch() override (base handles it) - Update drain_request_queue to skip expand_sequences for PD PREFILL (best_of_n expansion deferred to DECODE instance) - Remove DISAGG_PD_CHUNKED_PREFILL from SchedulerKind enum - Update scheduler_factory to route PD+chunked to DisaggPDScheduler
weizhehuang0827
requested review from
Clement-Wang26,
DongheJin,
DragonFive,
JimHsiung,
Kang-Meng,
RobbieLeung,
XuZhang99,
liujinguang0125,
liutongxuan,
walsonyang,
xiao-yu-chen,
yingxudeng,
yq33victor and
zhang-minchao
as code owners
July 23, 2026 11:10
JimHsiung
approved these changes
Jul 23, 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.
Description
Background
After the scheduler policy refactor (#1992),
DisaggPDChunkedPrefillSchedulerbecame the last scheduler subclass with its ownprepare_batch()that bypasses theSchedulerPolicyabstraction. Its core responsibility was:pd_prefill_footprint_fitsto gate fresh request admission.Both concerns are now handled by the general
PrefillFirstPolicy:PrefillFirstPolicyscheduleschunk_queue(in-flight) beforeprefill_queue(fresh). In-flight requests always get their chunks first → complete → release blocks → fresh can start. A new full-footprint admission gate inschedule_prefill_from_queueprovides additional protection.chunk_queue/prefill_queuenaturally eliminates the need for deferred re-queue — a blocked fresh request inprefill_queuenever starves an in-flight request inchunk_queue.Full-Footprint Admission Gate
Added inside
schedule_prefill_from_queue, gating fresh requests only (kv_cache_tokens_num == 0):reserved_full_footprintis passed by reference from the policy layer, accumulating across bothchunk_queueandprefill_queuescheduling passes.DecodeFirstPolicy, it's initialized withmax_used_blocks * 1.1to reserve margin for decode token generation (reduces preemption frequency).PrefillFirstPolicy, it starts at 0 (no decode on PD PREFILL instance).kv_cache_tokens_num > 0) skip this check — they are already admitted and must be allowed to continue.Other Adaptations
drain_request_queue: Skipexpand_sequencesfor PD PREFILL instances (best_of_n expansion deferred to DECODE instance, preserving the optimization from the deleted class).resolve_batch_mode: PD PREFILL instances always usePrefillFirstPolicy(exclusive batch), regardless ofenable_mix_batchsetting.handle_unschedulable_head: Removedchunk_queue.empty()condition — if a stuck request inchunk_queuecan never complete (footprint > total), it should also be error-reported.record_num_prefix_cache_tokens(): Already present inschedule_prefill_from_queue(line 322), preserving the prefix cache propagation fix from bugfix: propagate prefix cache usage across pd. #2011.What's Deleted
DisaggPDChunkedPrefillSchedulerclassDisaggPDScheduler→ContinuousScheduler::prepare_batch()→PrefillFirstPolicyDisaggPDScheduler::prepare_batch()overrideContinuousScheduler(drain handled bydrain_request_queue)pd_prefill_footprint_fits()schedule_prefill_from_queuepd_prefill_remaining_blocks()pick_pd_chunk_budget()compute_prefill_tokens()alloc_chunk()/match_prefix_blocks()allocate_for_prefill()/allocate_shared_blocks_for()schedule_waiting_prefill()(deferred pattern)schedule_prefill_from_queue(chunk_queue first, then prefill_queue)DISAGG_PD_CHUNKED_PREFILLenumSchedulerKindRelated Issues
Follow-up to #1992 (scheduler policy refactor)
Change Type
Pull Request Checklist
PR Title and Commit Messages
Pre-commit Checks
pre-commit run --all-filespassed.Self Review
Build and Test Coverage
Reviewer Notes
Test Results
Unit tests: 42 PASSED (scheduler_test)
PD Stress Tests (Qwen3-8B, single card, etcd + xllm_service):