已关闭
[Bug-Report|缺陷反馈]: MoeInitRoutingV3算子在部分测试用例中出现精度失败 #3554
wuxiyuan创建于  7月3日关闭于  7月3日
wuxiyuan成员
7月3日 创建

Thanks for sending an issue! Please fill in the following template to help quickly solve your problem.

Describe the current behavior / 问题描述 (Mandatory / 必填)

MoeInitRoutingV3 算子(arch35)在部分测试用例中出现精度失败。

根因分析

moe_v2_gather_static_quant.h 中 floatQueue_ 的 Buffer 初始化大小计算存在缺陷:

  • 原逻辑:AlignBytes(perLoopCols_, sizeof(float)) 直接按 perLoopCols_ 计算,未考虑数据类型 T 的对齐
  • 当 perLoopCols_ 未按 T 类型大小对齐时,分配的 Buffer 空间不足,导致后续计算精度异常

修复方案

在 AlignBytes 之前增加 Align(perLoopCols_, sizeof(T)),确保先按数据类型 T 对齐,再按 float 字节要求对齐:

// 修复前
pipe_->InitBuffer(floatQueue_, 1, AlignBytes(perLoopCols_, sizeof(float)));

// 修复后
pipe_->InitBuffer(floatQueue_, 1, AlignBytes(Align(perLoopCols_, sizeof(T)), sizeof(float)));
### Environment / 环境信息 (Mandatory / 必填)
            
Ascend950
### Steps to reproduce the issue / 重现步骤 (Mandatory / 必填)
            
使用指定用例即可复现
### Describe the expected behavior / 预期结果 (Mandatory / 必填)
            
算子精度PASS
### Related log / screenshot / 日志 / 截图 (Mandatory / 必填)
            
暂无
### Special notes for this issue/备注 (Optional / 选填)
            

likedislike
Wwuxiyuan成员
7月3日 添加了label:bug-report
Wwuxiyuan成员
7月3日 修改了issue 的描述
Wwuxiyuan成员
7月3日 将 wuxiyuan 设为负责人
CANN-robotCANN-robot成员
7月3日 关闭了 issue
CANN-robotCANN-robot成员
7月3日 添加了label:resolved