[BugFix]fix chunk_prefill logprobs - #8087
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #8087 +/- ##
==========================================
Coverage ? 67.79%
==========================================
Files ? 475
Lines ? 66915
Branches ? 10321
==========================================
Hits ? 45363
Misses ? 18659
Partials ? 2893
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
PaddlePaddle-bot
left a comment
There was a problem hiding this comment.
🤖 Paddle-CI-Agent | pr_review |
2026-07-01 17:06:29
📋 Review 摘要
PR 概述:为 GPU prompt logprobs 在 chunked prefill 场景增加 current-step 过滤,避免处理本步未执行的 pending 请求。
变更范围:fastdeploy/worker/gpu_model_runner.py、tests/worker/test_gpu_prompt_logprobs.py
影响面 Tag:[Engine]
问题
| 级别 | 文件 | 概述 |
|---|---|---|
| 🟡 建议 | tests/worker/test_gpu_prompt_logprobs.py:176 |
新测试仍只覆盖当前请求 seq_lens_this_time_cpu > 0 的正常计算分支,未覆盖本次新增的 skip 条件 |
历史 Findings 修复情况
| Finding | 问题 | 状态 |
|---|---|---|
| F1 | GPU prompt logprobs 的 current-step 检查仍使用未随 reorder 对齐的 req_ids.index(req_id) |
|
| F2 | 同构的 XPU/Metax prompt logprobs 路径仍未同步 current-step 过滤 |
📝 PR 规范检查
标题缺少 ] 后的空格,且 PR 描述保留了模板占位内容,未填写 Motivation/Modifications/Usage/Accuracy Tests 的具体内容。
标题建议(可直接复制):
[BugFix] Fix chunked prefill prompt logprobs
PR 描述建议(点击展开,可直接复制)
## Motivation
Fix incorrect prompt logprobs handling in chunked prefill when pending prompt_logprobs requests are not part of the current forward step.
## Modifications
- In `fastdeploy/worker/gpu_model_runner.py::_get_prompt_logprobs_list`, skip prompt_logprobs requests whose request id is not in the current `share_inputs["req_ids"]` or whose `seq_lens_this_time_cpu` is 0.
- This prevents computing prompt logprobs from hidden states of requests that did not run in the current step.
## Usage or Command
N/A
## Accuracy Tests
N/A
## Checklist
- [x] Add at least a tag in the PR title.
- Tag list: [`[FDConfig]`,`[APIServer]`,`[Engine]`, `[Scheduler]`, `[PD Disaggregation]`, `[Executor]`, `[Graph Optimization]`, `[Speculative Decoding]`, `[RL]`, `[Models]`, `[Quantization]`, `[Loader]`, `[OP]`, `[KVCache]`, `[DataProcessor]`, `[BugFix]`, `[Docs]`, `[CI]`, `[Optimization]`, `[Feature]`, `[Benchmark]`, `[Others]`, `[XPU]`, `[HPU]`, `[GCU]`, `[DCU]`, `[Iluvatar]`, `[Metax]`]
- You can add new tags based on the PR content, but the semantics must be clear.
- [ ] Format your code, run `pre-commit` before commit.
- [ ] Add unit tests. Please write the reason in this PR if no unit tests.
- [ ] Provide accuracy results.
- [ ] If the current PR is submitting to the `release` branch, make sure the PR has been submitted to the `develop` branch, then cherry-pick it to the `release` branch with the `[Cherry-Pick]` PR tag.总体评价
当前修改方向对准了 chunked prefill 下 prompt logprobs 的 pending request 问题,但新增测试尚未守住这次修复的跳过分支。历史遗留的 slot 对齐与多硬件同步问题仍未从当前 diff 中看到修复。
| model_runner.share_inputs.cu_seqlens_q = paddle.to_tensor([0, 1, 2, 3], dtype="int32") | ||
| model_runner.share_inputs.req_ids = ["asd1"] | ||
| model_runner.share_inputs.seq_lens_this_time_cpu = paddle.full([1, 1], 0, dtype="int32").pin_memory() | ||
| model_runner.share_inputs.seq_lens_this_time_cpu[0] = 4 |
There was a problem hiding this comment.
🟡 建议 这个测试把 req_ids 设成当前请求并将 seq_lens_this_time_cpu[0] 设为 4,因此仍只走正常计算分支;PR 新增的 idx < 0 / seq_lens_this_time_cpu <= 0 skip 分支没有被验证。
建议补一个用例:在 prompt_logprobs_reqs 中放入一个本轮未执行的请求(req_id 不在 share_inputs["req_ids"],或对应 seq_lens_this_time_cpu 为 0),并断言 _get_prompt_logprobs_list() 不调用 compute_logits、不写入该请求的 in_progress_prompt_logprobs,返回列表保持 None。
|
Thanks for your contribution! |
Motivation
修复开启chunked prefill 跑logprobs 时 异常挂掉的问题
当开启chunk_prefill的时候 同一个req0 可能被分成了 3个chunked [chunked0,chunke1,chunke2]
step=0的时候 调度传来chunked0
step=1的时候 调度传来 chunked1
但是可能在step=2的时候调度并没有传来 chunke2
导致计算prompt logprobs的时候会用 req0的信息和不带req0的 hidden_state
导致计算挂掉
该PR 通过判断 req0对应的槽位index 和 seq_this_time[index] 是否大于0判断
是否存在需要处理的prompt_hidden_state以此来修复切chunked prompt logprob挂掉的问题
Modifications
Usage or Command
Accuracy Tests
Checklist
[FDConfig],[APIServer],[Engine],[Scheduler],[PD Disaggregation],[Executor],[Graph Optimization],[Speculative Decoding],[RL],[Models],[Quantization],[Loader],[OP],[KVCache],[DataProcessor],[BugFix],[Docs],[CI],[Optimization],[Feature],[Benchmark],[Others],[XPU],[HPU],[GCU],[DCU],[Iluvatar],[Metax]]pre-commitbefore commit.releasebranch, make sure the PR has been submitted to thedevelopbranch, then cherry-pick it to thereleasebranch with the[Cherry-Pick]PR tag.