Pull Request has been successfully merged by CANN-robot.
(Thank you for gyl's contribution.)Hi @guyunlong1, welcome to submitting your first PR to CANN!
PR Merge Steps
1. CLA Signing
If the current PR label includes cann-cla/yes, it means you have signed the CLA and can proceed to the next step. If the label includes cann-cla/no, please sign the CLA first. If you have any questions, please refer to the FAQ.
2. CI Check
Please comment /compile to trigger the CI pipeline check. If the CI run is successful, the PR will be tagged with ci-pipeline-passed and you can proceed to the next step. If the CI run fails, the PR will be tagged with ci-pipeline-failed, please check the CI logs to fix the issues in the PR. If you have any questions, please refer to the FAQ.
3. Code Review
After CI passes, please refer to the PR Approval Progress and proactively @ the committers in the table to review the code. After approval, committers will comment /lgtm and /approve. Once the lgtm and approved labels are successfully added, the PR will be merged automatically.
%!(EXTRA string=https://atomgit.com/cann/community/blob/master/en/sig-infrastructure/command.md)


变更摘要
本 PR 针对 MoeTokenUnpermuteWithEp 算子加固 Host 侧输入校验与形状推导:InferShapeForMoeTokenUnpermuteWithEp 与 MoeTokenUnpermuteWithEpInputParamCheck、Init、TilingHiddenSize、TilingToken、SetTilingKey 等环节补充了属性、dtype、维度、range 及平台资源的合法性检查,非法输入统一返回 GRAPH_FAILED,避免静默成功或产生错误 tiling;同时新增独立的 Torch 参考实现并同步更新 UT 期望与文档。
主要改动
- InferShape 输入校验增强:
InferShapeForMoeTokenUnpermuteWithEp新增num_topk范围[1, 512]、permuted_tokens/probs必须为 2D 且非空、sorted_indices必须为 1D 且非空、attrs/out_shape空指针等校验,probs 缺省时输出 dim0 改为len(sorted_indices) / num_topk推导(未知维保持-1)。 - Tiling dtype 与属性门禁: 新增
IsSupportedFloatDtype、DtypeStr、CheckDtypes,限制permuted_tokens/probs仅支持 float32/float16/bfloat16、sorted_indices仅支持 int32;padded_mode仅支持 false,restore_shape必须为空(识别空列表与单元素 0 的等价形式),num_topk上界改为MAX_NUM_TOPK。 - range 与形状一致性校验:
Init中range空时按默认值处理,并校验0 <= start <= end、跨度不超过permuted_tokens第 0 维;同时校验输出 shape 的 dim0/dim1 与num_tokens、hidden_size一致,sorted_indices长度须为num_topk的正整数倍。 - Tiling 流程返回状态化:
Init、TilingHiddenSize、TilingToken、SetTilingKey由void改为返回ge::graphStatus,新增 platform、AIV 核数、UB 容量、tiling 长度非零等检查,UnpermuteWithEpTilingCompute逐级短路返回GRAPH_FAILED;未知 probs dtype 也不再静默继续。 - 测试与文档同步: 新增
tests/assets/moe_token_unpermute_with_ep.py作为独立 Torch Golden(同时注册 kernel 与 ACLNN 两条路径、空 range 视为{0, 0}输出全零),UT 中非法/未知 dtype 用例改为期望GRAPH_FAILED、test_infershape_prob_none_empty_range期望输出改为{1, 2},并更新README.md及中英文接口文档的公式与参数约束说明。
🧩 本次 Review 已使用自定义 Skill:


/lgtm


描述
加固 MoeTokenUnpermuteWithEp 的 Host 侧输入校验与形状推导,避免非法输入静默成功或产生错误 tiling:
len(sorted_indices) / num_topk推导,与 Tiling/文档保持一致。0 <= start <= end且跨度不超过 permuted_tokens 第 0 维)、输出 shape 一致性、platform/UB/AIV/UB 容量与 tiling 长度非零等校验;非法输入统一返回GRAPH_FAILED。tests/assets/moe_token_unpermute_with_ep.py,并同步更新 UT 期望(非法 dtype/未知 dtype 改为期望GRAPH_FAILED,probs 缺省空 range 的 InferShape 输出改为{1, 2})。关联的Issue
测试
文档更新
README.md、docs/aclnnMoeTokenUnpermuteWithEp.md、docs/aclnnMoeTokenUnpermuteWithEp_en.md。类型标签