Skip to content

[BugFix] Fix bugs in /v1/abort_requests interface from PR(#6992)#7176

Open
qwes5s5 wants to merge 3 commits intoPaddlePaddle:developfrom
qwes5s5:abort_requests_fix
Open

[BugFix] Fix bugs in /v1/abort_requests interface from PR(#6992)#7176
qwes5s5 wants to merge 3 commits intoPaddlePaddle:developfrom
qwes5s5:abort_requests_fix

Conversation

@qwes5s5
Copy link
Copy Markdown
Collaborator

@qwes5s5 qwes5s5 commented Apr 3, 2026

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)

It was discovered that PR(#6992) introduced bugs that may trigger 500 errors or finish_reason validation failures when using multimodal or completions interfaces.

Modifications

Modified finish_reason to include the "abort" value.

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.

@paddle-bot
Copy link
Copy Markdown

paddle-bot bot commented Apr 3, 2026

Thanks for your contribution!

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 3, 2026

Codecov Report

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

Files with missing lines Patch % Lines
fastdeploy/engine/common_engine.py 50.00% 3 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             develop    #7176   +/-   ##
==========================================
  Coverage           ?   74.39%           
==========================================
  Files              ?      383           
  Lines              ?    53629           
  Branches           ?     8414           
==========================================
  Hits               ?    39898           
  Misses             ?    11012           
  Partials           ?     2719           
Flag Coverage Δ
GPU 74.39% <73.33%> (?)

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

☔ View full report in Codecov by Sentry.
📢 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.

@qwes5s5 qwes5s5 requested a review from Jiang-Jia-Jun April 9, 2026 07:25
PaddlePaddle-bot

This comment was marked as outdated.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

该 PR 用于修复 PR(#6992) 引入的 /v1/abort_requests 相关问题,避免在多模态/Completion 场景下触发 500 或 OpenAI 协议 finish_reason 校验失败,并补强 abort 清理路径的健壮性。

Changes:

  • 扩展 OpenAI 协议响应的 finish_reason 枚举,加入 "abort" 以通过校验。
  • 优化 abort 等待/清理逻辑:对已结束请求做过滤与集合清理,并在资源回收时清理 abort 相关集合,避免残留导致异常。
  • 更新/修复相关单测,使其与新的过滤逻辑一致。

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
tests/engine/test_common_engine.py 调整 _wait_abort_complete 相关用例,补齐 requests 字典以匹配新过滤逻辑
fastdeploy/entrypoints/openai/protocol.py finish_reason 增加 "abort",修复协议校验失败
fastdeploy/engine/sched/resource_manager_v1.py abort/finish 回收路径使用 discard 并补充清理 abort 集合
fastdeploy/engine/common_engine.py _wait_abort_complete 增强:过滤已结束目标并清理 abort 集合,降低卡住/500 风险

Comment thread fastdeploy/engine/common_engine.py
Comment thread fastdeploy/entrypoints/openai/protocol.py
PaddlePaddle-bot

This comment was marked as outdated.

Jiang-Jia-Jun
Jiang-Jia-Jun previously approved these changes Apr 14, 2026
Copy link
Copy Markdown

@PaddlePaddle-bot PaddlePaddle-bot left a comment

Choose a reason for hiding this comment

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

📋 Review 摘要

PR 概述:修复 PR #6992 引入的 /v1/abort_requests 接口 bug
变更范围:common_engine.py、resource_manager_v1.py、protocol.py、test_common_engine.py
影响面 Tag[Engine] [APIServer]

📝 PR 规范检查

PR 标题和描述均符合规范。

问题

级别 文件 概述
🔴 Bug fastdeploy/entrypoints/openai/v1/serving_base.py _calc_finish_reason 方法未处理 abort 情况

总体评价

PR 的主要修复点都是合理的

  • 修改 eos_token_ids 获取方式,从 self.data_processor.eos_token_ids[0] 改为 getattr(request, "eos_token_ids", [0]),避免了对 data_processor 的依赖,更加健壮
  • _wait_abort_complete 中添加已完成请求的清理逻辑,避免等待已完成的请求
  • remove() 改为 discard(),避免 KeyError,这是正确的修改
  • finish_requests 中添加对 abort 相关集合的清理
  • protocol.py 中添加 "abort" 到 finish_reason 类型定义
  • 测试文件中添加必要的 mock 请求对象

但存在一个相关问题(不在本次 PR 变更范围内,但与 PR 目标相关)

fastdeploy/entrypoints/openai/v1/serving_base.py 中的 _calc_finish_reason 方法(第 213-223 行)没有处理 abort 情况。当 request_output.error_msg 包含 "Aborted" 时(在 _control_abort_requests 中设置为 error_msg="Aborted"),finish_reason 不会被正确设置为 "abort",而是保持默认的 "stop"。这与 protocol.py 中已添加的 "abort" 类型不一致。

对比旧版本的 serving_chat.pyserving_completion.py,它们都通过检查 error_msg 是否包含 "Aborted" 来设置 finish_reason = "abort"。v1 版本的 serving 代码使用 _calc_finish_reason 方法,但没有处理这个情况,这可能是导致 PR #6992 中提到的 "finish_reason validation failures" 的原因之一。

建议后续 PR 修复 serving_base.py 中的 _calc_finish_reason 方法,添加 abort 处理逻辑。

@qwes5s5 qwes5s5 requested a review from Jiang-Jia-Jun April 17, 2026 03:11
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.

5 participants