feat: add configurable prefill queue scheduling - #1591
Open
hiworldwzj wants to merge 2 commits into
Open
hiworldwzj wants to merge 2 commits into
hiworldwzj wants to merge 2 commits into
Conversation
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.
Summary
This PR adds configurable prefill-queue scheduling before compute-token and KV-cache allocation, with three policies:
default: preserve the existing FCFS behavior while honoring internal inference priority.promote_shortest: keep high-priority requests first, then promote the shortest normal prefill request without disturbing the relative order of the remaining requests.hrrn: order normal prefill requests with token-based Highest Response Ratio Next (HRRN) aging.It also separates router admission priority from inference-side scheduling priority, refines PD continuation handling, changes busy-node retry to opt-in, and adds documentation and focused tests.
Scheduling behavior
Decode requests are identified with the same rules used by request classification. They remain at the front of the queue in stable order and are not reordered by prefill policies.
defaultinfer_high_priority; equal-priority requests remain FCFS.promote_shortesthrrnThe HRRN score is based on processed prefill work rather than wall-clock time:
Implementation details:
InferReqsnapshots the backend's processed-prefill-token counter when it is constructed.max(1, input_len - cur_kv_len).prefill_need_token_numcalls.PD priority and retry behavior
high_priority_requestremains the router/shared-memory admission-priority flag.infer_high_priorityis an internal inference-side field; external requests cannot set it.segment_index > 0) receive elevated inference priority. The first segment is not promoted merely because it has a cache hit.LIGHTLLM_PD_NODE_BUSY_RETRY_TIMEOUT_SECONDSnow defaults to0, so busy-node retries are disabled unless a positive timeout is configured explicitly.Motivation and expected impact
promote_shortestis intended primarily for PD-disaggregated Prefill nodes. It can improve time to first token for short prompts with a deliberately limited queue reorder.hrrnfavors requests with small uncached service cost while token-based aging allows long-waiting requests to overtake newly arrived short work, reducing starvation risk.Documentation
Validation
Completed locally:
blackflake8py_compilegit diff --checkThe current development environment does not include
pytest, so the relevant test functions were executed directly with a lightweight harness.