已合并
refactor: remove unsupported api interception patches #43782
zhounan创建于 8月5日
refactor: remove unsupported api interception patches #43782
已合并
Pull Request已成功合入, 合并人@ascend-robot
(感谢 zhounan 的贡献)ascend-robot
8月5日 评论:
8月5日 评论:
8月5日 添加了label:stat/needs-squash
8月5日 添加了label:ascend-cla/no
此处折叠了280条消息 查看更多
27 天前 解决了最后一个问题
27 天前 关闭了关联的issue
27 天前 合入了pull request
ascend-robot
27 天前 评论:
27 天前 评论:
Pull Request 已合并或已关闭。
If you want to solve this problem, you can click here to do it in the FAQs.


ascend-robot
27 天前 评论:
27 天前 评论:
流水线 pytorch_gitcode_PR_multiVersion#13973 [ commitID:fc17a48f ] 已完成


【合入来源】
https://gitcode.com/Ascend/pytorch/issues/3682
【修改方案】
移除 torch_npu 对 6 个 PyTorch 模块方法(
nn.Module.share_memory与torch.jit.ScriptModule.add_module / bfloat16 / register_buffer / register_parameter / register_module)的 monkey-patch 拦截机制,并整体删除torch_npu/utils/npu_intercept.py。其中仍被使用的 CANN 包检测逻辑(_cann_package_check()与cann_pytorch_version_map)迁移至torch_npu/_init/registry/registry_manager.py(其唯一调用点所在)。-test/npu/test_unsupport_api.py:删除 6 项*_runtimeerror拦截测试;test_Module_share_memory_runtimeerror改为断言 NPU 上正常执行;test/jit/test_script_module.py:TestScriptModuleShareMemory.test_share_memory_on_npu_raises改为断言 NPU 上正常执行;TestScriptModuleMetadata的 2 项 raise 测试删除。【资料变更】
不涉及
【接口变更】
不涉及
【功能验证】
test/npu/test_unsupport_api.pytest/jit/test_script_module.py(ShareMemory/Metadata 类)candidate 的 9 项失败全部为原拦截 raise 测试:
share_memory/bfloat16:不再抛错(功能可用)——预期行为变更;add_module/register_module:原生 RuntimeError(消息不同);register_parameter/register_buffer:原生 AttributeError(类型不同)。官方用例对照
test_module_share_memory(@onlyPRIVATEUSE1,NPU )test/test_torch.pytest_share_memory(CPU storage shared 语义)test/test_nn.pytest_jit.py中与本修改相关的官方用例全部通过对进行削减的6个api在npu和gpu环境下进行调用,获取其输出结果,观察削减后两个环境中代码运行结果是否一致
npu运行结果 (Ascend 910B4,PyTorch: 2.13.0)
结果说明:这里主要考虑行为的一致,pass/fail仅表示是否会报错,若fail,则看报错信息是否一致。
削减后
cuda运行结果(torch==2.13.0+cu126)
削减后api调用的测试结果与cuda上一致
【CheckList】