pytorch:基于 PyTorch 生态的昇腾NPU适配插件项目

Ascend Extension for PyTorch

分支1Tags0
文件最后提交记录最后更新时间
!12588 add test/profiler Merge pull request !12588 from huangyunlong/2.4profile 1 年前
add pull request template 4 年前
!17049 TORCH MAIN SYNC : manylinux_2_28_aarch64 (cxx11_abi=1) Merge pull request !17049 from dilililiwhy/main_sync_20241115 1 年前
support for 3.12 3.13 Co-authored-by: huangyunlong2022<huangyunlong4@h-partners.com> # message auto-generated for no-merge-commit merge: !26309 merge 2.10v into master support for 3.12 3.13 Created-by: huangyunlong2022 Commit-by: huangyunlong2022 Merged-by: ascend-robot Description: <!-- Thanks for sending a pull request! --> **What type of PR is this?** > Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespaces from that line: > > /kind bug > /kind task > /kind feature **What does this PR do / why do we need it**: **Which issue(s) this PR fixes**: <!-- *Automatically closes linked issue when PR is merged. Usage: Fixes #<issue number>, or Fixes (paste link of issue). --> Fixes # **Special notes for your reviewers**: See merge request: Ascend/pytorch!263096 个月前
[Feature]support abi configuration for libtorch_npu. 2 年前
Support registering functions on AutogradPrivateUse1 via YAML dispatch configuration Co-authored-by: shaoyf02<shaoyifan1@huawei.com> # message auto-generated for no-merge-commit merge: merge master_autograd into master Support registering functions on AutogradPrivateUse1 via YAML dispatch configuration Created-by: shaoyf Commit-by: shaoyf02 Merged-by: ascend-robot Description: <!-- Thanks for sending a pull request! --> **What type of PR is this?** > Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespaces from that line: > > /kind bug > /kind task > /kind feature **What does this PR do / why do we need it**: 背景:解决高版本下默认针对没有注册autograd相关key但进行反向的api的告警 方案:通过提供支持添加dispatch字段注册到autogradprivateuse1上,避免出现告警: 例如: ``` - func: npu_moe_token_unpermute_with_routing_map(Tensor permuted_tokens, Tensor sorted_indices, int[] restore_shape, *, Tensor? probs=None, Tensor? routing_map=None, bool drop_and_pad=False) -> Tensor op_api: [v2.1, newest] dispatch: AutogradPrivateUse1: npu_moe_token_unpermute_with_routing_map ``` 具体样例: 添加dispatch前存在告警,添加后无 ``` [W919 12:36:08.793215810 compiler_depend.ts:67] Warning: npu::npu_moe_token_unpermute_with_routing_map: an autograd kernel was not registered to the Autograd key(s) but we are trying to backprop through it. This may lead to silently incorrect behavior. This behavior is deprecated and will be removed in a future version of PyTorch. If your operator is differentiable, please ensure you have registered an autograd kernel to the correct Autograd key (e.g. DispatchKey::Autograd, DispatchKey::CompositeImplicitAutograd). If your operator is not differentiable, or to squash this warning and use the previous behavior, please register torch::CppFunction::makeFallthrough() to DispatchKey::Autograd. (function operator()) ``` **Which issue(s) this PR fixes**: <!-- *Automatically closes linked issue when PR is merged. Usage: Fixes #<issue number>, or Fixes (paste link of issue). --> Fixes # **Special notes for your reviewers**: See merge request: Ascend/pytorch!250358 个月前
!6640 Add api info of pytorch ascend adapter Merge pull request !6640 from 李佳伟/master 2 年前
!15927 delete cpp_extensions examples Merge pull request !15927 from 詹昊/master 1 年前
!23099 add cve info Merge pull request !23099 from 王超/v2.8.0_cve 10 个月前
[bugfix]revert api profiler_trace Co-authored-by: chenweiheng<chenweiheng1@hisilicon.com> # message auto-generated for no-merge-commit merge: !27632 merge master into master [bugfix]revert api profiler_trace Created-by: chenweiheng Commit-by: chenweiheng Merged-by: ascend-robot Description: <!-- Thanks for sending a pull request! --> **What type of PR is this?** > Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespaces from that line: > > /kind bug **What does this PR do / why do we need it**: revert api profiler_trace **Which issue(s) this PR fixes**: <!-- *Automatically closes linked issue when PR is merged. Usage: Fixes #<issue number>, or Fixes (paste link of issue). --> Fixes # None **Special notes for your reviewers**: None See merge request: Ascend/pytorch!276325 个月前
Update op_plugin commit id Co-authored-by: pta-robot<pta_robot@163.com> # message auto-generated for no-merge-commit merge: !27726 merge master into master Update op_plugin commit id Created-by: pta-robot Commit-by: pta-robot Merged-by: ascend-robot Description: Commited by @pta-robot at 2025-12-09 16:02:36. See merge request: Ascend/pytorch!277265 个月前
[master][filght_recorder]add security check Co-authored-by: eveyin1<qianyin2022@hotmail.com> # message auto-generated for no-merge-commit merge: !26043 merge master into master [master][filght_recorder]add security check Created-by: eveyin1 Commit-by: eveyin1 Merged-by: ascend-robot Description: <!-- Thanks for sending a pull request! --> **What type of PR is this?** > Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespaces from that line: > > /kind bug > /kind task > /kind feature **What does this PR do / why do we need it**: **Which issue(s) this PR fixes**: <!-- *Automatically closes linked issue when PR is merged. Usage: Fixes #<issue number>, or Fixes (paste link of issue). --> Fixes # **Special notes for your reviewers**: See merge request: Ascend/pytorch!260437 个月前
[torch-master]修复profiler采集内存流ID数据没有aclrtStreamGetId接口兼容性问题 Co-authored-by: yu-liang-bin<y1416490440@163.com> # message auto-generated for no-merge-commit merge: !27671 merge bug_fix_memory into master [torch-master]修复profiler采集内存流ID数据没有aclrtStreamGetId接口兼容性问题 Created-by: yu_liangbin Commit-by: yu-liang-bin Merged-by: ascend-robot Description: <!-- Thanks for sending a pull request! --> **What type of PR is this?** > Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespaces from that line: > > /kind bug > /kind task > /kind feature **What does this PR do / why do we need it**: profiler采集内存数据时,会通过aclrtStreamGetId接口采集流ID,如果没有这个接口,会打断训练 **Which issue(s) this PR fixes**: 在调用aclrtStreamGetId接口采集流ID数据前增加aclrtStreamGetId接口检查函数 <!-- *Automatically closes linked issue when PR is merged. Usage: Fixes #<issue number>, or Fixes (paste link of issue). --> Fixes # **Special notes for your reviewers**: See merge request: Ascend/pytorch!276715 个月前
!20745 ignore diff in _op_plugin_docs.py Merge pull request !20745 from 姜怡文/main_ig 1 年前
Update torchair (GitCode) Co-authored-by: dilililiwhy<why.wuhuanyu@huawei.com> # message auto-generated for no-merge-commit merge: !26137 merge update_torchair into master Update torchair (GitCode) Created-by: dilililiwhy Commit-by: dilililiwhy Merged-by: ascend-robot Description: <!-- Thanks for sending a pull request! --> **What type of PR is this?** > Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespaces from that line: > > /kind bug > /kind task > /kind feature **What does this PR do / why do we need it**: **Which issue(s) this PR fixes**: <!-- *Automatically closes linked issue when PR is merged. Usage: Fixes #<issue number>, or Fixes (paste link of issue). --> Fixes # **Special notes for your reviewers**: See merge request: Ascend/pytorch!261376 个月前
!23988 add module afd Merge pull request !23988 from 李宁/master 9 个月前
Update URL (gitcode) Co-authored-by: dilililiwhy<why.wuhuanyu@huawei.com> # message auto-generated for no-merge-commit merge: merge update_url into master Update URL (gitcode) Created-by: dilililiwhy Commit-by: dilililiwhy Merged-by: ascend-robot Description: <!-- Thanks for sending a pull request! --> **What type of PR is this?** > Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespaces from that line: > > /kind bug > /kind task > /kind feature **What does this PR do / why do we need it**: **Which issue(s) this PR fixes**: <!-- *Automatically closes linked issue when PR is merged. Usage: Fixes #<issue number>, or Fixes (paste link of issue). --> Fixes # **Special notes for your reviewers**: See merge request: Ascend/pytorch!248438 个月前
!11194 update license and open_source_software Merge pull request !11194 from 郭光浩/master 2 年前
Update URL (gitcode) Co-authored-by: dilililiwhy<why.wuhuanyu@huawei.com> # message auto-generated for no-merge-commit merge: merge update_url into master Update URL (gitcode) Created-by: dilililiwhy Commit-by: dilililiwhy Merged-by: ascend-robot Description: <!-- Thanks for sending a pull request! --> **What type of PR is this?** > Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespaces from that line: > > /kind bug > /kind task > /kind feature **What does this PR do / why do we need it**: **Which issue(s) this PR fixes**: <!-- *Automatically closes linked issue when PR is merged. Usage: Fixes #<issue number>, or Fixes (paste link of issue). --> Fixes # **Special notes for your reviewers**: See merge request: Ascend/pytorch!248438 个月前
update readme Co-authored-by: guoguanghao<guoguanghao@huawei.com> # message auto-generated for no-merge-commit merge: !25927 merge master into master update readme Created-by: guoguanghao Commit-by: guoguanghao Merged-by: ascend-robot Description: <!-- Thanks for sending a pull request! --> **What type of PR is this?** > Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespaces from that line: > > /kind bug > /kind task > /kind feature **What does this PR do / why do we need it**: **Which issue(s) this PR fixes**: <!-- *Automatically closes linked issue when PR is merged. Usage: Fixes #<issue number>, or Fixes (paste link of issue). --> Fixes # **Special notes for your reviewers**: See merge request: Ascend/pytorch!259277 个月前
update readme Co-authored-by: guoguanghao<guoguanghao@huawei.com> # message auto-generated for no-merge-commit merge: !25927 merge master into master update readme Created-by: guoguanghao Commit-by: guoguanghao Merged-by: ascend-robot Description: <!-- Thanks for sending a pull request! --> **What type of PR is this?** > Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespaces from that line: > > /kind bug > /kind task > /kind feature **What does this PR do / why do we need it**: **Which issue(s) this PR fixes**: <!-- *Automatically closes linked issue when PR is merged. Usage: Fixes #<issue number>, or Fixes (paste link of issue). --> Fixes # **Special notes for your reviewers**: See merge request: Ascend/pytorch!259277 个月前
add submodule torch mlir Co-authored-by: lijintao<lijintao14@huawei.com> # message auto-generated for no-merge-commit merge: !25896 merge 11-add-submodule-torch-mlir into master add submodule torch mlir Created-by: gent1e Commit-by: lijintao Merged-by: ascend-robot Description: <!-- Thanks for sending a pull request! --> **What type of PR is this?** > Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespaces from that line: > > /kind bug > /kind task > /kind feature **What does this PR do / why do we need it**: **Which issue(s) this PR fixes**: <!-- *Automatically closes linked issue when PR is merged. Usage: Fixes #<issue number>, or Fixes (paste link of issue). --> Fixes # **Special notes for your reviewers**: See merge request: Ascend/pytorch!258967 个月前
update readme Co-authored-by: guoguanghao<guoguanghao@huawei.com> # message auto-generated for no-merge-commit merge: !25927 merge master into master update readme Created-by: guoguanghao Commit-by: guoguanghao Merged-by: ascend-robot Description: <!-- Thanks for sending a pull request! --> **What type of PR is this?** > Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespaces from that line: > > /kind bug > /kind task > /kind feature **What does this PR do / why do we need it**: **Which issue(s) this PR fixes**: <!-- *Automatically closes linked issue when PR is merged. Usage: Fixes #<issue number>, or Fixes (paste link of issue). --> Fixes # **Special notes for your reviewers**: See merge request: Ascend/pytorch!259277 个月前
!20780 avoid circular dependencies Merge pull request !20780 from huangyunlong/2.7lib 1 年前
!22658 cleancode Merge pull request !22658 from SCh-zx/clm 10 个月前
!9507 Add test cases and fix possible problems with cp in some environments Merge pull request !9507 from shaoyf/doc/master 2 年前
TORCH MAIN SYNC : add update_wrapped_number (bugfix to ForwardADWithScalars) Co-authored-by: dilililiwhy<why.wuhuanyu@huawei.com> # message auto-generated for no-merge-commit merge: !26081 merge main_sync_20251028 into master TORCH MAIN SYNC : add update_wrapped_number (bugfix to ForwardADWithScalars) Created-by: dilililiwhy Commit-by: dilililiwhy Merged-by: ascend-robot Description: <!-- Thanks for sending a pull request! --> **What type of PR is this?** > Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespaces from that line: > > /kind bug > /kind task > /kind feature **What does this PR do / why do we need it**: 2.10.0.dev20251110 **Which issue(s) this PR fixes**: <!-- *Automatically closes linked issue when PR is merged. Usage: Fixes #<issue number>, or Fixes (paste link of issue). --> Fixes # **Special notes for your reviewers**: https://github.com/pytorch/pytorch/issues/160513 https://github.com/pytorch/pytorch/pull/165784 https://github.com/pytorch/pytorch/pull/166657 See merge request: Ascend/pytorch!260816 个月前
Update URL (gitcode) Co-authored-by: dilililiwhy<why.wuhuanyu@huawei.com> # message auto-generated for no-merge-commit merge: merge update_url into master Update URL (gitcode) Created-by: dilililiwhy Commit-by: dilililiwhy Merged-by: ascend-robot Description: <!-- Thanks for sending a pull request! --> **What type of PR is this?** > Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespaces from that line: > > /kind bug > /kind task > /kind feature **What does this PR do / why do we need it**: **Which issue(s) this PR fixes**: <!-- *Automatically closes linked issue when PR is merged. Usage: Fixes #<issue number>, or Fixes (paste link of issue). --> Fixes # **Special notes for your reviewers**: See merge request: Ascend/pytorch!248438 个月前
!24312 lazy setdevice Merge pull request !24312 from huangyunlong/2.9ls 8 个月前
Update to v2.10.0 Co-authored-by: dilililiwhy<why.wuhuanyu@huawei.com> # message auto-generated for no-merge-commit merge: merge main_sync_20250928 into master Update to v2.10.0 Created-by: dilililiwhy Commit-by: dilililiwhy Merged-by: ascend-robot Description: <!-- Thanks for sending a pull request! --> **What type of PR is this?** > Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespaces from that line: > > /kind bug > /kind task > /kind feature **What does this PR do / why do we need it**: update to 2.10.0 (Based on torch-2.10.0.dev20250912) **Which issue(s) this PR fixes**: <!-- *Automatically closes linked issue when PR is merged. Usage: Fixes #<issue number>, or Fixes (paste link of issue). --> Fixes # **Special notes for your reviewers**: See merge request: Ascend/pytorch!253957 个月前

Ascend Extension for PyTorch插件

简介

本项目开发了名为torch_npuAscend Extension for PyTorch插件,使昇腾NPU可以适配PyTorch框架,为使用PyTorch框架的开发者提供昇腾AI处理器的超强算力。

昇腾为基于华为昇腾处理器和软件的行业应用及服务提供全栈AI计算基础设施。您可以通过访问昇腾社区,了解关于昇腾的更多信息。

版本说明

PyTorch与Python版本配套表

PyTorch版本 Python版本
PyTorch1.11.0 Python3.7.x(>=3.7.5), Python3.8.x, Python3.9.x, Python3.10.x
PyTorch2.1.0 Python3.8.x, Python3.9.x, Python3.10.x, Python 3.11.x
PyTorch2.2.0 Python3.8.x, Python3.9.x, Python3.10.x
PyTorch2.3.1 Python3.8.x, Python3.9.x, Python3.10.x, Python 3.11.x
PyTorch2.4.0 Python3.8.x, Python3.9.x, Python3.10.x, Python 3.11.x
PyTorch2.5.1 Python3.9.x, Python3.10.x, Python 3.11.x
PyTorch2.6.0 Python3.9.x, Python3.10.x, Python 3.11.x
PyTorch2.7.1 Python3.9.x, Python3.10.x, Python 3.11.x
PyTorch2.8.0 Python3.9.x, Python3.10.x, Python 3.11.x

昇腾辅助软件

Ascend Extension for PyTorch的分支名称采用{PyTorch版本}-{昇腾版本}命名规则,前者为Ascend Extension for PyTorch匹配的PyTorch版本,后者为Ascend Extension for PyTorch版本号,详细匹配如下:

CANN版本 支持的PyTorch版本 支持的Extension版本 GitCode分支
CANN 8.3.RC1 2.8.0 2.8.0 v2.8.0-7.2.0
2.7.1 2.7.1 v2.7.1-7.2.0
2.6.0 2.6.0.post3 v2.6.0-7.2.0
2.1.0 2.1.0.post17 v2.1.0-7.2.0
CANN 8.2.RC1 2.6.0 2.6.0 v2.6.0-7.1.0
2.5.1 2.5.1.post1 v2.5.1-7.1.0
2.1.0 2.1.0.post13 v2.1.0-7.1.0
CANN 8.1.RC1 2.5.1 2.5.1 v2.5.1-7.0.0
2.4.0 2.4.0.post4 v2.4.0-7.0.0
2.3.1 2.3.1.post6 v2.3.1-7.0.0
2.1.0 2.1.0.post12 v2.1.0-7.0.0
CANN 8.0.0 2.4.0 2.4.0.post2 v2.4.0-6.0.0
2.3.1 2.3.1.post4 v2.3.1-6.0.0
2.1.0 2.1.0.post10 v2.1.0-6.0.0
CANN 8.0.RC3 2.4.0 2.4.0 v2.4.0-6.0.rc3
2.3.1 2.3.1.post2 v2.3.1-6.0.rc3
2.1.0 2.1.0.post8 v2.1.0-6.0.rc3
CANN 8.0.RC2 2.3.1 2.3.1 v2.3.1-6.0.rc2
2.2.0 2.2.0.post2 v2.2.0-6.0.rc2
2.1.0 2.1.0.post6 v2.1.0-6.0.rc2
1.11.0 1.11.0.post14 v1.11.0-6.0.rc2
CANN 8.0.RC1 2.2.0 2.2.0 v2.2.0-6.0.rc1
2.1.0 2.1.0.post4 v2.1.0-6.0.rc1
1.11.0 1.11.0.post11 v1.11.0-6.0.rc1
CANN 7.0.0 2.1.0 2.1.0 v2.1.0-5.0.0
2.0.1 2.0.1.post1 v2.0.1-5.0.0
1.11.0 1.11.0.post8 v1.11.0-5.0.0
CANN 7.0.RC1 2.1.0 2.1.0.rc1 v2.1.0-5.0.rc3
2.0.1 2.0.1 v2.0.1-5.0.rc3
1.11.0 1.11.0.post4 v1.11.0-5.0.rc3
CANN 6.3.RC3.1 1.11.0 1.11.0.post3 v1.11.0-5.0.rc2.2
CANN 6.3.RC3 1.11.0 1.11.0.post2 v1.11.0-5.0.rc2.1
CANN 6.3.RC2 2.0.1 2.0.1.rc1 v2.0.1-5.0.rc2
1.11.0 1.11.0.post1 v1.11.0-5.0.rc2
1.8.1 1.8.1.post2 v1.8.1-5.0.rc2
CANN 6.3.RC1 1.11.0 1.11.0 v1.11.0-5.0.rc1
1.8.1 1.8.1.post1 v1.8.1-5.0.rc1
CANN 6.0.1 1.5.0 1.5.0.post8 v1.5.0-3.0.0
1.8.1 1.8.1 v1.8.1-3.0.0
1.11.0 1.11.0.rc2(beta) v1.11.0-3.0.0
CANN 6.0.RC1 1.5.0 1.5.0.post7 v1.5.0-3.0.rc3
1.8.1 1.8.1.rc3 v1.8.1-3.0.rc3
1.11.0 1.11.0.rc1(beta) v1.11.0-3.0.rc3
CANN 5.1.RC2 1.5.0 1.5.0.post6 v1.5.0-3.0.rc2
1.8.1 1.8.1.rc2 v1.8.1-3.0.rc2
CANN 5.1.RC1 1.5.0 1.5.0.post5 v1.5.0-3.0.rc1
1.8.1 1.8.1.rc1 v1.8.1-3.0.rc1
CANN 5.0.4 1.5.0 1.5.0.post4 2.0.4.tr5
CANN 5.0.3 1.8.1 1.5.0.post3 2.0.3.tr5
CANN 5.0.2 1.5.0 1.5.0.post2 2.0.2.tr5

快速入门

基于CNN模型识别手写数字的脚本,对在GPU上训练的该脚本代码进行修改,使其可以迁移到昇腾NPU上进行训练。具体操作请参见Ascend Extension for PyTorch 快速入门

环境部署

使用二进制文件进行安装

我们为用户提供可以快速安装torch_npu的whl安装包。在安装torch_npu之前,您需要先安装CANN软件。昇腾辅助软件中有更多关于CANN的版本信息。请参考CANN安装指南获取CANN安装包。

  1. 安装PyTorch

    通过 pip 安装 PyTorch。

    aarch64:

    pip3 install torch==2.1.0
    

    x86:

    pip3 install torch==2.1.0+cpu  --index-url https://download.pytorch.org/whl/cpu
    

    若使用pip命令安装失败,请使用下载链接或进入PyTorch官方网站进行查询下载对应版本。

    架构 Python版本 下载链接
    x86 Python3.8 下载链接
    x86 Python3.9 下载链接
    x86 Python3.10 下载链接
    x86 Python3.11 下载链接
    aarch64 Python3.8 下载链接
    aarch64 Python3.9 下载链接
    aarch64 Python3.10 下载链接
    aarch64 Python3.11 下载链接
  2. 安装torch_npu依赖

    运行以下命令安装依赖。

    pip3 install pyyaml
    pip3 install setuptools
    
  3. 安装torch_npu

    pip3 install torch-npu==2.1.0.post17
    

    如需要保存安装日志,可在pip3 install命令后面加上参数 --log <PATH>,并对您指定的目录<PATH>做好权限管控。

使用源代码进行安装

某些特殊场景下,用户可能需要自行编译torch_npu。可以根据昇腾辅助软件表PyTorch与Python版本配套表选择合适的分支。

推荐使用Docker镜像编译torch_npu,可以通过以下步骤获取(建议只挂载工作路径,并避开系统路径,以降低安全风险), 生成的.whl文件路径为./dist/。

须知:
如果不使用镜像,编译时请注意gcc版本遵循如下约束。

  • ARM架构下推荐使用gcc 10.2版本
  • X86架构下推荐使用gcc 9.3.1
  1. 克隆torch_npu代码仓

    git clone https://gitcode.com/ascend/pytorch.git -b v2.1.0-7.2.0 --depth 1
    
  2. 构建镜像

    cd pytorch/ci/docker/{arch} # {arch} for X86 or ARM
    docker build -t manylinux-builder:v1 .
    
  3. 进入Docker容器

    docker run -it -v /{code_path}/pytorch:/home/pytorch manylinux-builder:v1 bash
    # {code_path} is the torch_npu source code path
    
  4. 编译torch_npu

    Python 3.8 为例。

    cd /home/pytorch
    bash ci/build.sh --python=3.8
    

提示

如果想使用新的C++ ABI编译,请首先运行如下命令,此时推荐和社区torch包相同的编译环境:glibc 2.28, gcc 11.2.1。

export _GLIBCXX_USE_CXX11_ABI=1

同时,我们支持使用如下变量配置-fabi-version,要求和社区torch包ABI版本一致

export _ABI_VERSION=16

安装后验证

前提

运行以下命令初始化CANN环境变量。

# Default path, change it if needed.
source /usr/local/Ascend/ascend-toolkit/set_env.sh

快速验证

可以通过以下样例快速体验昇腾NPU

import torch
- import torch_npu # torch_npu2.5.1及以后版本可以不用手动导包

x = torch.randn(2, 2).npu()
y = torch.randn(2, 2).npu()
z = x.mm(y)

print(z)

卸载

Pytorch框架训练环境的卸载可以参考昇腾官方文档

torch_npu的卸载只需执行命令:

pip3 uninstall torch_npu

如需要保存卸载日志,可在pip3 uninstall命令后面加上参数 --log <PATH>,并对您指定的目录<PATH>做好权限管控。

硬件配套

昇腾训练设备包含以下型号,都可作为PyTorch模型的训练环境。

产品系列 产品型号
Atlas 训练系列产品 Atlas 800 训练服务器(型号:9000)
Atlas 800 训练服务器(型号:9010)
Atlas 900 PoD(型号:9000)
Atlas 300T 训练卡(型号:9000)
Atlas 300T Pro 训练卡(型号:9000)
Atlas A2 训练系列产品 Atlas 800T A2 训练服务器
Atlas 900 A2 PoD 集群基础单元
Atlas 200T A2 Box16 异构子框
Atlas A3 训练系列产品 Atlas 800T A3 训练服务器
Atlas 900 A3 SuperPoD 超节点

昇腾推理设备包含以下型号,都可作为大模型的推理环境。

产品系列 产品型号
Atlas 800I A2推理产品 Atlas 800I A2 推理服务器

建议与交流

欢迎大家为社区做贡献。如果有任何疑问或建议,请提交GitCode Issues,我们会尽快回复。感谢您的支持。

分支维护策略

Ascend Extension for PyTorch版本分支的维护阶段如下:

状态 时间 说明
计划 1—3 个月 计划特性
开发 6—12 个月 开发新特性并修复问题,定期发布新版本。针对不同的PyTorch版本采取不同的策略,常规分支的开发周期分别为6个月,长期支持分支的开发周期为12个月
维护 1年/3.5年 常规分支维护1年,长期支持分支维护3.5年。对重大BUG进行修复,不合入新特性,并视BUG的影响发布补丁版本
生命周期终止(EOL) N/A 分支不再接受任何修改

PyTorch版本维护策略

PyTorch版本 维护策略 当前状态 发布时间 后续状态 EOL日期
2.8.0 常规分支 开发 2025/10/15 预计2026/03/15起进入维护状态 -
2.7.1 长期分支 开发 2025/10/15 预计2026/10/15起进入维护状态 -
2.6.0 常规分支 开发 2025/07/25 预计2026/01/25起进入维护状态 -
2.5.1 常规分支 维护 2024/11/08 预计2026/08/08起进入无维护状态 -
2.4.0 常规分支 维护 2024/10/15 预计2026/06/15起进入无维护状态 -
2.3.1 常规分支 维护 2024/06/06 预计2026/06/07起进入无维护状态
2.2.0 常规分支 EOL 2024/04/01 2025/10/14
2.1.0 长期支持 开发 2023/10/15 预计2025/09/15起进入维护状态
2.0.1 常规分支 EOL 2023/7/19 2024/3/14
1.11.0 长期支持 维护 2023/4/19 预计2025/09/10起进入无维护状态
1.8.1 长期支持 EOL 2022/4/10 2023/4/10
1.5.0 长期支持 EOL 2021/7/29 2022/7/29

安全声明

Ascend Extension for PyTorch插件 安全声明

参考文档

有关安装指南、模型迁移和训练/推理教程和API列表等更多详细信息,请参考昇腾社区Ascend Extension for PyTorch

文档名称 文档链接
软件安装指南 参考链接
网络模型迁移和训练 参考链接
算子适配 参考链接
PyTorch原生接口清单 参考链接
Ascend Extension for PyTorch自定义API参考 参考链接

许可证

Ascend Extension for PyTorch插件使用BSD许可证。详见LICENSE文件。