Skip to content

[BugFix]fix chunk_prefill logprobs - #8087

Merged
Jiang-Jia-Jun merged 2 commits into
PaddlePaddle:developfrom
bukejiyu:chunked_prefill_logprobs
Jul 1, 2026
Merged

[BugFix]fix chunk_prefill logprobs#8087
Jiang-Jia-Jun merged 2 commits into
PaddlePaddle:developfrom
bukejiyu:chunked_prefill_logprobs

Conversation

@bukejiyu

@bukejiyu bukejiyu commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

Motivation

💡 If this PR is a Cherry Pick, the PR title needs to follow the format by adding the [Cherry-Pick] label at the very beginning and appending the original PR ID at the end. For example, [Cherry-Pick][CI] Add check trigger and logic(#5191)

💡 如若此PR是Cherry Pick,PR标题需遵循格式,在最开始加上[Cherry-Pick]标签,以及最后面加上原PR ID,例如[Cherry-Pick][CI] Add check trigger and logic(#5191)

修复开启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

  • 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.

PaddlePaddle-bot

This comment was marked as outdated.

@codecov-commenter

codecov-commenter commented Jul 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 33.33333% with 2 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (develop@aa50bd2). Learn more about missing BASE report.

Files with missing lines Patch % Lines
fastdeploy/worker/gpu_model_runner.py 33.33% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             develop    #8087   +/-   ##
==========================================
  Coverage           ?   67.79%           
==========================================
  Files              ?      475           
  Lines              ?    66915           
  Branches           ?    10321           
==========================================
  Hits               ?    45363           
  Misses             ?    18659           
  Partials           ?     2893           
Flag Coverage Δ
GPU 77.85% <33.33%> (?)
XPU 6.95% <0.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@PaddlePaddle-bot PaddlePaddle-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 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.pytests/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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 建议 这个测试把 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

@Jiang-Jia-Jun
Jiang-Jia-Jun merged commit 7d09226 into PaddlePaddle:develop Jul 1, 2026
40 of 43 checks passed
@paddle-bot

paddle-bot Bot commented Jul 14, 2026

Copy link
Copy Markdown

Thanks for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants