Closed
[Bug-Report|缺陷反馈]: MoeTokenUnpermuteWithEpGrad InferShape 将动态维窄化为超大正数 #5805
KaranocaVeAdd on Oct 5Closed at 1 day ago
Oct 5 Associated pull request
weihao18
Oct 5 Comments:
Oct 5 Comments:
/assign @KaranocaVe


Oct 5 Assign KaranocaVe as responsible person
Oct 5 Modify description of issue
周云飞
Oct 17 Comments:
Oct 17 Comments:
感谢提供清晰的复现条件和修复建议。
问题分析
该类型转换确实会丢失动态维信息。InferShape 中的两处赋值分别将 rowIdMapShape 的第 0 维和 unpermutedOutputDShape 的第 1 维存入 uint32_t 变量 inputGradDim0、hiddenSize。当维度值为 -1 时,转换结果为 4294967295,不再保留“维度未知”的含义。这与您报告的输出第 0 维异常一致,动态 hidden 维也存在同样的转换问题。
处理方向
将这两个暂存变量改为 int64_t 是合理的修复方向,可以保留动态维的 -1,同时避免对有符号维度值进行无符号窄化。回归用例应分别覆盖动态 token 维和动态 hidden 维,确认输出对应维度仍为 -1,并保持静态维度推导行为不变。
您提供了关联 PR #13339,并报告 Host tiling 与 InferShape 定向测试 34/34 通过。目前尚未核实该 PR 的具体改动和合入状态;上述测试结果按本次报告记录,不能据此推断设备侧动态 shape 执行已得到验证。


2 days ago Assign liuguoyue、Larry_liuyi、azyuli as responsible person
1 day ago Assign aaaakai as responsible person
1 day ago Associated pull request
1 day ago changed custom state from 进行中 to 已解决
1 day ago Close issue
[Bug-Report|缺陷反馈]: MoeTokenUnpermuteWithEpGrad InferShape 将动态维窄化为超大正数
问题描述
MoeTokenUnpermuteWithEpGrad的 Host InferShape 将 shape getter 返回的有符号维度存入uint32_t。动态维-1因此变成4294967295,使输出 shape 错误。该算子已声明支持动态 shape。重现
使用动态 token 维
[-1, 64]和动态sortedIndices长度-1调用 Host InferShape。输出第 0 维实际为4294967295,而应为-1。动态 hidden 维也覆盖同一窄化路径。影响
错误的输出描述会破坏动态图构建时的 shape 传播。本问题的复现和验证范围是 Host InferShape。
修复与验证
将两个输出维度暂存变量改为
int64_t,并增加动态 token 维和 hidden 维回归用例。修复后 Host tiling 与 InferShape 定向测试 34/34 通过。关联 PR: https://gitcode.com/cann/ops-transformer/merge_requests/13339