AWS sagemaker documentation change
Summary
Removed SageMaker Python SDK v2 (Legacy) configuration examples and redundant section headers
Security assessment
Changes consist of deleting legacy SDK code samples for sharded data parallelism configuration. No security vulnerabilities are addressed, and no new security features are documented. The removed content included MPI options and performance tuning parameters without security context.
Diff
diff --git a/sagemaker/latest/dg/model-parallel-extended-features-pytorch-sharded-data-parallelism.md b/sagemaker/latest/dg/model-parallel-extended-features-pytorch-sharded-data-parallelism.md index d8d1448ca..a618066c3 100644 --- a//sagemaker/latest/dg/model-parallel-extended-features-pytorch-sharded-data-parallelism.md +++ b//sagemaker/latest/dg/model-parallel-extended-features-pytorch-sharded-data-parallelism.md @@ -99,3 +98,0 @@ The following code shows an example of how to configure sharded data parallelism -SageMaker Python SDK v3 - - @@ -159,44 +155,0 @@ SageMaker Python SDK v3 -SageMaker Python SDK v2 (Legacy) - - - - import sagemaker - from sagemaker.pytorch import PyTorch - - smp_options = { - "enabled": True, - "parameters": { - # "pipeline_parallel_degree": 1, # Optional, default is 1 - # "tensor_parallel_degree": 1, # Optional, default is 1 - "ddp": True, - # parameters for sharded data parallelism - "sharded_data_parallel_degree": 2, # Add this to activate sharded data parallelism - "sdp_reduce_bucket_size": int(5e8), # Optional - "sdp_param_persistence_threshold": int(1e6), # Optional - "sdp_max_live_parameters": int(1e9), # Optional - "sdp_hierarchical_allgather": True, # Optional - "sdp_gradient_clipping": 1.0 # Optional - } - } - - mpi_options = { - "enabled" : True, # Required - "processes_per_host" : 8 # Required - } - - smp_estimator = PyTorch( - entry_point="your_training_script.py", # Specify your train script - role=sagemaker.get_execution_role(), - instance_count=1, - instance_type='ml.p3.16xlarge', - framework_version='1.13.1', - py_version='py3', - distribution={ - "smdistributed": {"modelparallel": smp_options}, - "mpi": mpi_options - }, - base_job_name="sharded-data-parallel-job" - ) - - smp_estimator.fit('s3://my_bucket/my_training_data/') - @@ -245,3 +197,0 @@ The following code example shows how to set up a PyTorch ModelTrainer using the -SageMaker Python SDK v3 - - @@ -303,40 +252,0 @@ SageMaker Python SDK v3 -SageMaker Python SDK v2 (Legacy) - - - - import sagemaker - from sagemaker.pytorch import PyTorch - - smp_options = { - "enabled":True, - "parameters": { - "partitions": 1, - "ddp": True, - "sharded_data_parallel_degree": 64 - "bf16": True, - **"ddp_dist_backend": "auto" # Specify "nccl" to force to use NCCL.** - } - } - - mpi_options = { - "enabled" : True, # Required - "processes_per_host" : 8 # Required - } - - smd_mp_estimator = PyTorch( - entry_point="your_training_script.py", # Specify your train script - source_dir="location_to_your_script", - role=sagemaker.get_execution_role(), - instance_count=8, - instance_type='ml.p4d.24xlarge', - framework_version='1.13.1', - py_version='py3', - distribution={ - "smdistributed": {"modelparallel": smp_options}, - "mpi": mpi_options - }, - base_job_name="sharded-data-parallel-demo", - ) - - smd_mp_estimator.fit('s3://my_bucket/my_training_data/') - @@ -407,3 +316,0 @@ The following code shows how you can configure the environment variables by appe -SageMaker Python SDK v3 - - @@ -460,37 +366,0 @@ SageMaker Python SDK v3 -SageMaker Python SDK v2 (Legacy) - - - - import sagemaker - from sagemaker.pytorch import PyTorch - - smp_options = { - .... # All modelparallel configuration options go here - } - - mpi_options = { - "enabled" : True, # Required - "processes_per_host" : 8 # Required - } - - **# Use the following two lines to tune values of the environment variables for buffer - mpioptions += " -x SMDDP_AG_SCRATCH_BUFFER_SIZE_BYTES=8192" - mpioptions += " -x SMDDP_AG_SORT_BUFFER_SIZE_BYTES=8192"** - - smd_mp_estimator = PyTorch( - entry_point="your_training_script.py", # Specify your train script - source_dir="location_to_your_script", - role=sagemaker.get_execution_role(), - instance_count=8, - instance_type='ml.p4d.24xlarge', - framework_version='1.13.1', - py_version='py3', - distribution={ - "smdistributed": {"modelparallel": smp_options}, - "mpi": mpi_options - }, - base_job_name="sharded-data-parallel-demo-with-tuning", - ) - - smd_mp_estimator.fit('s3://my_bucket/my_training_data/') - @@ -590,3 +459,0 @@ The following code snippet shows an example of creating a PyTorch ModelTrainer o -SageMaker Python SDK v3 - - @@ -645,39 +511,0 @@ SageMaker Python SDK v3 -SageMaker Python SDK v2 (Legacy) - - - - mpi_options = "-verbose --mca orte_base_help_aggregate 0 " - smp_parameters = { - "ddp": True, - "fp16": True, - "prescaled_batch": True, - "sharded_data_parallel_degree": 4, - "tensor_parallel_degree": 4 - } - - pytorch_estimator = PyTorch( - entry_point="your_training_script.py", - role=role, - instance_type="ml.p4d.24xlarge", - volume_size=200, - instance_count=4, - sagemaker_session=sagemaker_session, - py_version="py3", - framework_version="1.13.1", - distribution={ - "smdistributed": { - "modelparallel": { - "enabled": True, - "parameters": smp_parameters, - } - }, - "mpi": { - "enabled": True, - "processes_per_host": 8, - "custom_mpi_options": mpi_options, - }, - }, - source_dir="source_directory_of_your_code", - output_path=s3_output_location - ) -