Skip to content

[Feature] Refactor /v1/abort_requests Endpoint#7615

Open
qwes5s5 wants to merge 1 commit intoPaddlePaddle:developfrom
qwes5s5:refactor_abort_req
Open

[Feature] Refactor /v1/abort_requests Endpoint#7615
qwes5s5 wants to merge 1 commit intoPaddlePaddle:developfrom
qwes5s5:refactor_abort_req

Conversation

@qwes5s5
Copy link
Copy Markdown
Collaborator

@qwes5s5 qwes5s5 commented Apr 24, 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)

Currently, the /v1/abort_requests endpoint is synchronous, blocking the response until all target requests have been processed.

Modifications

Refactor this endpoint to an asynchronous model: it should return a response immediately upon receipt, offloading the actual interruption logic and result handling to the backend engine.

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 24, 2026

Thanks for your contribution!

PaddlePaddle-bot

This comment was marked as outdated.

PaddlePaddle-bot

This comment was marked as outdated.

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.

🤖 AI Code Review | 2026-04-24 20:48:11

📋 Review 摘要

PR 概述:将 /v1/abort_requests 端点从同步阻塞模式重构为异步 fire-and-forget 模式,同时提取 _resolve_abort_targets / _build_abort_results 两个辅助方法,删除 _wait_abort_complete
变更范围entrypoints/(api_server、engine_client、router)、engine/common_engine.pyscheduler/local_scheduler.py
影响面 TagAPIServer Engine Scheduler


问题

级别 文件 概述
🔴 Bug local_scheduler.py:136 ids_read_cursor 在删除末尾元素时越界
🔴 兼容性 api_server.py:500 /v1/abort_requests 响应格式破坏性变更
🟡 建议 engine_client.py:1142 abort_reqs() 无参调用时 engine 侧 KeyError 风险
🟡 建议 router.py:600 _forward_abort 无超时,挂起连接将永驻 _background_tasks

总体评价

重构方向正确,异步化可以避免接口阻塞;response_processors.py 中对空 token_ids 的防御性修复也是必要的。但 _recycle 的游标越界是真实的运行时崩溃风险,响应格式变更会静默破坏现有客户端,需要在合并前处理。

Comment thread fastdeploy/scheduler/local_scheduler.py
Comment thread fastdeploy/entrypoints/openai/api_server.py
Comment thread fastdeploy/entrypoints/engine_client.py
Comment thread fastdeploy/router/router.py
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 16 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (develop@791484a). Learn more about missing BASE report.

Files with missing lines Patch % Lines
fastdeploy/engine/common_engine.py 72.09% 10 Missing and 2 partials ⚠️
fastdeploy/entrypoints/engine_client.py 33.33% 2 Missing ⚠️
fastdeploy/scheduler/local_scheduler.py 50.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             develop    #7615   +/-   ##
==========================================
  Coverage           ?   71.66%           
==========================================
  Files              ?      419           
  Lines              ?    57804           
  Branches           ?     9064           
==========================================
  Hits               ?    41424           
  Misses             ?    13554           
  Partials           ?     2826           
Flag Coverage Δ
GPU 71.66% <75.00%> (?)

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 25, 2026 03:44
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.

3 participants