From e4e37b3cda8364fa5ab24376c1be38eee000b970 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=89=87=E5=88=BB=E5=B0=8F=E5=93=A5=E5=93=A5?= Date: Thu, 22 Feb 2024 18:18:52 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=9C=80=E6=96=B0?= =?UTF-8?q?=E7=9A=84=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/2.0/tutorials/intermediate/torchvision_tutorial.md | 4 ---- themes_material | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/docs/2.0/tutorials/intermediate/torchvision_tutorial.md b/docs/2.0/tutorials/intermediate/torchvision_tutorial.md index 6abd812a9..dcdc4a0b6 100755 --- a/docs/2.0/tutorials/intermediate/torchvision_tutorial.md +++ b/docs/2.0/tutorials/intermediate/torchvision_tutorial.md @@ -1,9 +1,5 @@ - - - # TorchVision 对象检测微调教程 [¶](#torchvision-object-detection-finetuning-tutorial "永久链接到此标题") - > 译者:[片刻小哥哥](https://github.com/jiangzhonglian) > > 项目地址: diff --git a/themes_material b/themes_material index 159fc7fe5..dd7faf15e 160000 --- a/themes_material +++ b/themes_material @@ -1 +1 @@ -Subproject commit 159fc7fe5f5d376b48e0624455a72baf360c977e +Subproject commit dd7faf15e340bd0e3d5f7650842b91ad44cb1825 From 9f65a6e62a41fdbce1f3ae07368a191570b4874e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=89=87=E5=88=BB=E5=B0=8F=E5=93=A5=E5=93=A5?= Date: Mon, 29 Apr 2024 17:47:43 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=9C=80=E6=96=B0?= =?UTF-8?q?=E6=8F=92=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes_material | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes_material b/themes_material index dd7faf15e..c75743a3b 160000 --- a/themes_material +++ b/themes_material @@ -1 +1 @@ -Subproject commit dd7faf15e340bd0e3d5f7650842b91ad44cb1825 +Subproject commit c75743a3b7a0613d5e3ba3419668c1d6b3007dd3 From f5a51abd2c737a33ee26bf23b3e7790c4e33a975 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=89=87=E5=88=BB=E5=B0=8F=E5=93=A5=E5=93=A5?= Date: Sun, 5 May 2024 03:22:54 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20PyTorch=20=E6=96=B0?= =?UTF-8?q?=E7=89=B9=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/LatestChanges/PyTorch_V2.0.md | 4 +- docs/LatestChanges/PyTorch_V2.1.md | 150 +++++++++++++++++++++++++++++ docs/LatestChanges/PyTorch_V2.2.md | 92 ++++++++++++++++++ docs/LatestChanges/PyTorch_V2.3.md | 71 ++++++++++++++ mkdocs.yml | 3 + 5 files changed, 318 insertions(+), 2 deletions(-) create mode 100644 docs/LatestChanges/PyTorch_V2.1.md create mode 100644 docs/LatestChanges/PyTorch_V2.2.md create mode 100644 docs/LatestChanges/PyTorch_V2.3.md diff --git a/docs/LatestChanges/PyTorch_V2.0.md b/docs/LatestChanges/PyTorch_V2.0.md index f2581081b..fb55c4ec0 100644 --- a/docs/LatestChanges/PyTorch_V2.0.md +++ b/docs/LatestChanges/PyTorch_V2.0.md @@ -267,12 +267,12 @@ PyTorch [DistributedTensor](https://github.com/pytorch/pytorch/blob/master/torc #### [Prototype] torch.compile(dynamic=True) -此版本提供对具有动态形状的 PT2 编译的实验支持。支持简单模型的电感器推理编译,但有很多限制: +此版本提供对具有动态形状的 PT2 编译的实验支持。支持简单模型的 inductor 推理编译,但有很多限制: * 未来版本中提供训练(这在夜间版本中已部分修复!) * 未来版本中将提供缩小器。 * 无论如何,很容易导致您想要动态的维度变得专门化。其中一些问题在夜间解决了,另一些则没有。 -* 我们没有适当地将电感器防护传播到顶层,这在[#96296](https://github.com/pytorch/pytorch/issues/96296)中进行跟踪。 +* 我们没有适当地将 inductor 防护传播到顶层,这在[#96296](https://github.com/pytorch/pytorch/issues/96296)中进行跟踪。 * 像非零这样的数据相关操作仍然需要图形中断。 * 动态不适用于非标准模式,例如减少开销或最大自动调整。 * Inductor编译存在很多bug。要跟踪已知错误,请检查PyTorch 问题跟踪器上的[动态形状标签。](https://github.com/pytorch/pytorch/issues?q=is%3Aopen+is%3Aissue+label%3A%22module%3A+dynamic+shapes%22) diff --git a/docs/LatestChanges/PyTorch_V2.1.md b/docs/LatestChanges/PyTorch_V2.1.md new file mode 100644 index 000000000..2f6e9d6b5 --- /dev/null +++ b/docs/LatestChanges/PyTorch_V2.1.md @@ -0,0 +1,150 @@ +# 新版本: PyTorch 2.1 版本,automatic dynamic shapes 编译,分布式 checkpoint + +> 发布: 2023年10月04日 +> +> 译者:[@片刻](https://github.com/jiangzhonglian) +> +> 原文: +> +> 翻译: + +**来自 PyTorch团队** + +我们很高兴地宣布PyTorch® 2.1([发布说明](https://github.com/pytorch/pytorch/releases/tag/v2.1.0))的发布!PyTorch 2.1提供automatic dynamic shapes支持intorch*.compile*,*torch.distributed.checkpoint*,用于并行保存/加载多个排名上的分布式训练作业,andtorch*.compile*支持NumPy API。 + +此外,此版本提供了许多性能改进(例如CPU inductor 改进,AVX512支持,scaled-dot-product-attention 支持)以及*torch.export*的原型发布,声音的全图捕获机制,以及基于*torch.export*的量化。 + +除了2.1,我们还发布了PyTorch域库的一系列更新。更多详细信息可以在图书馆更新博客中找到。 + +自2.0以来,此版本由6,682个提交和784个贡献者组成。我们要真诚地感谢我们敬业的社区的贡献。一如既往,我们鼓励您尝试这些,并在我们改进2.1时报告任何问题。有关如何开始使用PyTorch 2系列的更多信息,请访问我们的[入门](https://pytorch.org/get-started/pytorch-2.0/)页面。 + +总结: + +* *torch.compile*现在包括自动支持使用*automatic dynamic shapes*检测和最小化因张量形状变化而导致的重新编译*。* +* *torch.distributed.checkpoint*允许从多个秩并行保存和加载模型,以及由于集群拓扑的变化而重新排序。 +* *torch.compile*现在可以通过将NumPy操作转换为PyTorch等效操作来编译NumPy操作。 +* *torch.compile*现在包括对Python 3.11的改进支持。 +* 新的CPU性能功能包括 inductor 改进(例如bfloat16支持和动态形状)、AVX512内核支持和scaled-dot-product-attention 内核。 +* *torch.export*,一个声音的全图捕获机制被引入为原型功能,以及基于*torch.export*的量化。 +* *torch.sparse*现在包括对NVIDIA® GPU上semi-structed(2:4)稀疏性的原型支持。 + +| **Stable** | **Beta** | **Prototype** | **Performance Improvements** | +| --- | --- | --- | --- | +|   | Automatic Dynamic Shapes | *torch.export()* | AVX512内核支持 | +|   | *torch.distributed.checkpoint* | 基于Torch.export的量化 | scaled-dot-product-attention (SPDA)的CPU优化 | +|   | *torch.compile* + NumPy | semi-structed(2:4)稀疏 | bfloat16的CPU优化 | +|   | *torch.compile* + Python 3.11 | torchinductor 的 *cpp_wrapper* |   | +|   | *torch.compile + autograd.Function* |   |   | +|   | 第三方设备集成:*PrivateUse1* |   |   | + +* 要查看公共2.1、2.0和1.13功能提交的完整列表,请单击[此处](https://docs.google.com/spreadsheets/d/1TzGkWuUMF1yTe88adz1dt2mzbIsZLd3PBasy588VWgk/edit?usp=sharing)。 + +## **测试版功能** + +**[Beta版] Automatic Dynamic Shapes** + +动态形状是*torch.compile*内置的功能,可以通过跟踪和生成基于张量符号形状而不是静态形状的代码来最大限度地减少重新编译(例如*[B,128,4]*而不是*[64,128,4]*)。这允许*torch.compile*生成一个单个内核,该内核可以适用于多种尺寸,但效率成本适中。动态形状在PyTorch 2.1中已大大稳定,如果由于输入形状不同而导致*torch.compile*通知重新编译,现在会自动启用。您可以通过将*dynamic=False*传递给torch.compile或settingtorch*._dynamo.config.automatic_dynamic_shapes = False*来禁用自动动态。 + +在PyTorch 2.1中,我们在CUDA和CPU上在各种模型类型(包括大型语言模型)上启用了动态形状,表现出了良好的性能。 + +有关动态形状的更多信息,请参阅[此文档](https://pytorch.org/docs/2.1/torch.compiler_dynamic_shapes.html)。 + +**[Beta] *torch.distributed.checkpoint*** + +*torch.distributed.checkpoint*能够并行从多个等级保存和加载模型。此外,检查点自动处理跨模型和优化器的完全限定名称(FQN)映射,从而实现跨不同集群拓扑的加载时间重新分级。 + +有关更多信息,请参阅*torch.distributed.checkpoint*[文档](https://pytorch.org/docs/2.1/distributed.checkpoint.html)和[教程](https://pytorch.org/tutorials/recipes/distributed_checkpoint_recipe.html)。 + +**[测试版] *torch.compile* + *NumPy*** + +*torch.compile*现在了解如何通过将NumPy操作转换为PyTorch等效操作来编译它们。由于这种集成以与设备无关的方式运行,您现在只需使用 *torch.compile,*就可以 GPU 加速 NumPy 程序,甚至混合 NumPy/PyTorch 程序。 + +有关 *torch.compile + NumPy 交互*的更多信息,请参阅 *torch.compile* FAQ 中的[此部分](https://pytorch.org/docs/2.1/torch.compiler_faq.html#does-numpy-work-with-torch-compile),并关注 [PyTorch 博客](https://pytorch.org/blog/)以获取即将发布的有关此功能的博客。 + +**[Beta] *torch.compile* + Python 3.11** + +*torch.compile*以前只支持Python版本3.8-3.10。用户现在可以在Python 3.11中使用*torch.compile*优化模型。 + +**[Beta] *torch.compile* + *autograd.Function*** + +*torch.compile*现在可以跟踪和优化用户定义的[autograd函数](https://pytorch.org/docs/stable/autograd.html#function)的后向功能,这为更重地使用扩展机制的模型解锁了训练优化。 + +**[Beta版]改进的第三方设备支持:*PrivateUse1*** + +第三方设备类型现在可以使用privateuse1调度密钥注册到PyTorch。这允许设备扩展将新内核注册到PyTorch,并将其与新密钥相关联,允许用户代码与内置设备类型等效。例如,要注册*“my_hardware_device*”,可以执行以下操作: + +``` +torch.rename_privateuse1_backend("my_hardware_device") +torch.utils.generate_methods_for_privateuse1_backend() +x = torch.randn((2, 3), device='my_hardware_device') +y = x + x # run add kernel on 'my_hardware_device' +``` + +为了验证此功能,*Ascend NPU*的OSS团队已通过*PrivateUse1*功能成功将[**torch_npu**](https://github.com/Ascend/pytorch)作为插件集成到pytorch中。 + +有关更多信息,请参阅[此处](https://pytorch.org/tutorials/advanced/privateuseone.html)的PrivateUse1教程。 + +## **原型功能** + +**[Prototype] *torch.export()*** + +*torch.export()*提供了一个声音跟踪机制,用于从基于PT2.0提供的新技术的PyTorch程序中捕获完整的图形。 + +用户可以以数据流图的形式提取PyTorch程序的干净表示(导出IR),主要由对PyTorch运算符的直线调用组成。然后,导出IR可以转换、序列化、保存到文件、传输、加载回来,以便在有或没有Python的环境中执行。 + +有关更多信息,请参阅[此处](https://pytorch.org/tutorials/intermediate/torch_export_tutorial.html)的教程。 + +**[Prototype] *torch.export-based* 的量化** + +*torch.ao.quantization*现在支持基于PyTorch 2 *torch.export*的流的量化。这包括支持内置*XNNPACK*和*X64Inductor* *Quantizer*,以及指定自己的*Quantizer*的能力。 + +有关使用torch.export进行后训练静态量化的解释,请参阅[本教程](https://pytorch.org/tutorials/prototype/pt2e_quant_ptq.html),有关使用torch.export进行静态量化的量化感知培训,请参阅[本教程](https://pytorch.org/tutorials/prototype/pt2e_quant_qat.html)。 + +有关如何编写自己的量化器的解释,请参阅[本教程](https://pytorch.org/tutorials/prototype/pt2e_quantizer.html)。 + +**[Prototype]NVIDIA® GPU的半结构化(2:4)稀疏性** + +*torch.sparse*现在支持在半结构化稀疏(2:4)张量上创建和加速计算。有关格式的更多信息,请参阅NVIDIA[的](https://developer.nvidia.com/blog/accelerating-matrix-multiplication-with-block-sparse-format-and-nvidia-tensor-cores/)博客。介绍半结构化稀疏性的最小示例如下: + +``` +from torch.sparse import to_sparse_semi_structured + +x = torch.rand(64, 64).half().cuda() +mask = torch.tensor([0, 0, 1, 1]).tile((64, 16)).cuda().bool() +linear = nn.Linear(64, 64).half().cuda() + +linear.weight = nn.Parameter(to_sparse_semi_structured(linear.weight.masked_fill(~mask, 0))) +linear(x) +``` + +要了解更多信息,请参阅[文档](https://pytorch.org/docs/2.1/sparse.html#sparse-semi-structured-tensors)和随附的[教程](https://pytorch.org/tutorials/prototype/semi_structured_sparse.html)。 + +**[Prototype] *torchinductor*的*cpp_wrapper*** + +*cpp_wrapper*可以通过在C++中生成内核包装器代码来减少在torhinductor中调用内核的Python开销。此功能仍处于原型阶段;它不支持今天在PT2中成功编译的所有程序。如果您发现用例的限制,请提交问题,以帮助我们确定优先级。 + +打开此功能的API是: + +``` +import torch +import torch._inductor.config as config +config.cpp_wrapper = True +``` + +有关更多信息,请参阅[教程](https://pytorch.org/tutorials/prototype/inductor_cpp_wrapper_tutorial.html)。 + +## **性能改进** + +**AVX512内核支持** + +在PyTorch 2.0中,即使CPU支持AVX512指令,也会使用AVX2内核。现在,如果CPU支持这些指令,PyTorch默认使用AVX512 CPU内核,这相当于在以前的版本中设置*ATEN_CPU_CAPABILITY=avx512*。可以通过设置*ATEN_CPU_CAPABILITY=avx2*来启用之前的行为*。* + +**缩放点产品关注(SDPA)的CPU优化** + +以前版本的PyTorch为变压器原语viatorch*.nn.functiona.scaled_dot_product_attention*提供了优化的CUDA实现。PyTorch 2.1包括优化的基于FlashAttention的CPU例程。 + +请参阅[此处](https://pytorch.org/docs/2.1/generated/torch.nn.functional.scaled_dot_product_attention.html)的文档。 + +**bfloat16的CPU优化** + +PyTorch 2.1包括bfloat16的CPU优化,包括改进的矢量化支持和*火炬 inductor *代码器。 diff --git a/docs/LatestChanges/PyTorch_V2.2.md b/docs/LatestChanges/PyTorch_V2.2.md new file mode 100644 index 000000000..68d6b3f18 --- /dev/null +++ b/docs/LatestChanges/PyTorch_V2.2.md @@ -0,0 +1,92 @@ +# 新版本: PyTorch 2.2 版本,FlashAttention-v2 集成,AOTInductor + +> 发布: 2024年01月30日 +> +> 译者:[@片刻](https://github.com/jiangzhonglian) +> +> 原文: +> +> 翻译: + +**来自 PyTorch团队** + +我们很高兴地宣布PyTorch® 2.2([发布说明](https://github.com/pytorch/pytorch/releases/tag/v2.2.0))的发布!PyTorch 2.2通过[FlashAttention-v2](https://arxiv.org/abs/2307.08691)集成以及*AOTInductor*(一种为非python服务器端部署构建的新的提前编译和部署工具)提供了约2倍的性能改进,以达到*[scaledot_product_attention](https://pytorch.org/docs/2.2/generated/torch.nn.functional.scaled_dot_product_attention.html)*。 + +此版本还包括对优化器的改进的*torch.compile*支持,一些新的电感优化,以及名为TORCH_LOGS的新日志记录机制。 + +请注意,我们正在[弃用macOS x86支持](https://github.com/pytorch/pytorch/issues/114602),PyTorch 2.2.x将是支持macOS x64的最后一个版本。 + +除了2.2,我们还发布了对PyTorch域库的一系列更新。更多详细信息可以在图书馆更新博客中找到。 + +自PyTorch 2.1以来,此版本由3628个提交和521个贡献者组成。我们要真诚地感谢我们敬业的社区的贡献。一如既往,我们鼓励您尝试这些,并报告任何问题,因为我们改进了2.2。有关如何开始使用PyTorch 2系列的更多信息,请访问我们的[入门](https://pytorch.org/get-started/pytorch-2.0/)页面。 + +总结: + +* *[scaled_dot_product_attention](https://pytorch.org/docs/2.2/generated/torch.nn.functional.scaled_dot_product_attention.html)*(SDPA)现在支持*[FlashAttention-2](https://arxiv.org/abs/2307.08691)*,与之前的版本相比,速度提高了约2倍。 +* PyTorch 2.2引入了[TorchInductor](https://dev-discuss.pytorch.org/t/torchinductor-a-pytorch-native-compiler-with-define-by-run-ir-and-symbolic-shapes/747)的一个新的提前扩展,称为*[AOTInductor](https://pytorch.org/docs/main/torch.compiler_aot_inductor.html)*,旨在为非python服务器端编译和部署PyTorch程序。 +* *torch.distributed*支持一种名为*[device_mesh](https://pytorch.org/tutorials/recipes/distributed_device_mesh.html)*的新抽象,用于初始化和表示ProcessGroups。 +* PyTorch 2.2提供了一种标准化、可配置的日志记录机制,称为[TORCH_LOGS](https://pytorch.org/tutorials/recipes/torch_logs.html)。 +* PyTorch 2.2中包含一些*torch.compile*改进,包括改进了对编译优化器的支持,以及改进了TorchInductor融合和布局优化。 +* 请注意,我们正在[弃用macOS x86支持](https://github.com/pytorch/pytorch/issues/114602),PyTorch 2.2.x将是支持macOS x64的最后一个版本。 + + + +| **Stable** | **Beta** | **Performance Improvements** | +| --- | --- | --- | +| | FlashAttention-2集成 | Inductor 优化 | +| | AOTInductor | aarch64 优化 | +| | TORCH_LOGS | | +| | device_mesh | | +| | 优化器编译 | | + +* 要查看公共功能提交的完整列表,请单击[此处](https://docs.google.com/spreadsheets/d/1TzGkWuUMF1yTe88adz1dt2mzbIsZLd3PBasy588VWgk/edit?usp=sharing)。 + +## 测试版功能 + +### [Beta] FlashAttention-2在*torch.nn.functional.scaled_dot_product_attention中*的支持 + +*[torch.nn.functional.scaled_dot_product_attention](https://pytorch.org/docs/2.2/generated/torch.nn.functional.scaled_dot_product_attention.html)*(SDPA)现在支持FlashAttention-2,速度约为2倍(与之前版本相比),并在A100 GPU上达到理论最大FLOP/s的约50-73%。 + +[本文](https://arxiv.org/abs/2307.08691)提供了有关FlashAttention-2的更多信息。 + +有关如何使用SDPA的教程,请参阅[本教程](https://pytorch.org/tutorials/intermediate/scaled_dot_product_attention_tutorial.html)。 + +### [Beta] AOTInductor:torch.export-ed程序的提前编译和部署 + +AOTInductor是[TorchInductor](https://dev-discuss.pytorch.org/t/torchinductor-a-pytorch-native-compiler-with-define-by-run-ir-and-symbolic-shapes/747)的扩展,旨在处理导出的PyTorch模型,优化它们,并生成共享库以及其他相关工件。这些编译的工件可以部署在非Python环境中,这些环境经常用于服务器端的推理。请注意,AOTInductor支持与Inductor相同的后端,包括CUDA、ROCm和CPU。 + +有关更多信息,请参阅[AOTInductor教程](https://pytorch.org/docs/main/torch.compiler_aot_inductor.html)。 + +### [Beta]通过TORCH_LOGS进行细粒度的可配置日志记录 + +PyTorch现在提供一个标准化的、可配置的日志记录机制,可用于分析各种子系统的状态,如编译和分布式操作。 + +日志可以通过TORCH_LOGS环境变量启用。例如,要将TorchDynamo的日志级别设置为logging.ERROR,将TorchInductor的日志级别设置为logging.DEBUG,请将*TORCH_LOGS=”-dynamo,+inductor”*传递给PyTorch。 + +有关更多信息,请参阅日志记录[文档](https://pytorch.org/docs/2.2/logging.html)和[教程](https://pytorch.org/tutorials/recipes/torch_logs.html)。 + +### [Beta] torch.distributed.device_mesh + +PyTorch 2.2引入了一种新的抽象,用于表示分布式并行性所涉及的进程组,称为*torch.distributed.device_mesh*。这种抽象允许用户通过N维数组表示节点间和节点内进程组,例如,一个维度可以在FSDP中表示数据并行性,而另一个维度可以表示FSDP中的张量并行性。 + +有关更多信息,请参阅 [device_mesh 教程](https://pytorch.org/tutorials/recipes/distributed_device_mesh.html)。 + +### [Beta]对*torch.compile*-ing优化器的改进 + +对torch.compile-ing优化器进行了一些改进,包括减少开销和对cuda图的支持。 + +有关改进的更多技术细节可在[dev-discuss](https://dev-discuss.pytorch.org/t/compiling-the-optimizer-with-pt2/1669)上找到,并且可以[在这里](https://pytorch.org/tutorials/recipes/compiling_optimizer.html)找到*torch.compile*-ing优化器的配方。 + +## 性能改进 + +### Inductor性能优化 + +TorchInductor中添加了许多性能优化,包括[对torch.concat的水平融合支持](https://github.com/pytorch/pytorch/pull/111437),[改进了卷积布局优化](https://github.com/pytorch/pytorch/pull/114600),以及改进了*scaled_dot_product_attention*[模式](https://github.com/pytorch/pytorch/pull/109156)[匹配](https://github.com/pytorch/pytorch/pull/110001)。 + +有关Inductor优化的完整列表,请参阅[发布说明](https://github.com/pytorch/pytorch/tree/v2.2.0)。 + +### aarch64性能优化 + +PyTorch 2.2包括aarch64的一些性能增强功能,包括支持[mkldnn权重预打包](https://github.com/pytorch/pytorch/pull/115037/files),改进的[ideep](https://github.com/intel/ideep)[原始缓存](https://github.com/intel/ideep/pull/261),以及通过对[OneDNN的](https://github.com/oneapi-src/oneDNN/)[固定格式内核改进](https://github.com/oneapi-src/oneDNN/pull/1590)提高推理速度。 + +有关aarch64优化的完整列表,请参阅[发布说明](https://github.com/pytorch/pytorch/tree/v2.2.0)。 diff --git a/docs/LatestChanges/PyTorch_V2.3.md b/docs/LatestChanges/PyTorch_V2.3.md new file mode 100644 index 000000000..c56237cc6 --- /dev/null +++ b/docs/LatestChanges/PyTorch_V2.3.md @@ -0,0 +1,71 @@ +# 新版本: PyTorch 2.3 版本,公告 + +> 发布: 2024年04月24日 +> +> 译者:[@片刻](https://github.com/jiangzhonglian) +> +> 原文: +> +> 翻译: + +**来自 PyTorch团队** + +我们很高兴地宣布PyTorch® 2.3([发布说明](https://github.com/pytorch/pytorch/releases/tag/v2.3.0))的发布!PyTorch 2.3支持torch.compile中用户定义的Triton内核,允许用户从渴望中迁移自己的Triton内核,而无需经历性能回归或图形中断。张量并行性改进了使用原生PyTorch函数训练大型语言模型的体验,该函数已在100B参数模型的训练运行中进行了验证。此外,半结构化稀疏实现了半结构化稀疏作为张量子类,在密集矩阵乘法上观察到的速度高达1.6。 + +自PyTorch 2.2以来,此版本由3393个提交和426个贡献者组成。我们要真诚地感谢我们敬业的社区的贡献。一如既往,我们鼓励您尝试这些,并报告任何问题,因为我们改进了2.3。有关如何开始使用PyTorch 2系列的更多信息,请访问我们的[入门](https://pytorch.org/get-started/pytorch-2.0/)页面。 + +| **Beta** | **Prototype** | **Performance Improvements** | +| --- | --- | --- | +| torch.compile 中用户定义的 Triton内核 | torch.export 添加了新的API来指定 dynamic_shapes | 仅重量量化引入 inductor CPU后端 | +| PyTorch分布式中的 Tensor 并行性 | 异步 checkpoint 生成 | | +| 支持半结构化稀疏性 | | | + +* 要查看公共功能提交的完整列表,请单击[此处](https://docs.google.com/spreadsheets/d/1TzGkWuUMF1yTe88adz1dt2mzbIsZLd3PBasy588VWgk/edit?usp=sharing)。 + +## 测试版功能 + +### [Beta]支持 *torch.compile* 中用户定义的Triton内核 + +允许使用torch.compile原生执行包含三通内核的PyTorch代码。这使用户能够将包含三元内核的代码从渴望的PyTorch迁移到*torch.compile*,而不会遇到性能回归或图表中断。原生支持还为Torch Inductor预编译用户定义的Triton内核以及更好地围绕Triton内核组织代码创造了机会,从而进行进一步的优化。 + +您可以在[本教程](https://pytorch.org/tutorials/recipes/torch_compile_user_defined_triton_kernel_tutorial.html)中找到有关如何在torch.compile中使用用户定义的Triton内核的更多信息。 + +### [Beta]张量并行性引入了更有效的方法来训练LLM + +张量并行API促进了GPU/主机之间的各种张量操作,并与FSDP集成进行二维并行(跨设备的张量并行+跨主机的数据并行)。它还提供了一个用于构建更高级Tensor并行API的低级API。该API已经过验证,以支持具有超过1000亿个参数的变压器模型的训练。 + +您可以在[本教程](https://pytorch.org/tutorials/intermediate/TP_tutorial.html)中找到有关如何在工作流程中利用此的更多信息。 + +### [Beta]半结构化稀疏性为用户提供了一种利用加速稀疏推理和内存节省的方法 + +*torch.sparse.SparseSemiStructuredTensor*将半结构化稀疏作为张量子类,该子类在密集矩阵乘法上观察到高达1.6的速度。 + +特别是,它补充说: + +* 量化可组合性的额外支持(混合d型、去定量融合) +* 更新了cuSPARSELt和CUTLASS内核 +* torch.compile支持 + +您可以[在这里](https://pytorch.org/tutorials/advanced/semi_structured_sparse.html)找到有关如何利用半结构化稀疏性的更多信息。 + +## 原型功能 + +### [PROTOTYPE] *torch.export*添加了新的API来指定*dynamic_shapes* + +您现在可以使用*torch.export.Dim*更好地表示动态形状,方法是允许开发人员指定范围(最小和最大值),这些范围可以在不同的输入维度上重复使用,这些维度被限制为相等。 + +要了解有关*torch.export.Dim*的更多信息,以及如何使用它来表达更有趣的关系(如线性算术表达式),请查看[此处](https://pytorch.org/tutorials/intermediate/torch_export_tutorial.html#constraints-dynamic-shapes)的教程。 + +### [PROTOTYPE]异步检查点生成 + +异步检查点生成允许用户在生成检查点时继续他们的训练循环,基本上卸载了大部分检查点成本。 + +通过这个[例子](https://github.com/pytorch/pytorch/blob/release/2.3/torch/distributed/checkpoint/examples/async_checkpointing_example.py),您可以了解如何在自己的工作流程中利用这一点。 + +## 性能改进 + +### [PROTOTYPE]在 inductor CPU后端引入仅重量量化 + +PyTorch 2.3增强了火炬电感CPU后端的LLM推理性能。该项目[gpt-fast](https://github.com/pytorch-labs/gpt-fast)为使用*torch.compile*的变压器文本生成提供了简单高效的PyTorch原生加速。在2.3之前,只支持CUDA设备,此功能通过为int4和int8权重仅量化线性提供高度优化的内核来支持CPU对应。 + +有关更多信息/如何使用此功能,请参阅[gpt-fast README](https://github.com/pytorch-labs/gpt-fast#quantization)。 diff --git a/mkdocs.yml b/mkdocs.yml index 1c95bbc51..d589821bd 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -54,6 +54,9 @@ extra_javascript: nav: - "PyTorch 中文文档 & 教程": "index.md" - "PyTorch 新特性": + - "V2.3": "LatestChanges/PyTorch_V2.3.md" + - "V2.2": "LatestChanges/PyTorch_V2.2.md" + - "V2.1": "LatestChanges/PyTorch_V2.1.md" - "V2.0": "LatestChanges/PyTorch_V2.0.md" - "V1.13": "LatestChanges/PyTorch_V1.13.md" - "V1.12": "LatestChanges/PyTorch_V1.12.md"