← Back
AWS ML Blog

Bring your own model with Amazon SageMaker AI: Script mode in SDK v3

•18 min read•
#python#compute#amazon
Level:Intermediate
For:AI Engineers
✦TL;DR

** The SageMaker Python SDK v3 introduces a unified ModelTrainer and ModelBuilder API that replaces framework‑specific estimators, enabling true “bring‑your‑own‑model” workflows via script mode. By syncing a local source_dir into any container image (AWS DLC, custom ECR image, or third‑party) at runtime through the new SourceCode object, developers can iterate training scripts instantly without rebuilding containers. The post demonstrates this with a scikit‑learn Random Forest on the diabetes dataset (deployed via DJL Serving) and a Stable Diffusion 3.5 LoRA fine‑tune using Hugging Face Accelerate. Engineers gain faster iteration cycles, full container control, and a single API across frameworks for both training and deployment. **KeyTakeaways:** - ModelTrainer replaces all v2 estimator classes (SKLearn, PyTorch, XGBoost) with one unified trainer class.

⚡ Key Takeaways

  • ModelTrainer replaces all v2 estimator classes (SKLearn, PyTorch, XGBoost) with one unified trainer class.
  • SourceCode object injects code at runtime using source_dir plus command or entry_script instead of baked‑in images.
  • Supports any container image from Amazon ECR, including custom builds, AWS Deep Learning Containers, or third‑party images.
  • Deploys with ModelBuilder, which packages the inference handler and creates a real‑time endpoint (e.g., DJL Serving).
  • Prerequisite: pip install sagemaker>=3.0 and an IAM role with SageMaker and S3 permissions.
💡 Why It Matters

** Engineers can now modify training scripts and redeploy models in minutes without container rebuilds, dramatically reducing development latency and simplifying multi‑framework pipelines in production SageMaker environments. **TechnicalLevel:** Advanced **TargetAudience:** ML Engineers **PracticalSteps:** - Install the SDK: `pip install sagemaker>=3.0`.

✅ Practical Steps

  1. Install the SDK: `pip install sagemaker>=3.0`.
  2. Define a ModelTrainer with a SourceCode(source_dir="path/to/code", command="python train.py") and launch the training job.
  3. Use ModelBuilder with SourceCode(source_dir="path/to/inference", entry_script="serve.py") to package the handler and deploy a real‑time endpoint.

Want the full story? Read the original article.

Read on AWS ML Blog ↗

More like this

Introducing workload recovery and expanded infrastructure checks on Amazon SageMaker HyperPod

AWS ML Blog•#deployment

AI’s GPU focus meets a CPU reality check at Dell and AMD

SiliconANGLE AI•#agents

NVIDIA RTX Spark Compact Desktops Out Now

NVIDIA Blog•#compute

AI’s hidden energy tax: More than 80% of scale-up traffic is just memory moving around

SiliconANGLE AI•#compute

EXPLORE AI NEWS

Daily hand-picked stories on LLMs, RAG, agents and production AI — curated for engineers who ship.

BROWSE NEWS

GET THE WEEKLY DIGEST

Join engineers getting the Monday signal-over-noise AI breakdown. No spam, unsubscribe anytime.

LEARN AI ENGINEERING

Curated courses, research papers, repos and tutorials built for engineers leveling up in AI.

START LEARNING