Overview#
Note
SageMaker Python SDK V3 contains breaking changes from V2. See the V3.0.0 release notes for release notes or visit the V2 documentation.
SageMaker Python SDK v3.0 introduces a modern, modular API for training, fine-tuning, deploying, and managing models on Amazon SageMaker. This release replaces legacy interfaces such as Estimator, Model, and Predictor with unified classes like ModelTrainer and ModelBuilder, reducing boilerplate and simplifying workflows. V3 also introduces comprehensive fine-tuning support with new trainer classes for foundation models.
What’s New in V3#
Model Customization (V3 Exclusive)
Revolutionary foundation model fine-tuning with specialized trainers:
- SFTTrainer - Supervised fine-tuning for task-specific adaptation
- DPOTrainer - Direct preference optimization without RL complexity
- RLAIFTrainer - Reinforcement learning from AI feedback
- RLVRTrainer - Reinforcement learning from verifiable rewards
Advanced techniques like LoRA, preference optimization, and RLHF that simply don't exist in V2.
Modular Architecture
Separate PyPI packages for specialized capabilities:
- sagemaker-core - Low-level SageMaker resource management
- sagemaker-train - Unified training with ModelTrainer
- sagemaker-serve - Simplified inference with ModelBuilder
- sagemaker-mlops - ML operations and pipeline management
Single classes replace multiple framework-specific implementations:
- ModelTrainer replaces PyTorchEstimator, TensorFlowEstimator, SKLearnEstimator, etc.
- ModelBuilder replaces PyTorchModel, TensorFlowModel, SKLearnModel, etc.
Capabilities#
Training with ModelTrainer#
Unified training interface replacing framework-specific estimators with intelligent defaults and streamlined workflows:
from sagemaker.train import ModelTrainer
from sagemaker.train.configs import InputData
trainer = ModelTrainer(
training_image="your-training-image",
role="your-sagemaker-role"
)
train_data = InputData(
channel_name="training",
data_source="s3://your-bucket/train-data"
)
training_job = trainer.train(input_data_config=[train_data])
Inference with ModelBuilder#
Simplified model deployment and inference with the ModelBuilder
from sagemaker.serve import ModelBuilder
model_builder = ModelBuilder(
model="your-model",
model_path="s3://your-bucket/model-artifacts"
)
model = model_builder.build(model_name="my-model")
endpoint = model_builder.deploy(
endpoint_name="my-endpoint",
instance_type="ml.m5.xlarge",
initial_instance_count=1
)
result = endpoint.invoke(
body={"inputs": "your-input-data"},
content_type="application/json"
)
ML Operations#
Comprehensive MLOps capabilities for building, deploying, and managing machine learning workflows at scale:
from sagemaker.mlops import Pipeline, TrainingStep, ModelStep
pipeline = Pipeline(name="production-ml-pipeline")
training_step = TrainingStep(
name="train-model",
training_config=TrainingConfig(
algorithm_specification={
"training_image": "your-training-image"
}
)
)
pipeline.add_step(training_step)
SageMaker Core#
Low-level, object-oriented access to Amazon SageMaker resources with intelligent defaults and type safety:
from sagemaker.core.resources import TrainingJob
training_job = TrainingJob.create(
training_job_name="my-training-job",
role_arn="arn:aws:iam::123456789012:role/SageMakerRole",
input_data_config=[{
"channel_name": "training",
"data_source": "s3://my-bucket/train"
}]
)
Getting Started#
Installation#
Install SageMaker Python SDK V3 to get started
Migration from V2#
Key changes when migrating from V2:
Replace Estimator classes with
ModelTrainerReplace Model classes with
ModelBuilderUse structured config objects instead of parameter dictionaries
Next Steps#
Get Started: Follow the Quickstart guide for a hands-on introduction