AWS Security ChangesHomeSearch

AWS sagemaker documentation change

Service: sagemaker · 2026-06-28 · Documentation low

File: sagemaker/latest/dg/sagemaker-hyperpod-trainium-sagemaker-training-jobs-pretrain-tutorial.md

Summary

Replaced PyTorch estimator with ModelTrainer class, added SageMaker Python SDK v3 code example with Trainium-specific configuration.

Security assessment

Changes focus on updating training job implementation to use the ModelTrainer API and provide Trainium-optimized examples. No security fixes, vulnerabilities, or security features are mentioned or implied in the modifications.

Diff

diff --git a/sagemaker/latest/dg/sagemaker-hyperpod-trainium-sagemaker-training-jobs-pretrain-tutorial.md b/sagemaker/latest/dg/sagemaker-hyperpod-trainium-sagemaker-training-jobs-pretrain-tutorial.md
index 85674c33d..81212c703 100644
--- a//sagemaker/latest/dg/sagemaker-hyperpod-trainium-sagemaker-training-jobs-pretrain-tutorial.md
+++ b//sagemaker/latest/dg/sagemaker-hyperpod-trainium-sagemaker-training-jobs-pretrain-tutorial.md
@@ -90 +90 @@ We strongly recommend using a SageMaker AI Jupyter notebook in SageMaker AI Jupy
-You can use the following Python code to run a SageMaker training job using your recipe. It leverages the PyTorch estimator from the [SageMaker AI Python SDK](https://sagemaker.readthedocs.io/en/stable/) to submit the recipe. The following example launches the llama3-8b recipe as a SageMaker AI Training Job.
+You can use the following Python code to run a SageMaker training job using your recipe. It leverages the PyTorch ModelTrainer from the [SageMaker AI Python SDK](https://sagemaker.readthedocs.io/en/stable/) to submit the recipe. The following example launches the llama3-8b recipe as a SageMaker AI Training Job.
@@ -96,0 +97,56 @@ You can use the following Python code to run a SageMaker training job using your
+SageMaker Python SDK v3
+    
+    
+    
+    import os
+    import boto3
+    from sagemaker.core.debugger import TensorBoardOutputConfig
+    from sagemaker.core.helper.session_helper import Session, get_execution_role
+    from sagemaker.train import ModelTrainer
+    from sagemaker.train.configs import Compute, InputData, OutputDataConfig
+    
+    sagemaker_session = Session()
+    role = get_execution_role()
+    
+    bucket = sagemaker_session.default_bucket() 
+    output = os.path.join(f"s3://{bucket}", "output")
+    output_path = "<s3-URI>"
+    
+    recipe_overrides = {
+        "run": {
+            "results_dir": "/opt/ml/model",
+        },
+        "exp_manager": {
+            "explicit_log_dir": "/opt/ml/output/tensorboard",
+        },
+        "data": {
+            "train_dir": "/opt/ml/input/data/train",
+        },
+        "model": {
+            "model_config": "/opt/ml/input/data/train/config.json",
+        },
+        "compiler_cache_url": "<compiler_cache_url>"
+    } 
+    
+    tensorboard_output_config = TensorBoardOutputConfig(
+        s3_output_path=os.path.join(output, 'tensorboard'),
+        container_local_output_path=recipe_overrides["exp_manager"]["explicit_log_dir"]
+    )
+    
+    model_trainer = ModelTrainer(
+        output_data_config=OutputDataConfig(s3_output_path=output_path),
+        base_job_name=f"llama-trn",
+        role=role,
+        compute=Compute(instance_type="ml.trn1.32xlarge", instance_count=1),
+        training_recipe="training/llama/hf_llama3_70b_seq8k_trn1x16_pretrain",
+        recipe_overrides=recipe_overrides,
+    )
+    
+    model_trainer.train(input_data_config=[
+        InputData(channel_name="train", data_source="your-inputs")
+    ], wait=True)
+    
+
+SageMaker Python SDK v2 (Legacy)
+    
+    
@@ -141 +197 @@ You can use the following Python code to run a SageMaker training job using your
-The preceding code creates a PyTorch estimator object with the training recipe and then fits the model using the `fit()` method. Use the `training_recipe` parameter to specify the recipe you want to use for training.
+The preceding code creates a ModelTrainer object with the training recipe and then trains the model using the `train()` method. Use the `training_recipe` parameter to specify the recipe you want to use for training.