Pull Request has been successfully merged by CANN-robot.
(Thank you for songyangyang18's contribution.)变更摘要
本 PR 将计算确定性(compute determinism)的设置来源改为跟随 torch_npu,不再新增独立的 determinism_options / JSON 配置项。核心思路是:JIT 编译入口在设置配置时读取 torch_npu.npu._get_deterministic_level(),将 level >= 1 视为确定性开启,并通过新增的 config::SetComputeDeterminism 同步到 C++ 进程级开关;同时将该开关纳入编译 cache hash,确定性 level 变化会触发重编。用户需在首次 @jit 编译前调用 torch_npu.npu.set_deterministic_level(1),C++ UT 则可直接调用 config::SetComputeDeterminism(bool)。
主要改动
- C++ 进程级确定性开关: 在
framework/include/tilefwk/config.h声明、config_manager.cpp实现SetComputeDeterminism(bool)与IsComputeDeterminismEnabled(),并在ConfigStorage中新增computeDeterminism字段(默认false),Reset()时一并复位;该开关为进程级状态,不属于tile_fwk_config配置项。 - Python 侧 torch_npu 状态读取: 在
python/pypto/_utils.py新增is_torch_npu_compute_determinism_enabled(),通过torch_npu.npu._get_deterministic_level()返回值是否>= 1判断确定性是否开启(torch_npu不可用时返回False)。 - JIT 编译入口同步:
entry.py的JitCallableWrapper在_set_config_option中调用pypto_impl.SetComputeDeterminism(...)将确定性开关同步到 C++ 后端,并将其纳入编译 cache hash 计算,确定性 level 变化时缓存失效触发重编。 - Python 绑定: 在
python/src/bindings/controller.cpp中为config::SetComputeDeterminism与config::IsComputeDeterminismEnabled增加 pybind 绑定,供 Python 侧调用。 - 新增单元测试: 新增
python/tests/ut/interface/test_compute_determinism.py,验证torch_npu确定性 level 从 0 切换到 1 再切回 0 时,前端is_torch_npu_compute_determinism_enabled()与后端pypto_impl.IsComputeDeterminismEnabled()状态同步一致。


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 |
|---|---|---|
| framework/src/interface/configs | ✅ tsungl4, gaoxingwang (2/2) | ✅ tsungl4 (1/1) |
| python/pypto/frontend | ✅ tsungl4, gaoxingwang (2/2) | ✅ tsungl4 (1/1) |
| repo-cann/pypto | ✅ tsungl4, gaoxingwang (2/2) | ✅ tsungl4 (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
songyangyang18, thanks for your pull request. All authors of the commits have signed the CLA. 👍


/approve


/lgtm


PyPTO 编码侧的计算确定性需要与 torch_npu 进程级设置保持一致。
前端同步:在 JIT 编译入口读取 torch_npu.npu._get_deterministic_level(),写入已有 global config 项 compute_determinism_level(取值 0/1/2),后端通过 ConfigManagerNg::GetGlobalConfig 读取。
level 含义与 torch_npu 一致:0 关闭,1 仅确定性,2 强一致性。约定进程内 level 固定,不在运行中切换。