Repository navigation
feat: add configurable prefill queue scheduling - #1591
Conversation
|
在 rebase 后的提交 测试配置:同一块 H100 80GB、Qwen3.5-0.8B、同一个 Jenkins 构建镜像;纯文本,短输入 128 tokens、长输入 16384 tokens,均输出 128 tokens。 每个场景先运行一次完整混合负载预热,再测量三次;每种策略共 864 个测量请求,全部成功。下表为三次测量各项指标的中位数,P95 为每轮请求分布 P95 的中位数。
负载及结果范围:
CI 原始指标、配置、服务日志和实验记录已归档(以下为内部 Jenkins 地址):default #10、promote_shortest #11、HRRN #12。三组均通过 |
|
补充完成多 GPU 混合负载和 PD 详细测试,提交仍为 24组正式实验、320,640个测量请求,全部成功。普通模式6张H100,每个prefill预算用3张卡轮换三种策略并平衡顺序;PD为同机1P1D、NCCL,各预算固定GPU对,P策略改变、D参数固定。Qwen3.5-0.8B纯文本、无MTP,短输入128 tokens、长输入4K/8K/16K,输出128 tokens。 同卡比较核对了镜像、驱动、CPU绑定、模型清单、客户端代码及每轮payload/计划发送时间摘要。任何策略的某轮若与TileLang编译重叠,该卡三策略对应轮次同时排除;原始记录均保留,每卡/场景至少3轮干净配对。以下变化为各卡配对对数比均值换算百分比,95%区间由GPU与负载轮次交叉bootstrap获得,保留共同种子的相关性及编译排除的缺失单元。PD每预算仅一个GPU对,区间主要反映重复负载的不确定性。 代表场景:8K长输入、25%长请求,持续60请求/s、8秒。相对 default 的变化(延迟负值更好,吞吐正值更好):
同场景 HRRN相对promote_shortest 的配对变化与95%区间:
两处代价:
完整六场景还覆盖长请求先到的突发、4K/20请求每秒低负载、16K/120请求每秒过载与短请求占多数。部分突发/低负载指标的区间仍很宽,跨零不表示已证明等价;±5%只作为本次工程参考线。不同预算组硬件/NUMA不同,未把跨预算绝对差异单独归因于预算。普通模式使用token ID列表、PD使用重分词校验精确长度的文本,未直接混比两种模式的绝对性能。 所有原始请求、配置、服务日志、编译标记和统计输入哈希已归档,实验及最终评估均通过 |
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
验证
已 rebase 到 upstream/main
3d9415f44470202b9bd24e9b5b6f32ded726413a,保留原有两个提交。冲突处理中保留 upstream 的整组 shm_req 分配和 stop 参数逻辑,并更新优先级字段、整组分配 mock 和测试导入顺序。CPU 测试:241 项通过,4 项失败。这 4 项在未修改的 upstream/main 上同样复现,分别涉及 full-attention DP 容量,以及 PD 缓存优先级最大年龄、最小 prompt 长度和节点资源等待时间的默认值。
pre-commit(Black、Flake8)与git diff --check通过。本次只做 rebase 和兼容修正,没有新增 GPU 性能测试。