Closed
omitted range disables every gradient copy #8068
MetastarxAdd on 9 days agoClosed at 3 days ago
周云飞
9 days ago Comments:
9 days ago Comments:
按您描述的调用路径,省略 rangeOptional 后范围变成 [0, 0),确实没有索引能通过范围检查,可能导致 token 和概率梯度均为零。相关算子实现和省略范围时的预期语义仍需确认。
一个可行的处理方向是在 Init 中为未提供范围的情况设置覆盖有效索引的默认范围,同时保留显式传入范围时的行为;具体上界需结合索引含义和输入形状确认。我们会继续分析这一问题。


4 days ago Assign yu-xinjie62、liuguoyue、azyuli as responsible person
4 days ago Removed responsible person yu-xinjie62
3 days ago Associated pull request
azyuli
3 days ago Comments:
3 days ago Comments:
Thanks for reporting this!
- For direct op/tiling calls where the
rangeattribute is absent (rangePtr == nullptr), PR !15613 (commit36d2c8261) already updated theelsebranch inInit()to fall back to[0, sorted_indices.dim(0)). - For
aclnnMoeTokenPermuteWithEpGradcalls,moe_token_permute_with_ep_grad_def.cppdefinesAttr("range").AttrType(OPTIONAL).ListInt({0, 0}), so passingrangeOptional = nullptrpasses[0, 0](an empty interval[0, 0)) by default, producing all-zero gradients without ignoringprobs, and an empty length-0 array is rejected. - To keep the interface documentation consistent with this behavior, we have submitted PR !17196 updating
aclnnMoeTokenPermuteWithEpGrad.md,aclnnMoeTokenPermuteWithEpGrad_en.md,README.md, andREADME_en.mdto explicitly document the[0, 0]default fornullptrin aclnn calls and recommend passing[0, sortedIndices.numel]explicitly (or callingaclnnMoeTokenPermuteGrad) when the full range is needed.


3 days ago Close issue
3 days ago changed custom state from 待办的 to 已完成
周云飞
3 days ago Comments:
3 days ago Comments:
PR #17196 更新了 aclnnMoeTokenPermuteWithEpGrad 的中英文接口文档和 README,明确:
rangeOptional仅支持长度为 2 的整型数组,不支持空数组。- 传入空指针时默认范围为
[0, 0),梯度输出全 0,且不会忽略概率梯度相关参数。 - 如需处理全量
sortedIndices,应显式传入[0, sortedIndices.numel],或使用aclnnMoeTokenPermuteGrad。
本次是文档说明修正,未修改算子代码或改变默认行为。
关联 PR:PR #17196


2 days ago Added label: resolved
The call path Tiling4MoeTokenPermuteWithEpGrad (line 438) -> PermuteWithEpGradTilingCompute (line 405) -> Init (line 177) sets param.input.start and param.input.end both to 0 when rangeOptional is absent (lines 214-216). SetTilingData stores those values at lines 344-350. The kernel then only reads input data when an index satisfies start <= index < end: CalPartOutToken checks this at lines 287-301, and CopyProbIn performs the same check at lines 443-463. With the normal non-negative sorted_indices values, no index can satisfy index >= 0 && index < 0, so the token path duplicates zero and writes it at CopyOut (line 326), while the probability path also produces zero. Valid calls that omit rangeOptional therefore return zero gradients instead of processing the full sorted_indices range.