amazon-sagemaker-examples
AGENTS.md11k starsChanged 3 months agoApache-2.0View on GitHub
Guidance for AI coding agents (Cursor, GitHub Copilot, Claude Code, Amazon Q Developer, Kiro, Codex, Gemini CLI, etc.) working in this repository. Follows the AGENTS.md convention (https://agents.md). This repository contains example notebooks for the Amazon SageMaker Python SDK v3. pip install sagemaker installs v3. SDK v3 is a modular redesign and is not backward compatible with v2. It is split into: Generate SageMaker Python SDK v3 code by default. Produce v2 code only when the user explicitly asks for "v2"…
- Installs packages
Trending
Quiet this year.about the whole repository
Who's talking about aws/amazon-sagemaker-examples
- plotly/jupyter-dash“AWS SageMaker”GitHub · Oct 6, 2020 · 7 reactions
- aws/sagemaker-python-sdk“ModelTrainer Local Mode PermissionError: [Errno 13] Permission denied: 'sm_drivers'”GitHub · Feb 27, 2025 · 3 reactions
- hashicorp/terraform-provider-aws“F/Add model_package_name for aws_sagemaker_model”GitHub · Jun 4, 2023 · 3 reactions
- aws/sagemaker-python-sdk“Error when running hyperparameter tuning job locally”GitHub · Oct 19, 2020 · 2 reactions
- philschmid/easyllm“Streaming support in Sagemaker?”GitHub · Aug 17, 2023 · 1 reactions
The biggest 5 of 22 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 22
Talked about on GitHub (22 times).
On GitHub · 22
- Oct 6, 2020AWS SageMaker — plotly/jupyter-dash7 reactions · 15 comments
- Feb 27, 2025ModelTrainer Local Mode PermissionError: [Errno 13] Permission denied: 'sm_drivers' — aws/sagemaker-python-sdk3 reactions · 1 comment
- Jun 4, 2023F/Add model_package_name for aws_sagemaker_model — hashicorp/terraform-provider-aws3 reactions · 5 comments
- Oct 19, 2020Error when running hyperparameter tuning job locally — aws/sagemaker-python-sdk2 reactions · 5 comments
- Aug 17, 2023Streaming support in Sagemaker? — philschmid/easyllm1 reaction · 1 comment
17 more on GitHub
- Jun 22, 2021Custom `model_fn` function not found when extending the PyTorch inference container — aws/sagemaker-inference-toolkit1 reaction
- Oct 6, 2020Model and output files do not get saved to S3 when training own model — aws/sagemaker-training-toolkit1 reaction · 5 comments
- Jan 31, 2025SageMaker Unified Studio: default_bucket returning incorrect bucket and default_bucket_prefix returning None from sagemaker_core python SDK — aws/sagemaker-core0 reactions · 1 comment
- Dec 4, 2024Server reruns same task multiple times — aws/sagemaker-huggingface-inference-toolkit0 reactions
- Oct 11, 2023Structure for custom entrypoint inference script and its overridden methods for DJLModel — aws/sagemaker-python-sdk0 reactions · 1 comment
- Aug 23, 2023Update README.md — awslabs/sagemaker-debugger0 reactions
- Jul 19, 2023error in code — johnny-chivers/sagemakerCode0 reactions
- Mar 2, 2023Domain Specific: Feature Sets — SuperCowPowers/workbench0 reactions
- Feb 8, 2023[bug] tensorflow inference container, python service is not enabled even though insert environment variable SAGEMAKER — aws/deep-learning-containers0 reactions · 2 comments
- Dec 7, 2022【时间序列】时间序列预测算法总结 - 知乎 — liuwa666/webclipper0 reactions
- Dec 7, 2022【时间序列】时间序列预测算法总结 - 知乎 — liuwa666/webclipper0 reactions
- Oct 28, 2022Training metrics not being recorded in Sagemaker Experiments — aws/sagemaker-experiments0 reactions
- May 11, 2022Batch Inference does not work when using the default handler — aws/sagemaker-pytorch-inference-toolkit0 reactions
- Feb 17, 2022[bug] Docker File not building in scikit_bring_your_own example — aws/deep-learning-containers0 reactions · 2 comments
- Sep 15, 2021Impossible to deploy on sagemaker, a random forest model with a custom container — aws-samples/amazon-sagemaker-custom-container0 reactions
- Oct 25, 2020Python随身听-2020-10-25技术精选 — pythonradio/pythonradio.github.io0 reactions
- Oct 16, 2020Python随身听-2020-10-16技术精选 — pythonradio/pythonradio.github.io0 reactions
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repositoryOne other file it gives its agents.
- llms.txtllms.txt
The file
We split this AGENTS.md into the rules it gives an agent
7 rules. About 0 are common, 6 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 46
Only step outside the SDK when the SDK genuinely does not cover the task (e.g., a pure IAM or S3 setup step), and say so explicitly when …
- Distinctive: line 56
Do not emit the left column unless v2 is explicitly requested.
- Distinctive: line 74
Write the code using v3 patterns from the table above.
- Distinctive: line 77
If a v2 pattern is found, fix it to v3 and re-check until clean.
- Distinctive: line 78
Only then present the code.
- Very specific: line 101
No hardcoded account IDs, role ARNs, regions, subnets, or bucket names.
- Distinctive: line 103
Do not require interactive input to run.
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AGENTS.md — Amazon SageMaker Examples
Guidance for AI coding agents (Cursor, GitHub Copilot, Claude Code, Amazon Q Developer, Kiro, Codex, Gemini CLI, etc.) working in this repository. Follows the AGENTS.md convention (https://agents.md).
Project context
This repository contains example notebooks for the Amazon SageMaker Python SDK v3.
pip install sagemaker installs v3. SDK v3 is a modular redesign and is not
backward compatible with v2. It is split into:
sagemaker-core— foundation primitives and the low-level, resource-oriented APIsagemaker-train— training (ModelTrainer)sagemaker-serve— model building & deployment (ModelBuilder)sagemaker-mlops— pipelines and workflow orchestration
Golden rule: generate v3 by default
Generate SageMaker Python SDK v3 code by default. Produce v2 code only when the
user explicitly asks for "v2" (e.g., "give me the v2 version"); if you do, label it as
deprecated and note pip install 'sagemaker<3.0'.
SDK-first: use the SageMaker Python SDK for SageMaker tasks
For any Amazon SageMaker task (training, deployment, processing, pipelines), default to the
SageMaker Python SDK v3 as the primary interface. Do not drop to raw boto3
(client("sagemaker").create_training_job(...)), the AWS CLI, or hand-rolled framework
scripts unless the user explicitly asks for them, because the SDK handles image resolution,
packaging, and job wiring that raw clients leave to the caller.
Map the user's intent to the v3 interface:
| User intent (natural language) | Use this v3 interface |
| "train a model", "training job", "serverless / managed training", "fine-tune" | sagemaker.train.ModelTrainer → .train(...) |
| "distributed training", "multi-GPU / multi-node" | ModelTrainer with Compute(instance_count=N, ...) |
| "hyperparameter tuning", "HPO", "sweep" | sagemaker.train tuner APIs on top of ModelTrainer |
| "deploy a model", "real-time / serverless / async endpoint", "host / serve" | sagemaker.serve.ModelBuilder → .deploy(...) |
| "batch inference", "batch transform", "offline scoring" | sagemaker.core.resources transform APIs |
| "process data", "feature engineering", "preprocess", "transform dataset" | sagemaker.core.resources.ProcessingJob |
| "build an ML pipeline", "orchestrate a workflow", "MLOps" | sagemaker.mlops.pipeline.Pipeline, sagemaker.mlops.steps |
| "register a model", "model registry" | sagemaker.mlops model-registry APIs |
| "get / retrieve a container image URI" | sagemaker.core.image_uris.retrieve(...) |
Only step outside the SDK when the SDK genuinely does not cover the task (e.g., a pure IAM or S3 setup step), and say so explicitly when you do.
Honest scope note: this guidance only steers agents that have this file (or the SDK repo, or an equivalent rules/MCP configuration) in context. It does not change a plain chat session that never loads these files — winning those requires corpus/discoverability work outside this repo (see the deprecation recommendations doc).
Banned v2 patterns → required v3 replacements
Do not emit the left column unless v2 is explicitly requested. Mappings follow the official migration guide.
| v2 (do NOT use) | v3 (use instead) |
from sagemaker.estimator import Estimator | from sagemaker.train import ModelTrainer |
framework estimator classes — from sagemaker.pytorch import PyTorch (also TensorFlow, SKLearn, XGBoost, HuggingFace) | ModelTrainer + from sagemaker.core import image_uris → image_uris.retrieve(...) |
estimator.fit(...) | model_trainer.train(...) |
from sagemaker.model import Model / model.deploy(...) | from sagemaker.serve import ModelBuilder; ModelBuilder(...).deploy(...) |
from sagemaker.predictor import Predictor / predictor.predict(...) | Predictor is replaced by Endpoint (sagemaker-core); use the predictor returned by ModelBuilder.deploy(...) |
from sagemaker.processing import Processor / ScriptProcessor / SKLearnProcessor | sagemaker.core.resources.ProcessingJob |
from sagemaker.workflow... (old paths) | from sagemaker.mlops... (sagemaker.mlops.pipeline.Pipeline, sagemaker.mlops.steps) |
Removed in v3 with no direct replacement (do not invent shims): MXNet, Chainer, RLEstimator, Training Compiler.
Required workflow when writing SageMaker code
- Write the code using v3 patterns from the table above.
- Self-check the output for any banned v2 pattern (if a migration MCP tool such as
sagemaker-sdk-helperis available, call its validate/transform tools). - If a v2 pattern is found, fix it to v3 and re-check until clean.
- Only then present the code.
Repository layout (capability folders)
The repository is organized by ML capability, following the lifecycle order:
training/— training withModelTrainer: script and framework training, distributed training, managed spot, heterogeneous clusters, BYOC, AWS Batch training queues,@remotemodel_customization/— fine-tuning foundation models: SFT, DPO, RLVR, RLAIF, MTRL, CPT, recipe overrides, data mixing, JumpStart fine-tuning, distributed fine-tuningevaluation/— the*Evaluatorsurface: benchmark, custom scorer, LLM-as-a-judge, Inspect AIinference/— deployment withModelBuilderand sagemaker-core: real-time / serverless / async endpoints, local and in-process modes, inference pipelines, MME / multi-container, A/B testing, shadow variants, guardrails, autoscaling,optimize(), batch transform, Bedrockmlops/— Pipelines and Model Registry, lineage, experiments, Feature Store, processing, EMR Serverless steps, Clarify, MLflow
(Category folders carry leading-space ordering prefixes in this repo — training,
model_customization, evaluation, inference, mlops — so that they list in
lifecycle order. Match the existing name exactly, including the prefix, when adding files.)
Code conventions
- No hardcoded account IDs, role ARNs, regions, subnets, or bucket names. Use
get_execution_role()andSession().default_bucket(). - Do not require interactive input to run.
- Notebook file naming:
sm-<feature>_<description>.ipynb. - Each notebook includes: a title cell, a setup cell (
%pip install sagemaker), a cleanup cell that deletes created resources, and a summary cell. - Clear cell outputs before committing. Target the latest v3.
Canonical v3 example (train + deploy)
Grounded in the migration guide; verify exact signatures against the installed SDK.
from sagemaker.core import image_uris
from sagemaker.train import ModelTrainer
from sagemaker.train.configs import SourceCode, Compute, InputData
from sagemaker.serve import ModelBuilder
from sagemaker.serve.configs import InferenceSpec
# Training
training_image = image_uris.retrieve(
framework="pytorch", region="us-west-2", version="2.0.0",
py_version="py310", instance_type="ml.p3.2xlarge", image_scope="training",
)
model_trainer = ModelTrainer(
training_image=training_image,
role=role,
source_code=SourceCode(source_dir="./src", entry_script="train.py"),
compute=Compute(instance_type="ml.p3.2xlarge", instance_count=1),
)
model_trainer.train(input_data_config=[InputData(channel_name="train", data_source="s3://<bucket>/train")])
# Inference
model_builder = ModelBuilder(
inference_spec=InferenceSpec(
image_uri="<inference-image-uri>",
model_data_url="s3://<bucket>/model.tar.gz",
),
role=role,
)
predictor = model_builder.deploy(instance_type="ml.m5.large", initial_instance_count=1)References
- V2 → V3 migration guide: https://github.com/aws/sagemaker-python-sdk/blob/master/migration.md
- SageMaker Python SDK (source): https://github.com/aws/sagemaker-python-sdk
- SageMaker Python SDK docs: https://sagemaker.readthedocs.io/
- Curated index for agents: ./llms.txt
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

