

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# SageMaker 模型平行化程式庫的核心功能
<a name="model-parallel-core-features"></a>

Amazon SageMaker AI 模型平行化程式庫提供發佈策略和節省記憶體技術，例如碎片資料平行化、張量平行化、管道排程模型依層分割，以及檢查點。模型平行化策略與技術有助於發佈大型模型到多個裝置，同時最佳化訓練速度及記憶體使用量。此程式庫也提供 Python 協助程式函式、內容管理員與包裝函式，以調整訓練指令碼來自動化或手動分割模型。

當您實作模型平行化至訓練任務時，您會保持相同的兩個步驟工作流程，如同[利用模型平行化執行 SageMaker 分散式訓練任務](https://docs.aws.amazon.com/sagemaker/latest/dg/model-parallel-use-api.html)區段所示。若要調整訓練指令碼，您需要新增零或幾行其他程式碼至訓練指令碼。若要啟動已調整訓練指令碼的訓練任務，您需要設定發佈設定參數，以便啟用節省記憶體功能，或傳遞平行處理程度的值。

若要開始使用範例，請參閱下列 Jupyter 筆記本，其中示範如何使用 SageMaker 模型平行化程式庫。
+ [PyTorch 範例筆記本](https://github.com/aws/amazon-sagemaker-examples/tree/main/training/distributed_training/pytorch/model_parallel)
+ [TensorFlow 範例筆記本](https://github.com/aws/amazon-sagemaker-examples/tree/main/training/distributed_training/tensorflow/model_parallel/mnist)

若要深入了解程式庫的核心功能，請參閱下列主題。

**注意**  
SageMaker 分散式訓練程式庫可透過 SageMaker Training 平台中 PyTorch、Hugging Face 和 TensorFlow 的 AWS 深度學習容器取得。若要利用分散式訓練程式庫的功能，建議您使用 SageMaker Python SDK。如果您透過適用於 Python 的 SDK (Boto3) 或 AWS Command Line Interface使用 SageMaker API，您還可以手動設定 JSON 的請求語法。在整份文件，指示與範例著重於如何搭配 SageMaker Python SDK 使用分散式訓練程式庫。

**重要**  
SageMaker 模型平行化程式庫支援 PyTorch 的所有核心功能，並支援 TensorFlow 的管道平行化。

**Topics**
+ [碎片資料平行處理](model-parallel-extended-features-pytorch-sharded-data-parallelism.md)
+ [管道模型](model-parallel-core-features-pipieline-parallelism.md)
+ [張量平行處理](model-parallel-extended-features-pytorch-tensor-parallelism.md)
+ [最佳化工具狀態碎片](model-parallel-extended-features-pytorch-optimizer-state-sharding.md)
+ [啟用檢查點](model-parallel-extended-features-pytorch-activation-checkpointing.md)
+ [啟用卸載](model-parallel-extended-features-pytorch-activation-offloading.md)
+ [使用模型平行化進行 FP16 訓練](model-parallel-extended-features-pytorch-fp16.md)
+ [支援 FlashAttention](model-parallel-attention-head-size-for-flash-attention.md)