Supports Sonicmoe bf16 z and wgrad, optimize sonicmoe performance#1348
Conversation
PaddleFleet Log Analysis
日志分析报告PR #1348 | branch:
失败的测试case: 根本原因分析: 本 PR ( 修复建议:
🔄 每次 Re-run 后自动更新 |
ed6e8ab to
04d3c80
Compare
df6e058 to
3f1cb5b
Compare
| if self.sonic_moe_config.enabled is True and self.need_quant_weight(): | ||
| self.quant_weight() |
There was a problem hiding this comment.
这里把 FP8 权重量化缓存的刷新条件收窄成只看 need_quant_weight(),训练中第一次 forward 后 weight.fp8 / weight.transposed_fp8 会一直存在;优化器更新 BF16 参数后,下一步 run_sonic_moe(..., use_fp8=True) 仍会使用旧缓存,实际参与训练的专家权重会落后一轮。当前 SonicMoEExpert.step() 只做 layout flush,没有清空这些缓存。请在训练态重新量化,或接入明确的 optimizer-step 缓存失效/版本检查,并补一个包含 optimizer.step() 后第二次 FP8 forward 的回归测试。一个保守的本地修复是:
| if self.sonic_moe_config.enabled is True and self.need_quant_weight(): | |
| self.quant_weight() | |
| if self.sonic_moe_config.enabled is True and ( | |
| self.training or self.need_quant_weight() | |
| ): | |
| self.quant_weight() |
| dispatched_indices = ( | ||
| self.token_dispatcher._comm_manager.dispatched_indices | ||
| ) | ||
| dispatched_probs = self.token_dispatcher._comm_manager.dispatched_probs |
There was a problem hiding this comment.
这里绕过了上面 get_dispatched_routing() 的公共返回值,改成无条件读取 self.token_dispatcher._comm_manager;但 moe_token_dispatcher_type="allgather" 初始化的是 AllGatherTokenDispatcher,该类没有 _comm_manager,同时 _validate_allgather_config() 会强制 moe_use_fusion_node=True,所以 EP>1 allgather SonicMoE 会进入 fusion_moe_forward() 并在这里触发 AttributeError。请保留公共 API 返回的 dispatched_indices / dispatched_probs,不要对所有 dispatcher 访问私有 manager。
| dispatched_indices = ( | |
| self.token_dispatcher._comm_manager.dispatched_indices | |
| ) | |
| dispatched_probs = self.token_dispatcher._comm_manager.dispatched_probs | |
| fp8_combine_grad_handle = {} if self.fp8_dispatch_bwd else None |
5a8b125 to
4ababba
Compare
PaddlePaddle-bot
left a comment
There was a problem hiding this comment.
🤖 Paddle-CI-Agent | pr_review |
2026-07-10 20:57:32
📋 Review 摘要
PR 概述:为 SonicMoE 接入 BF16 z/recompute_z、BF16 wgrad 和部分 FP8/metadata 性能优化。
变更范围:src/paddlefleet/transformer/moe/、SonicMoE third-party 子模块和相关单/多卡测试。
影响面 Tag:MoE FP8 Third-Party
问题
未发现新的阻塞性问题。PR 规范问题在下面章节报,不在这里重复。
历史 Findings 修复情况
| Finding | 问题 | 状态 |
|---|---|---|
| F1 | FP8 权重缓存仅在缺失时量化 | |
| F2 | dispatcher 公共结果仍被 _comm_manager 直接读取 |
|
| F3 | weight2.main_grad 布局转换仍被跳过 |
📝 PR 规范检查
标题缺少官方 Tag;描述已包含 checklist §D2 要求的 PR Category、PR Types 和 Description 章节。
标题建议(可直接复制):
[Performance] Support SonicMoE BF16 z/recompute_z and BF16 wgrad
总体评价
本轮按风险优先审查了 SonicMoE 权重布局/FP8 缓存、router-score metadata、combine backward FP8 handle 和新增测试;没有新增行间评论。历史问题仍需在合入前继续处理,尤其是 FP8 权重缓存和 weight2.main_grad 布局。
Codecov Report❌ Patch coverage is
❌ Your patch status has failed because the patch coverage (20.00%) is below the target coverage (90.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## develop #1348 +/- ##
==========================================
Coverage ? 20.00%
==========================================
Files ? 3
Lines ? 85
Branches ? 16
==========================================
Hits ? 17
Misses ? 68
Partials ? 0
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
修改内容只有b卡才能跑 |
PR Category
Performance Optimization
PR Types
Performance
Description
Supoorts high-precision sonicmoe: PFCCLab/supersonic-moe#56, and add config in SonicMoEExpert to set the inside config in sonicmoe.
是否引起精度变化
否