Pull Request has been successfully merged by CANN-robot.
(Thank you for LiuChang's contribution.)变更摘要
本 PR 将新 IR 编译管线设为默认行为,彻底移除 new_ir 配置项。此前 pypto.frontend.jit 装饰器与 JitCallableWrapper 通过 new_ir 开关在旧解析路径与 compile_new 之间切换,本次改动删除了该开关及其相关属性,使编译入口统一走 compile_new 管线,并同步清理了仅适用于旧 IR 的测试与相关导入。
主要改动
- 移除
jit装饰器的new_ir参数:pypto.frontend.jit不再接受new_ir参数,同时删除其文档说明及向JitCallableWrapper的传参,外部调用方无法再通过该配置项选择编译管线。 - 简化
JitCallableWrapper编译流程: 删除__init__中的new_ir形参与_use_new_ir属性,并将原方法内的新旧分支合并为直接调用self.compile_new(tensors, tensor_defs),旧的解析、setup_verify_data绑定与 golden data 重置等分支代码被移除。 - 清理旧 IR 相关导入:
entry.py中移除了setup_verify_data的导入,仅保留_pto_verify_datas。 - 更新存量测试的装饰器用法: 多个
python/tests/st下的用例去掉new_ir=True/False参数,统一使用默认编译行为;其中部分分布式测试(如test_allgather_matmul、test_matmul_allreduce_add_rmsnorm、test_moe_distributed_combine、test_allreduce_cascading等)新增@pytest.mark.skip()。 - 删除依赖旧 IR 的测试: 删除
python/tests/ut/interface/test_control_flow_error.py,并从python/tests/ut/interface/test_error.py中移除多个基于new_ir=False的错误场景用例及相应导入。


代码审查
审查结论
发现的问题(共 3 项)
| # | 优先级 | 文件:行 | 标题 |
|---|---|---|---|
| 1 | P1 | python/pypto/frontend/parser/entry.py:40 |
删除 setup_verify_data 导入会打断 interpreter UT 的 monkeypatch |
| 2 | P3 | python/pypto/frontend/parser/entry.py:493 |
compile 固定走 compile_new 后 _create_parser/_parser 成为死代码(可选清理) |
| 3 | P3 | python/tests/ut/interface/test_error.py:20-22 |
依赖 new_ir 的用例被整体删除而非按任务要求 skip(可选改进) |
逐文件审查确认
python/pypto/frontend/parser/entry.py— 有 2 项问题(P1:setup_verify_data导入单边删除导致tests/ut/interpreter/conftest.py:94的monkeypatch.setattr(entry, "setup_verify_data", ...)抛AttributeError,该 fixture 为autouse=True,会让整个 interpreter UT 目录集体 error;P3:compile()旧分支删除后_create_parser与self._parser不可达)。其余改动(new_ir形参/属性移除、jit签名与create_new_logical_tensor保留)经find_references/grep 全仓核验,无遗留new_ir=调用方,未发现破坏性变更。python/tests/st/frontend/test_kernel_reuse.py— no issues(仅去掉new_ir=True;文件内test_new_ir_inplace_reshape_cache_reuse等命名/日志中的 "new_ir" 为描述性文字,非残留 API 用法)。python/tests/st/interface/test_helper_move_loop_carry_new_front.py— no issues(仅去掉装饰器中的new_ir=True)。python/tests/st/operator/distributed/test_allgather_matmul.py— no issues(new_ir=False→(),并按要求对test_allgather_matmul加@pytest.mark.skip())。python/tests/st/operator/distributed/test_matmul_allreduce_add_rmsnorm.py— no issues(两个 kernel 装饰器同步更新,test_matmul_allreduce_add_rmsnorm已 skip)。python/tests/st/operator/distributed/test_moe_distributed_dispatch_combine.py— no issues(两处new_ir=False去除,test_moe_distributed_combine/test_moe_distributed_dispatch_combine均已 skip)。python/tests/st/operator/distributed/test_multi_comm_groups.py— no issues(new_ir=False→(),test_allreduce_cascading已 skip)。python/tests/ut/interface/test_error.py— 有 1 项 P3(删除 7 个错误路径用例,与 Issue 要求的 "skip" 不一致,且其中 contiguous 校验、错误码格式等契约在新 IR 下仍生效,覆盖出现空洞)。- (附带)
python/tests/ut/interface/test_control_flow_error.py整文件删除 — 同属上述 P3 的删除而非 skip 策略问题。
整体风险判断
改动主体是“删除 new_ir 开关、默认走新 IR”的收敛型重构,方向与 Issue #3370 一致,未发现新 IR 路径上的逻辑或安全问题。主要风险集中在 entry.py 第 40 行的单边导入删除:它与未同步修改的 interpreter UT conftest 形成跨文件契约不一致,很可能造成单测套件大面积 error,建议合入前确认。其余为可选的死代码清理与测试保留策略建议,不阻塞合入。
| 类型 | 数量 |
|---|---|
| 🔴 阻塞 | 1 |
| 🟡 建议 | 0 |
⛔ 需要修改


Thanks for your pull-request.
The full list of commands accepted by me can be found at here.
You can get sig-info at here.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.
For more, you also can visit HICANN.
PR Approval Progress
✅ Congratulations! All modules have met the lgtm and approve requirements.
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| python/pypto/frontend | ✅ tsungl4, DCGDDD (2/2) | ✅ tsungl4, DCGDDD (2/1) |
| repo-cann/pypto | ✅ tsungl4, DCGDDD (2/2) | ✅ DCGDDD, tsungl4 (2/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
seu_chang, thanks for your pull request. All authors of the commits have signed the CLA. 👍


compile


| 🚀 CI 流水线已启动 |
|---|
| 📋 执行详情: 点击查看流水线 |


🟠 High Priority
变更点:entry.py 第 40 行由 from pypto.runtime import _pto_verify_datas, setup_verify_data 改为只导入 _pto_verify_datas,模块级符号 setup_verify_data 在 pypto.frontend.parser.entry 中不再存在。
影响契约:python/tests/ut/interpreter/conftest.py:94(未在本 diff 中修改)显式执行
monkeypatch.setattr(entry, "setup_verify_data", setup_verify_data_host),
其中 entry 即 import pypto.frontend.parser.entry as entry(conftest.py:77)。pytest 的 monkeypatch.setattr 默认 raising=True,当目标属性不存在时会抛出 AttributeError。
失败模式:该 fixture 为 autouse=True,属性缺失导致 fixture setup 阶段直接报 AttributeError: <module 'pypto.frontend.parser.entry'> has no attribute 'setup_verify_data',python/tests/ut/interpreter/ 下所有用例集体 error,CI 单测大面积失败(而非仅个别用例失败)。
建议:恢复 from pypto.runtime import _pto_verify_datas, setup_verify_data,或同步修改 python/tests/ut/interpreter/conftest.py:94 使 monkeypatch 目标与 entry 模块实际导出的符号一致。


compile


| 🚀 CI 流水线已启动 |
|---|
| 📋 执行详情: 点击查看流水线 |


compile


| 🚀 CI 流水线已启动 |
|---|
| 📋 执行详情: 点击查看流水线 |


/approve


/lgtm
/approve


The MR can not be merged, because of CodeReview discussion not resolved
If you want to solve this problem, you can click here to do it in the FAQs.


check-pr


默认new-ir , 删除配置项