

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 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 分布式训练库可通过 Hugging Face 的 AWS PyTorch深度学习容器获得， TensorFlow 也可以在训练平台 SageMaker 内使用。要使用分布式训练库的功能，我们建议您使用 SageMaker Python SDK。如果你 SageMaker APIs 通过适用于 Python 的 SDK (Boto3) 或，也可以使用 JSON 请求语法手动配置。 AWS Command Line Interface在整篇文档中，说明和示例都侧重于如何将分布式训练库与 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)
+ [Support FlashAttention](model-parallel-attention-head-size-for-flash-attention.md)