[Cherry-Pick][BugFix] Fix clear_parameters hang issue in MTP during weight cleanup in RL (#7522)#7523
Conversation
|
Thanks for your contribution! |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## release/2.6 #7523 +/- ##
==============================================
Coverage ? 73.55%
==============================================
Files ? 376
Lines ? 53033
Branches ? 8288
==============================================
Hits ? 39011
Misses ? 11274
Partials ? 2748
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:
|
2ffb8ec to
d58843f
Compare
PaddlePaddle-bot
left a comment
There was a problem hiding this comment.
🤖 AI Code Review |
2026-04-21 21:05:12
📋 Review 摘要
PR 概述:将 MTP Speculative Decoding 场景中 CUDA Graph 的清理操作移至权重释放之前,修复 RL 场景下的 hang 问题。
变更范围:fastdeploy/worker/gpu_model_runner.py — clear_parameters 方法
影响面 Tag:[Speculative Decoding] [RL]
问题
| 级别 | 文件 | 概述 |
|---|---|---|
| ❓ 疑问 | gpu_model_runner.py:2700 |
proposer.model.clear_graph_opt_backend() 嵌套在 if self.use_cudagraph: 内,当主模型未使用 cudagraph 但 draft model 启用了 cudagraph 时,可能存在资源未释放风险 |
| 🟡 建议 | — | 该 hang 问题缺乏回归测试,建议补充测试用例防止未来回退 |
总体评价
修复思路正确,将 proposer.model.clear_graph_opt_backend() 前移至 clear_parameters() 之前以避免 hang,同时新增 speculative_decoding 和 draft_model_use_cudagraph 条件守卫使逻辑更严谨。建议确认 use_cudagraph 与 draft_model_use_cudagraph 的配置约束关系,以及考虑补充回归测试。
| # Clear CUDAGraph | ||
| if self.use_cudagraph: | ||
| self.model.clear_graph_opt_backend() | ||
| if ( |
There was a problem hiding this comment.
❓ 疑问 proposer.model.clear_graph_opt_backend() 现在嵌套在 if self.use_cudagraph: 块内
原始代码中,MTP 的 proposer.model.clear_graph_opt_backend() 是在 if self.spec_method == SpecMethod.MTP: 条件下单独调用的,与主模型的 use_cudagraph 开关无关。
新代码将其嵌套在 if self.use_cudagraph: 内,意味着当主模型禁用 cudagraph(use_cudagraph=False),但 draft model 独立启用了 cudagraph(draft_model_use_cudagraph=True)时,proposer.model.clear_graph_opt_backend() 将永远不会被调用,可能导致 draft model 的 CUDA graph 资源泄漏。
请确认:draft_model_use_cudagraph=True 是否在设计上一定需要 use_cudagraph=True 才能生效?如果是,建议在配置层面添加约束或断言,使假设显式化。
EmmonsCurse
left a comment
There was a problem hiding this comment.
LGTM~ Skip coverage check as it mainly relies on tests with RL.
Motivation
Cleaning CUDA Graphs after releasing weights may lead to a hang issue.
Modifications
This PR resolves the problem by moving the CUDA Graph cleanup logic in MTP to occur before weight cleanup, preventing hangs observed in RL scenarios.
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.