[Cherry-Pick][Optimization] merge matmul and add(#6986) #7184
[Cherry-Pick][Optimization] merge matmul and add(#6986) #7184BingooYang wants to merge 1 commit intoPaddlePaddle:release/2.5from
Conversation
|
Thanks for your contribution! |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## release/2.5 #7184 +/- ##
==============================================
Coverage ? 69.48%
==============================================
Files ? 390
Lines ? 54362
Branches ? 8570
==============================================
Hits ? 37771
Misses ? 13862
Partials ? 2729
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:
|
fastdeploy-bot
left a comment
There was a problem hiding this comment.
🤖 AI Code Review |
2026-04-03 17:30 CST
📋 Review 摘要
PR 概述:将 UnquantizedLinearMethod.apply() 中的 matmul + add 替换为 paddle.nn.functional.linear,优化带 bias 场景的计算性能
变更范围:model_executor/layers/linear.py(核心优化)、tests/e2e/utils/(测试 baseline 路径更新)
影响面 Tag:OP
问题
| 级别 | 文件 | 概述 |
|---|---|---|
| 🟡 建议 | rollout_routing_replay_test_utils.py:160 |
baseline 路径硬编码日期 0403,建议语义化命名 |
总体评价
核心优化逻辑正确,新增的 bias 维度 assert 检查增强了代码健壮性。测试文件的 baseline 路径变更建议改用更语义化的版本命名方式。
| if model_path: | ||
| baseline_path = os.path.join(model_path, f"R3_BaseLine_25_uint8/routing_replay_output_baseline_{model_name}") | ||
| baseline_path = os.path.join( | ||
| model_path, f"R3_BaseLine_dev_uint8_0403/routing_replay_output_baseline_{model_name}" |
There was a problem hiding this comment.
🟡 建议 baseline 路径中硬编码了日期 0403。
这种命名方式可能导致未来维护困难:
- 每次更新 baseline 都需要修改代码中的路径
- 日期含义不够清晰,
dev_uint8_0403中的0403指的是什么不明确
建议:
- 使用更语义化的版本命名,如
R3_BaseLine_v2.5_uint8 - 或者将 baseline 路径配置化,通过环境变量或配置文件管理
Motivation
性能优化
Modifications
将UnquantizedLinearMethod中的matmul和add用linear替换。

带bias情况基本上有加速,不带bias情况小shape下性能有下降(主要是python层if等调度开销,linear内部实现也是matmul)。
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.