# TorchNPU

作为Ascend for PyTorch社区的核心组件，TorchNPU是昇腾专为PyTorch打造的深度学习适配框架，使PyTorch框架能够直接调用昇腾NPU，为开发者提供强劲的AI算力支撑。

#### TorchNPU 26.2.X的关键特性

- 支持alltoallvc通信算子，优化alltoall通信性能。
- 支持通信域以  分级建链方式(https://www.hiascend.com/document/detail/zh/Pytorch/2620/devguide/dist/docs/zh/developer_notes/distributed/startup_and_fault_tolerance/torch_npu_run.md)
初始化，性能优化。
- 支持  Inductor基于AscendC IR的自动算子融合(https://www.hiascend.com/document/detail/zh/Pytorch/2620/userguide/torchcompile/docs/zh/user_guide/torch_compile/compilation_backend/inductor.md)
。
- 继承DeviceAllocator，支持在Eager模式下启用  accelerator memory(https://www.hiascend.com/document/detail/zh/Pytorch/2620/apiref/nativeapi/docs/zh/api/native_api/pytorch_2-14-0/torch-accelerator.md)
和  graph(https://www.hiascend.com/document/detail/zh/Pytorch/2620/devguide/NPUGraph/docs/zh/developer_notes/npugraph.md)
相关接口。
- 从本版本起，Inductor后端中的Torch-MLIR编译器已废弃，涉及《Torch.compile》和《环境变量》，具体变更内容请参考  版本配套文档(https://www.hiascend.com/document/detail/zh/Pytorch/2620/releasenote/docs/zh/release_notes.md#版本配套文档)
。
- 从本版本起，基于毕昇编译器提供的编译优化功能已废弃，可以使用  Clang(https://www.hiascend.com/document/detail/zh/Pytorch/2620/installguide/ref/docs/zh/installation_guide/references/building_with_clang.md)
进行替换。


#### 快速上手

TorchNPU概述(https://www.hiascend.com/document/detail/zh/Pytorch/2620/userguide/torchnpuoverview/docs/zh/user_guide/product_overview.md)

版本说明(https://www.hiascend.com/document/detail/zh/Pytorch/2620/releasenote/docs/zh/release_notes.md)

安装(https://www.hiascend.com/developer/software/ai-frameworks/pytorch/download)


#### 查阅TorchNPU文档


**表1 安装指南**

| 安装指南 |
| --- |
| 安装(https://www.hiascend.com/developer/software/ai\-frameworks/pytorch/download) |
| 卸载与升级(https://www.hiascend.com/document/detail/zh/Pytorch/2620/installguide/uninstallupg/docs/zh/installation\_guide/upgrading\_and\_uninstalling.md) |
| 参考(https://www.hiascend.com/document/detail/zh/Pytorch/2620/installguide/ref/docs/zh/installation\_guide/references/building\_from\_source.md) |


**表2 用户指南**

| 用户指南 |
| --- |
| TorchNPU概述(https://www.hiascend.com/document/detail/zh/Pytorch/2620/userguide/torchnpuoverview/docs/zh/user\_guide/product\_overview.md) |
| 快速入门(https://www.hiascend.com/document/detail/zh/Pytorch/2620/userguide/fastexperience/docs/zh/user\_guide/quick\_start.md) |
| Torch.compile(https://www.hiascend.com/document/detail/zh/Pytorch/2620/userguide/torchcompile/docs/zh/user\_guide/torch\_compile/overview.md) |
| 配套软件库(https://www.hiascend.com/document/detail/zh/Pytorch/2620/userguide/SuppLib/docs/zh/user\_guide/libraries.md) |
| 故障处理(https://www.hiascend.com/document/detail/zh/Pytorch/2620/userguide/troubleshooting/docs/zh/user\_guide/troubleshooting/troubleshooting\_process.md) |


**表3 API**

| API |
| --- |
| 原生API(https://www.hiascend.com/document/detail/zh/Pytorch/2620/apiref/nativeapi/docs/zh/api/native\_api/pytorch\_2\-14\-0/overview.md) |
| 自定义API(https://www.hiascend.com/document/detail/zh/Pytorch/2620/apiref/customapi/docs/zh/custom\_APIs/overview.md) |
| 环境变量(https://www.hiascend.com/document/detail/zh/Pytorch/2620/apiref/ENV/docs/zh/api/environment\_variable/env\_variable\_list.md) |


**表4 开发指南**

| 开发指南 |
| --- |
| 内存管理(https://www.hiascend.com/document/detail/zh/Pytorch/2620/devguide/memmgmt/docs/zh/developer\_notes/memory\_management/memory\_resource\_overview.md) |
| 分布式(https://www.hiascend.com/document/detail/zh/Pytorch/2620/devguide/dist/docs/zh/developer\_notes/distributed/distributed\_overview.md) |
| 算子下发(https://www.hiascend.com/document/detail/zh/Pytorch/2620/devguide/opdisp/docs/zh/developer\_notes/operator\_dispatch/automatic\_core\_binding.md) |
| 故障诊断(https://www.hiascend.com/document/detail/zh/Pytorch/2620/devguide/faultdia/docs/zh/developer\_notes/fault\_diagnosis/feature\_value\_detection.md) |
| NPUGraph(https://www.hiascend.com/document/detail/zh/Pytorch/2620/devguide/NPUGraph/docs/zh/developer\_notes/npugraph.md) |
| 自定义算子适配开发(https://www.hiascend.com/document/detail/zh/Pytorch/2620/devguide/Customopadapt/docs/zh/developer\_notes/custom\_operator\_adaptation/opplugin\_operator\_adaptation/adaptation\_overview\_opplugin.md) |
| TorchAir(https://www.hiascend.com/document/detail/zh/Pytorch/2620/devguide/TorchAir/docs/zh/overview.md) |
| 模型迁移调试(https://www.hiascend.com/document/detail/zh/ModelZoo/traditional\_model\_train/PyTorch/docs/zh/migration\_process.md) |
| 模型性能调优(https://www.hiascend.com/document/detail/zh/ModelZoo/traditional\_model\_train/PyTorch/docs/zh/performance\_tuning/performance\_overview.md) |


**表5 参考**

| 参考 |
| --- |
| 昇腾产品形态说明(https://www.hiascend.com/document/detail/zh/Glossary/productform/hardwaredesc\_0001.html) |
| 安全声明(https://www.hiascend.com/document/detail/zh/Pytorch/2620/comref/securityguide/docs/zh/reference/security\_statement.md) |
| 术语(https://www.hiascend.com/document/detail/zh/Glossary/gls/gls\_0001.html) |
