[APIServer][BugFix] Fix gunicorn fork deadlock and multi-dp pipe issue in get_save_output_v1 - #8088
Conversation
…re is only one worker
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #8088 +/- ##
==========================================
Coverage ? 67.49%
==========================================
Files ? 475
Lines ? 66919
Branches ? 10321
==========================================
Hits ? 45169
Misses ? 18870
Partials ? 2880
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 22:26:38
📋 Review 摘要
PR 概述:修复 OpenAI APIServer 单 worker 启动路径,并调整 get_save_output_v1 在多 DP 下的 ZMQ 消费。
变更范围:fastdeploy/entrypoints/openai/、fastdeploy/output/、fastdeploy/worker/、tests/entrypoints/
影响面 Tag:[APIServer] [DataProcessor] [XPU] [Metax]
问题
未发现新的非历史阻塞性问题。
历史 Findings 修复情况
| Finding | 问题 | 状态 |
|---|---|---|
| F1 | 单 worker 分支需要同步更新 launcher 单测 | ✅ 已修复 |
| F2 | Gunicorn 多 worker 退出时误清理共享 LLMEngine 子服务 | |
| F3 | XPU DP×TP 多个 TP rank 输出推到同一个 DP socket | |
| F4 | 单 worker Uvicorn 路径未继承 --timeout-graceful-shutdown |
📝 PR 规范检查
已修复。当前 PR 描述已补充 Motivation、Modifications、Usage or Command、Accuracy Tests 等实质内容,历史模板占位问题已不再存在。
总体评价
本轮未发现新的可定位代码问题。需要注意的是,三个历史问题仍能从当前代码中复现:多 worker 生命周期清理仍无 worker 数量保护,XPU DP×TP 的 get_save_output_v1 socket 命名/发送关系仍未修正,单 worker uvicorn.run 仍未传入 graceful shutdown 超时参数。
CI报告基于以下代码生成(30分钟更新一次): 1 Required任务 : 8/10 通过
2 失败详情🔴 Run FastDeploy Unit Tests and Coverage / run_tests_with_coverage — PR问题(置信度: 高)分析器: 通用分析(fallback)
关键日志:
PR 新增的同步 shutdown 分支 修复建议:
关联变更: 🔴 Approval — 环境问题(置信度: 高)该 Job 需要人工 Approval,完成审批后 CI 才会继续执行。
修复建议:
关联变更: 无 |
|
Thanks for your contribution! |
Motivation
This PR fixes two issues related to process forking in the API server:
workers=1, gunicorn still forks a worker process, which can cause deadlock due to inherited resources (e.g., zmq sockets, CUDA contexts) not being fork-safe. When there is only one worker, uvicorn should be used directly to avoid the fork entirely.get_save_output_v1: Non-rank-0 token_processors skip receiving from their zmq pipes under multi-DP, causing pipes to block or lose data.Modifications
fastdeploy/entrypoints/openai/api_server.py:StandaloneApplication(gunicorn) whenworkers > 1, useuvicorn.rundirectly whenworkers == 1, avoiding unnecessary fork that can lead to deadlock.llm_engine._exit_sub_services()call in thelifespanshutdown path for the non-async branch, ensuring sub-services exit properly in sync mode.fastdeploy/output/token_processor.py:rank_id-based conditional check inget_save_output_v1, so that all token_processors receive and process data from their respective zmq pipes regardless of rank, ensuring pipes are properly consumed in multi-DP scenarios.Usage or Command
No extra configuration needed. Single-worker deployments will automatically use uvicorn instead of gunicorn.
Accuracy Tests
This PR does not modify model computation logic and does not affect accuracy.
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.