[Optimization] enable trtllm_all_reduce fusion kernel in glm model#6660
Conversation
|
Thanks for your contribution! |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #6660 +/- ##
==========================================
Coverage ? 74.19%
==========================================
Files ? 395
Lines ? 54859
Branches ? 8593
==========================================
Hits ? 40700
Misses ? 11416
Partials ? 2743
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:
|
|
/re-run all-failed |
1 similar comment
|
/re-run all-failed |
e0fd641 to
b314228
Compare
|
/re-run all-failed |
2 similar comments
|
/re-run all-failed |
|
/re-run all-failed |
|
/re-run all-failed |
08d2f16 to
09cb26d
Compare
b7c4a47 to
be78caa
Compare
93fad2c to
912aab4
Compare
PaddlePaddle-bot
left a comment
There was a problem hiding this comment.
🤖 AI Code Review | 2026-04-15
📋 Review 摘要
PR 概述:在 GLM 模型中启用 trtllm_allreduce_fusion 算子以优化性能
变更范围:model_executor/layers/、model_executor/models/glm4_moe.py、config/、engine/
影响面 Tag:[OP] [Models] [Optimization]
发现的问题
| 级别 | 文件 | 概述 |
|---|---|---|
| 🔴 Bug | normalization.py:253 |
fusion 失败时缺少降级机制,会导致运行时崩溃 |
| 🟡 建议 | flashinfer_comm_fusion.py:206 |
cleanup 函数未被调用,可能导致资源泄漏 |
总体评价
PR 实现了 flashinfer allreduce fusion 算子的接入,代码结构清晰,测试覆盖较全面。但存在 fusion 失败时缺少降级机制的问题,可能导致生产环境运行时崩溃。建议修复后再合并。
| norm_out = flashinfer_allreduce_residual_rmsnorm( | ||
| fd_config=self.fd_config, input_tensor=x, residual=residual_input, weight=self.weight, eps=self.eps | ||
| ) | ||
| assert norm_out[0] is not None, "Trtllm-all-reduce fusion failed!" |
There was a problem hiding this comment.
🔴 Bug fusion 失败时缺少降级机制
当 flashinfer 不可用、workspace 初始化失败等情况时,flashinfer_allreduce_residual_rmsnorm 返回 (None, None),但这里会抛出断言错误。这可能导致生产环境运行时崩溃。
建议修改为优雅降级:
elif self.enable_all_reduce_fusion and x.shape[0] <= 2048:
norm_out, residual_out = flashinfer_allreduce_residual_rmsnorm(
fd_config=self.fd_config, input_tensor=x, residual=residual_input, weight=self.weight, eps=self.eps
)
if norm_out is None or residual_out is None:
# Fallback to standard all-reduce + RMSNorm
if is_batch_invariant_mode_enabled():
if residual_input is not None:
x = x + residual_input
norm_out = rms_norm_batch_invariant(x, self.weight, self.eps), x
else:
norm_out = self.norm_func(
x,
norm_weight=self.weight,
norm_bias=None,
epsilon=self.eps,
begin_norm_axis=self.begin_norm_axis,
bias=self.bias,
residual=residual_input,
quant_scale=(-1 if self.quant_scale is None else self.quant_scale),
quant_round_type=self.quant_round_type,
quant_max_bound=self.quant_max_bound,
quant_min_bound=self.quant_min_bound,
)| return norm_out, residual_out | ||
|
|
||
|
|
||
| def cleanup_flashinfer_workspace(): |
There was a problem hiding this comment.
🟡 建议 cleanup 函数未被调用
cleanup_flashinfer_workspace 函数已定义但在生产代码中未调用,可能导致 IPC workspace 资源泄漏。
建议在以下场景调用:
- Worker 进程 shutdown 时
- 模型卸载时
- 配置变更需要重新初始化时
可参考:fastdeploy/worker/worker_process.py 或 engine shutdown 逻辑中添加清理调用。
|
/re-run all-failed |
…addlePaddle#6660) * enable trtllm_all_reduce fusion kernel in glm model * fix conflict * format update * fix a bug * modify test * modify test * support empty tensor and modify test * fix test_linear config issues * modify test name * add edge test case * modify format * fix conflict * modify default max token num in trtllm_allreduce_fusion * add max token num branch for trtllm_allreduce_fusion * fix format * fix rmsnorm config issue * modify 2025 to 2026 * using compat grard * Lazily import flashinfer.comm and fix test config issue * fix test issues * add flashinfer cache dir clean machine * fix some issues
… glm model (#6660) (#7228) * enable trtllm_all_reduce fusion kernel in glm model * update flashinfer paddle version * format update modify test modify test support empty tensor and modify test fix test_linear config issues modify test name add edge test case modify format fix conflict modify default max token num in trtllm_allreduce_fusion add max token num branch for trtllm_allreduce_fusion fix format fix rmsnorm config issue modify 2025 to 2026 enable trtllm_allreduce fusion Revert "[Cherry-Pick][CI] Use GPU-Build-RL runner for _build_linux_rl.yml (#7186) (#7195)" This reverts commit ca2f38b. Revert "[Cherry-Pick][BugFix] prevent requests from entering running state without a slot(#7141) (#7181)" This reverts commit 80f4a72. clean flashinfer cache and modify test fix dumpy patch issue fix some issues * remove redundent * enable moe reduce fusion * fix test * fix cuda context issue * update flashinfer version
Motivation
FD接入trtllm_allreduce_fusion算子
Modifications
Usage or Command
H卡和B卡本地测试均通过
python -m fastdeploy.entrypoints.openai.api_server --model /root/paddlejob/workspace/bingoo/model/GLM-4.5-Air --tensor-parallel-size 4 --port 8185 --max-num-batched-tokens 2048 --enable-flashinfer-allreduce-fusion
Accuracy Tests
python -m paddle.distributed.launch --gpus=0,1 ./FastDeploy/tests/layers/test_rms_allreduce_fusion.py
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.