[Docs][BugFix] fix mla log#7243
Conversation
|
Thanks for your contribution! |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #7243 +/- ##
==========================================
Coverage ? 73.88%
==========================================
Files ? 383
Lines ? 53510
Branches ? 8377
==========================================
Hits ? 39537
Misses ? 11207
Partials ? 2766
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:
|
|
/skip-ci all for only logger change~ |
EmmonsCurse
left a comment
There was a problem hiding this comment.
LGTM~ Skip check for Docs.
PaddlePaddle-bot
left a comment
There was a problem hiding this comment.
🤖 AI Code Review |
2026-04-13 12:17 CST
📋 Review 摘要
PR 概述:修改 MLA attention backend 的日志格式(参数化 → f-string)
变更范围:model_executor/layers/attention/
影响面 Tag:[OP]
📝 PR 规范检查
| 检查项 | 问题 |
|---|---|
| 标题 Tag | 使用了 [Docs] tag,但此 PR 修改的是代码日志格式,非文档变更 |
| Motivation | 仅写 "fix mla log",未说明为何需要修改日志格式 |
| Modifications | 未填写 |
标题建议(可直接复制):
[BugFix][OP] 优化 MLA attention 日志格式
描述模板(可直接复制):
## Motivation
将 logger.warning 从参数化格式改为 f-string 格式,[请说明原因]
## Modifications
- 修改 `mla_attention_backend.py` 中的日志格式
问题
| 级别 | 文件 | 概述 |
|---|---|---|
| 🟡 建议 | mla_attention_backend.py:279-282 |
使用 f-string 替代参数化日志,会降低性能 |
总体评价
此变更将日志从参数化格式改为 f-string 格式,属于性能回退:
- 参数化日志
logger.warning("val=%d", val)在日志级别不匹配时(如 INFO 级别运行)会跳过字符串格式化,性能更优 - f-string 始终执行字符串拼接,即使日志不会被输出
建议:恢复参数化格式,或说明为何必须使用 f-string(如需要更复杂的格式化逻辑)。
| @@ -277,10 +277,8 @@ def __init__( | |||
| self.padding_num_heads = 64 - self.num_heads | |||
| self.heads_need_padding = True | |||
| logger.warning( | |||
There was a problem hiding this comment.
🟡 建议 使用 f-string 替代参数化日志会降低性能。
原因:
logger.warning("format %d", val)- 参数化格式,日志级别不匹配时跳过格式化,性能更优logger.warning(f"format {val}")- f-string 始终执行字符串拼接
建议修复方式:
恢复参数化格式,或说明为何必须使用 f-string。
logger.warning(
"MLA num_attention_heads is less than 64, force to use 64 num_heads. "
"current num_heads=%d, tp_size=%d",
self.num_heads,
fd_config.parallel_config.tensor_parallel_size,
)
Motivation
fix mla log
Modifications
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.