[BugFix] Fix bugs in /v1/abort_requests interface from PR(#6992)#7176
Conversation
|
Thanks for your contribution! |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #7176 +/- ##
==========================================
Coverage ? 73.90%
==========================================
Files ? 398
Lines ? 55000
Branches ? 8618
==========================================
Hits ? 40649
Misses ? 11632
Partials ? 2719
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
81f06aa to
81239a0
Compare
There was a problem hiding this comment.
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 风险 |
81239a0 to
e9d94e0
Compare
|
日志归属合理 |
PaddlePaddle-bot
left a comment
There was a problem hiding this comment.
🤖 AI Code Review |
2026-04-21 11:57:28
📋 Review 摘要
PR 概述:修复 PR(#6992) 引入的 abort 请求接口 bug,包括 finish_reason 校验失败和潜在 500 错误
变更范围:Engine abort 流程、资源管理器清理逻辑、OpenAI 协议定义
影响面 Tag:Engine Scheduler APIServer
问题
| 级别 | 文件 | 概述 |
|---|---|---|
| 🔴 Bug | common_engine.py:1596 |
getattr 在属性为 None 时不会返回 fallback,仍会触发 TypeError |
详见行内评论。
总体评价
本 PR 的整体修复方向正确:remove → discard 消除 KeyError、finish_reason 新增 "abort" 值、_wait_abort_complete 增加已完成请求的提前退出逻辑,这些都是合理的 bugfix。但 eos_token_ids 的 getattr fallback 存在一个遗留 bug——当属性存在但值为 None 时仍会崩溃,需要修复后才能安全合入。
| engine_recv_first_token_time=request.metrics.engine_recv_first_token_time if request.metrics else now, | ||
| request_start_time=request.metrics.arrival_time if request.metrics else now, | ||
| ) | ||
| eos_token_ids = getattr(request, "eos_token_ids", [0]) |
There was a problem hiding this comment.
🔴 Bug getattr(request, "eos_token_ids", [0]) 在 eos_token_ids 为 None 时不会返回 fallback 值 [0]
Request 类中 eos_token_ids 定义为 Optional[list[int]] = None(request.py:92/149),该属性始终存在但可能为 None。getattr 只在属性不存在时才返回默认值,当属性存在但值为 None 时,getattr 仍然返回 None,后续 eos_token_ids[0] 会触发 TypeError: 'NoneType' object is not subscriptable。
建议修复:
eos_token_ids = getattr(request, "eos_token_ids", None) or [0]或更明确地:
eos_token_ids = request.eos_token_ids if request.eos_token_ids else [0]…e#6992) (PaddlePaddle#7176) * abort api bug fix * bug fix --------- Co-authored-by: Jiang-Jia-Jun <163579578+Jiang-Jia-Jun@users.noreply.github.com>
Motivation
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
[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.