Repository navigation
Conversation
Contributor
|
Documentation preview: https://vllm--66705.org.readthedocs.build/en/66705/ |
Contributor
|
This pull request has merge conflicts that must be resolved before it can be |
Add `--scheduling-policy shortest_prefill_first`. Before each scheduling step it looks at the first 64 waiting requests and moves the one with the fewest prompt tokens not in the prefix cache to the front. Preempted requests rank ahead of all others and arrival time breaks ties; the rest of the queue keeps arrival order, and preemption is the same as FCFS. The admission logic is ported from vllm-torchtpu's PrefixAwareScheduler (Copyright 2026 Google LLC, Apache-2.0), with its tests. It runs as a policy of the default scheduler instead of an AsyncScheduler subclass, and reads the skip-prefix-cache flag through Request.get_prefix_cache_hit_limit(). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: wzhao18 <wzhao18.sz@gmail.com>
…_first Add KVConnectorBase_V1.get_known_num_matched_tokens, a side-effect-free hint of the external cache's known prefix hit, implemented by MooncakeStoreConnector (reads a finished lookup, never submits one) and MultiConnector. The policy now ranks by tokens in neither the local nor the known external cache. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: wzhao18 <wzhao18.sz@gmail.com>
wzhao18
force-pushed
the
wzhao/shortest-prefill-first
branch
from
November 11, 2026 04:28
69cc8ab to
61b2467
Compare
…emaining prefill Replace the single-request promotion with a per-step ordering of every scheduler queue. Requests whose remaining prefill length is known are sorted shortest first among the positions they already hold: running prefill chunks and KV-holding requests by tokens not yet computed, and waiting requests whose KV connector lookup has finished (including a hit of 0) by tokens not in that hit. Requests with an unknown length (decodes, waiting requests with no or an unfinished lookup, external reads skipped) keep their exact positions. Nothing else changes: budget, chunking, lookups, loads, allocation and preemption run as under fcfs. The local prefix-cache lookup per waiting request is dropped, so the policy adds no cache or connector lookups. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: wzhao18 <wzhao18.sz@gmail.com>
This branch has not been deployed
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.
Overview
Adds
--scheduling-policy shortest_prefill_first. Before each scheduling step, requests whose remaining prefill length is known are ordered shortest first within each scheduler queue. Nothing else in the scheduler changes: token budget, chunking, KV connector lookups and loads, block allocation and preemption all run as underfcfs.The target is prefill instances serving multi-turn, prefix-heavy traffic (e.g. agentic coding with an external KV cache tier such as Mooncake), where uncached tokens per request are heavy-tailed and a few long prefills ahead in the queue set the TTFT of many short ones.
Ordering rules
Key: remaining prefill tokens, smallest first; ties keep their current order.
runningkv_holding_waitingwaiting,async_kv_waiting(first 64)A request whose remaining length is not known keeps its exact position: a decode, a waiting request with no or an unfinished external lookup, or one that skips external KV reads. Known requests are permuted only among the positions they already hold, so nothing moves past an unordered request. Without a KV connector, the waiting queues keep arrival order and only the running and KV-holding queues are ordered.
Requests with an unknown external hit are deliberately not ranked by their local hit: on an external-cache-heavy workload the local hit is a small part of the true hit, so they would sort to the back, and since their lookup is submitted only when the admission loop reaches them, they could stay unknown.
External hits are read with a new optional connector hook,
get_known_num_matched_tokens, which returns the prefix the external cache is already known to hold, orNone. It must not start a lookup or change state.MooncakeStoreConnectorreturns the hit of an already finished lookup (LookupKeyClient.peek),MultiConnectorthe largest of its connectors', and other connectorsNone.Costs and side effects
fcfsandpriorityare unchanged. Cache-aware admission ([Core] Add cache-aware admission ordering #54625) staysfcfs-only.Validation
tests/v1/core/test_shortest_prefill_first.py: running prefills ordered and decodes in place; KV-holding queue ordered; waiting requests with known hits (including 0) ordered among their own positions while unknown andskip_reading_external_kvrequests keep theirs; a full hit still counts its last token; stable ties; no connector leaves waiting untouched; the 64-request window.tests/v1/core/test_scheduler.py::test_shortest_prefill_first_policy_runs_shortest_prefill_first: with two running prefills and a budget that cannot cover both chunks,shortest_prefill_firstgives the budget to the one with fewer tokens left first,fcfsto the earlier one.tests/v1/kv_connector/unit/test_mooncake_store_lookup.py::test_peek_reads_finished_lookup_without_side_effects:peekreturnsNonebefore and during a lookup and the hit once it finishes, without submitting, consuming or expiring it.On a Linux CPU node (
VLLM_TARGET_DEVICE=cpu): the SPF, Mooncake lookup and the two policy tests intest_scheduler.pypass (21 tests). The fulltest_scheduler.pygives 230 passed / 67 failed both with and without this change, with the same 67 failures (environment-dependent tests, e.g. diffusion and CPU-encoder paths).E2E (Kimi K3.1, GB300, disaggregated P/D with Mooncake, AgentX agentic trace, 60 min): pending.
Pull Request Checklist
I used vLLM's
/pr-checklistskill. (Mandatory for agents, optional for humans).AI assistance was used during the creation of this PR.
Design Fit: Minimizes impact on core components, reuses existing functionality, and justifies added complexity.
Testing and Validation: Validates the change and ensures any added tests are meaningful and reliable, with CI coverage or documented CI resource constraints and validation performed outside CI.
Code Quality and Style: Keeps code and comments clear and concise, and updates relevant documentation and examples.
Pull Request Contents: Includes a brief summary and relevant links, supports claims with evidence, explains root causes and implementation trade-offs, and follows the contributing guide.
🤖 Generated with Claude Code