[Scheduler] Soften Long Prefill Tokens Threshhold (#57951)

Signed-off-by: Robert Shaw <robertgshaw2@gmail.com>
Signed-off-by: Robert Shaw <robshaw@redhat.com>
Co-authored-by: Robert Shaw <robshaw@redhat.com>
This commit is contained in:
Robert Shaw
2026-09-21 17:19:42 -07:00
committed by GitHub
co-authored by Robert Shaw
parent 78d7836525
commit c64b15cde5
5 changed files with 52 additions and 11 deletions
+4 -1
View File
@@ -79,7 +79,10 @@ class SchedulerConfig:
long_prefill_token_threshold: int = Field(default=0, ge=0)
"""For chunked prefill, a request is considered long if the prompt is
longer than this number of tokens. 0 disables the cap (default)."""
longer than this number of tokens. 0 disables the cap (default).
The cap is not applied when the request is the only one in the batch,
since there is no other request for it to starve."""
max_num_queued_reqs: int | None = Field(default=None, ge=0)
"""Maximum number of requests that can be in-flight (waiting or running)
+13 -5
View File
@@ -599,6 +599,15 @@ class Scheduler(SchedulerInterface):
throttle_prefills and not self.prefill_capacity_bound
) and any(not r.is_prefill_chunk for r in self.running)
# `long_prefill_token_threshold` exists to stop a long prefill from
# starving other requests of the token budget. When it is the only
# request there is nobody to starve, so let it use the whole budget.
long_prefill_token_threshold = (
self.scheduler_config.long_prefill_token_threshold
if len(self.running) + len(self.waiting) + len(self.skipped_waiting) > 1
else 0
)
# First, schedule the RUNNING requests.
req_index = 0
while req_index < len(self.running) and token_budget > 0:
@@ -650,8 +659,8 @@ class Scheduler(SchedulerInterface):
+ request.num_output_placeholders
- request.num_computed_tokens
)
if 0 < self.scheduler_config.long_prefill_token_threshold < num_new_tokens:
num_new_tokens = self.scheduler_config.long_prefill_token_threshold
if 0 < long_prefill_token_threshold < num_new_tokens:
num_new_tokens = long_prefill_token_threshold
num_new_tokens = min(
num_new_tokens, token_budget, input_budget - draft_slots
)
@@ -1090,9 +1099,8 @@ class Scheduler(SchedulerInterface):
num_new_tokens = padded_num_tokens
pad_spec_decode = True
threshold = self.scheduler_config.long_prefill_token_threshold
if 0 < threshold < num_new_tokens:
num_new_tokens = threshold
if 0 < long_prefill_token_threshold < num_new_tokens:
num_new_tokens = long_prefill_token_threshold
# chunked prefill has to be enabled explicitly to allow
# pooling requests to be chunked