SageMaker Training Job Operator
Activation
Activate this skill when the user reports a SageMaker training job
operation. Trigger phrases: "SageMaker training job",
"create-training-job", "spot training", "SpotInstanceConfig",
"checkpoint S3", "distributed training", "SageMaker Distributed Data
Parallel", "SageMaker Distributed Model Parallel", "warm pool",
"hyperparameter tuning", "automatic model tuning", "HPO",
"register-model", "model registry", "Training Compiler",
"P5 instance", "H100 training", "training plan", "SageMaker training
BLOCKED", "training job Failed".
Mindset
One-line takeaway: a SageMaker training job is a container that
runs on a managed EC2 instance, reads input from S3, writes model
artifacts to S3, and emits CloudWatch logs — the operator's job is to
ensure the configuration is internally consistent (image matches
instance type, input channels are reachable, the execution role can
read/write S3 and KMS, the VPC has the right endpoints, and spot /
distributed / warm-pool settings are coherent) before launching, and
to monitor SecondaryStatus + AlgorithmSpecification until
Completed.
Five SageMaker realities shape every operation:
The execution role is the most common failure point. SageMaker
assumes the role you provide to read inputs from S3, write outputs
to S3, pull the container image (if private), encrypt/decrypt with
KMS, and (for VPC jobs) create ENIs. A missing s3:GetObject on
the input bucket, s3:PutObject on the output bucket, or
kms:Decrypt on the volume KMS key produces a Failed job within
seconds. Always run pre-checks on the role before launching.
Instance type dictates image and framework compatibility. A
GPU image (e.g., the PyTorch GPU training container) requires a
GPU instance (ml.p3.*, ml.p4d.*, ml.p4de.*, ml.p5.*,
ml.g4dn.*, ml.g5.*). A CPU image requires a CPU instance
(ml.m5.*, ml.c5.*, ml.r5.*). AWS Trainium (ml.trn1.*)
requires the Neuron container. Mismatch produces a Failed job
immediately. P5 (H100) and Trn1 (Trainium) also require Service
Quota approval — the default quota is zero.
Spot training requires checkpointing to be useful. Spot
instances can be interrupted with 2 minutes' notice. Without
checkpointing to S3, each interruption restarts the job from
scratch. Configure both EnableManagedSpotTraining: true and
CheckpointConfig (S3 URI + local path) — the framework
(PyTorch / TensorFlow) must also load/save checkpoints at the
configured path.
Distributed training configuration must match instance
topology. SageMaker Distributed Data Parallel (SMDDP) requires
multiple GPUs across one or more instances.
smdistributed:dataparallel is a HyperParameters entry, not a
top-level field. SageMaker Distributed Model Parallel (SMDMP)
requires smdistributed:modelparallel with explicit
pipeline_parallel_degree, tensor_parallel_degree, and
microbatches. The framework entry point must call SMDDP / SMDMP
primitives correctly — misconfiguration produces a silent
performance regression (training runs but uses only one GPU).
Warm pools persist the compute cluster between jobs. A
WarmPoolConfig keeps the cluster alive for a configurable
MaxIdleSeconds (max 3600 seconds) after the previous job
completes, so the next job starts in seconds rather than minutes.
The next job must request the same instance type and image as the
warm pool's source job — otherwise it falls back to a cold start.
Warm pools are charged at standard instance rates while idle; they
count against the warm-pool Service Quota (separate from
training-job quota).
Quick reference — operation to verdict
| Operation |
Trigger condition |
Verdict |
| Launch training job |
All pre-checks passed; awaiting CONFIRM gate |
READY |
| Launch blocked |
Instance quota exhausted, image not found, S3 input inaccessible, role missing permissions, VPC misconfigured, warm pool capacity unavailable |
BLOCKED |
| Job in progress |
TrainingJobStatus: InProgress, SecondaryStatus reports training |
COMPLETED once TrainingJobStatus: Completed; BLOCKED if Failed |
| Job completed |
TrainingJobStatus: Completed, ModelArtifacts.S3ModelArtifacts populated, TrainingTimeInSeconds set |
COMPLETED with artifact S3 path |
| Job failed |
TrainingJobStatus: Failed, FailureReason populated |
BLOCKED with the failure cause from FailureReason and CloudWatch logs |
| Stop job |
TrainingJobStatus: InProgress, operator requests stop |
COMPLETED once TrainingJobStatus: Stopped |
| Register model |
Job Completed, operator requests model registry version |
READY to create-model-package after pre-checks |
| HPO launch |
Tuning config valid, base job pre-checks pass, warm start config (if any) valid |
READY |
| Warm pool reuse |
Source job Completed, target job instance type + image match, idle time < MaxIdleSeconds |
READY (warm start) — otherwise cold start |
Pre-check priority order (apply in this sequence, all must pass
for READY):
- Execution role —
iam simulate-principal-policy for
s3:GetObject on input, s3:PutObject on output, kms:Decrypt
on KMS key, ecr:BatchGetImage if private image, plus the
SageMaker-managed AmazonSageMakerFullAccess baseline.
- Instance quota —
service-quotas get-service-quota for
ml.<instance-type> (P5, Trn1 default to zero — request an
increase first).
- Image + instance compatibility — GPU image requires GPU
instance; Trainium image requires Trn1; Training Compiler
requires a supported image and framework version.
- S3 input/output accessibility — the role can read input, the
input channels point at valid S3 prefixes, the output bucket
exists and accepts writes.
- VPC configuration (if specified) — subnets exist, security
groups allow S3 (VPC endpoint or NAT) and ECR (VPC endpoint or
NAT), KMS endpoint if KMS is used.
- Warm pool availability (if
WarmPoolConfig specified) — the
source job's instance type and image match; the warm pool has
not been reaped by MaxIdleSeconds.
Quick navigation
- Step 0 — Capture the operation target (job name, region,
operation type, configuration).
- Step 1 — Run pre-flight (role, quota, image, S3, VPC, warm
pool).
- Step 2 — Launch training job (single-instance, spot,
distributed, warm pool).
- Step 3 — Monitor
TrainingJobStatus and SecondaryStatus
until Completed or Failed.
- Step 4 — Handle interruptions (spot, hard failure, log-driven
debugging).
- Step 5 — Launch HPO (hyperparameter tuning) with optional
warm start.
- Step 6 — Register the model artifact in the model registry
(create-model, create-model-package).
- Step 7 — Decide VERDICT (READY / BLOCKED / COMPLETED).
- Step 8 — Post-completion cleanup (delete warm pool, log
retention).
STRICT output contract
Every response MUST begin with this block — no preamble, no
conversational opening:
OPERATION: <launch-training-job | launch-spot | launch-distributed | launch-hpo | stop | register-model | describe | warm-pool>
VERDICT: READY | BLOCKED | COMPLETED
TARGET: <job-name, instance-type, region>
PRE_CHECKS:
- [PASS] <check description>
- [FAIL] <check description> — <reason>
STEPS:
1. <CLI command with flags populated>
2. <wait command — aws sagemaker wait training-job-completed-or-stopped>
3. <next step>
POST_VERIFY:
- [PASS] <verification description>
- [FAIL] <verification description> — <reason>
MODEL_ARTIFACT: <S3 URI of model.tar.gz, or N/A if not completed>
LOG_GROUP: <CloudWatch log group /aws/sagemaker/TrainingJobs>
CONFIRM: Before executing any state-changing CLI, emit and await
operator approval: "CONFIRM: About to <operation> on <job> in
<region>. Proceed? (yes/no)"
Do NOT omit any field. If a field is not applicable, write N/A
with a one-line reason.
Process — Operation execution plan (apply in order)
Step 0: Capture the operation target
Gather these inputs. Each downstream step branches on which is
present.
| Signal |
Source |
Why required |
| Operation type |
User-provided |
launch / stop / describe / register-model / launch-hpo |
| Job name + region |
User-provided |
All SageMaker calls need this; the name must be unique in the account-region |
| Algorithm spec (image or algorithm ARN) |
User-provided |
Drives the container that runs |
| Input data config (S3 channels) |
User-provided |
Each channel (train, test, validation) is an S3 prefix |
| Output data config (S3) |
User-provided |
Where model.tar.gz is written |
| Instance type + volume size |
User-provided |
Drives GPU/CPU image compatibility and quota check |
| Hyperparameters |
User-provided |
Framework entry point, batch size, learning rate, distributed config |
| Execution role ARN |
User-provided |
SageMaker assumes this role; must have S3/KMS/ECR permissions |
| Optional: spot, distributed, warm pool, HPO |
User-provided |
Each adds additional pre-checks |
If the user has not provided the job name or operation, emit
VERDICT: BLOCKED with the list of missing inputs and the discovery
command (aws sagemaker list-training-jobs --status-equals InProgress
or Completed).
Step 1: Pre-flight (role, quota, image, S3, VPC, warm pool)
Run these checks before launch (skip for offline plan audit). The
canonical CLI sequence is in references/diagnostic-commands.md of
the references folder.
- Execution role —
iam simulate-principal-policy for
s3:GetObject on input, s3:PutObject on output, kms:Decrypt
on KMS key, ecr:BatchGetImage if private image.
- Instance quota —
service-quotas get-service-quota for the
instance type. P5 / Trn1 default to zero — request an increase.
- S3 input/output —
s3api list-objects-v2 on input prefix;
verify output bucket accepts writes.
- VPC —
ec2 describe-subnets + describe-vpc-endpoints;
confirm S3 / ECR endpoints or NAT gateway.
- Warm pool —
sagemaker list-warm-pools filtered by instance
type; confirm Status: Available and source job matches.
Pre-check failure → BLOCKED reasons:
| Failure |
Reason |
Fix |
EvalDecision: implicitDeny on s3:GetObject |
Role cannot read input bucket |
Attach an inline or managed policy granting s3:GetObject on arn:aws:s3:::<input-bucket>/* |
EvalDecision: implicitDeny on s3:PutObject |
Role cannot write output bucket |
Attach s3:PutObject on arn:aws:s3:::<output-bucket>/* |
EvalDecision: implicitDeny on kms:Decrypt |
Role cannot use the volume/output KMS key |
Attach kms:Decrypt and kms:GenerateDataKey on the KMS key ARN |
Service Quota value 0 for P5 / Trn1 |
Default quota is zero |
Request a quota increase via the Service Quotas console; P5 / Trn1 may also require AWS approval |
NoSuchBucket on input |
Input bucket does not exist or is in another account without cross-account access |
Confirm bucket name; add bucket policy granting the role read access |
VpcEndpoint State pending |
VPC endpoint not yet available |
Wait for available; or use NAT gateway as fallback |
WarmPoolResources[] empty for instance type |
No warm pool of matching instance type / image exists |
Either cold-start, or launch a warm-up job first |
Step 2: Launch training job
2a. Single-instance training
Full single-instance create-training-job CLI (algorithm spec, input channels, resource config, hyperparameters, VPC config, network isolation): references/job-creation-procedures.md.
Load on demand when emitting the launch command.
2b. Spot training with checkpointing
Full spot-training CLI (CheckpointConfig S3Uri + LocalPath, managed spot, MaxWaitTime vs MaxRuntime budget): references/job-creation-procedures.md.
Load on demand when configuring spot training.
2c. Distributed training (SMDDP)
Full SMDDP distributed CLI (sagemaker_distributed_dataparallel_enabled, num_processes, Training Compiler flag, SMDMP degrees): references/job-creation-procedures.md.
Load on demand when launching distributed training.
2d. Warm pool (reuse across sequential jobs)
Full warm-pool source/target job pair CLI (KeepAlivePeriodInSeconds, WarmPoolConfig PoolName): references/job-creation-procedures.md.
Load on demand when reusing clusters across jobs.
Step 3: Monitor job status
# Watch training job status:
aws sagemaker describe-training-job \
--training-job-name <name> \
--query '{status:TrainingJobStatus,secondary:SecondaryStatus,reason:FailureReason,elapsed:TrainingTimeInSeconds,billable:BillableTimeInSeconds,artifact:ModelArtifacts.S3ModelArtifacts}'
# Stream CloudWatch logs (live tail):
aws logs tail /aws/sagemaker/TrainingJobs --log-stream-name-prefix <name> --follow
# Block until completion or failure:
aws sagemaker wait training-job-completed-or-stopped \
--training-job-name <name>
Status transitions:
InProgress / Starting → cluster provisioning
InProgress / Downloading → input data download (or FastFile mode streaming)
InProgress / Training → training loop
InProgress / Uploading → model artifacts upload to S3
Completed → ModelArtifacts.S3ModelArtifacts populated
Failed → FailureReason populated (read it verbatim; cross-reference CloudWatch logs)
Stopped → operator-initiated stop completed
Stopping → stop requested, in progress
Step 4: Handle interruptions and failures
| Symptom |
Cause |
Resolution |
TrainingJobStatus: Failed, FailureReason: ClientError: ... insufficient capacity |
AWS could not provision the instance type (common for P5, Trn1) |
Retry; consider a training plan (capacity reservation) or fall back to P4de |
Failed, FailureReason: ... unauthorized S3 access |
Execution role missing s3:GetObject on input |
Attach the policy; relaunch |
Failed, FailureReason: ... image not found |
ECR image URI wrong, or role lacks ecr:BatchGetImage |
Verify the image URI; attach the policy |
Failed, FailureReason: ... CUDA error |
CPU image on GPU instance, or GPU image on CPU instance |
Match the image to the instance type |
Failed, FailureReason: ... out of memory |
Batch size too large for GPU memory; or VolumeSizeInGB too small for dataset |
Reduce batch size; increase volume size |
Interrupted (spot training) |
Spot capacity reclaimed |
Ensure CheckpointConfig is set; SageMaker auto-relaunches and resumes from checkpoint |
Failed, FailureReason: ... connection timed out |
VPC missing S3 endpoint or NAT |
Add S3 VPC endpoint (Gateway type) or NAT gateway; verify security group allows outbound HTTPS |
Failed, FailureReason: ... training compiler error |
Framework / image version not supported by Training Compiler |
Check the supported versions matrix; fall back to non-compiler image |
Step 5: Launch HPO (hyperparameter tuning)
Full create-hyper-parameter-tuning-job CLI (tuning job config, parameter ranges, early stopping, warm start): references/job-creation-procedures.md.
Load on demand when launching HPO.
Monitor via describe-hyper-parameter-tuning-job; the best training
job is reported in BestTrainingJob. The full HPO CLI script is in
references/job-creation-procedures.md.
Step 6: Register the model in the model registry
After the training job Completed, the registration flow is:
(1) create-model linking the artifact to an inference image;
(2) create-model-package-group (one-time per model lineage);
(3) create-model-package with InferenceSpecification,
ModelMetrics, and --approval-status PendingManualApproval;
(4) update-model-package --model-approval-status Approved once the
model passes review.
The full CLI script is in references/job-creation-procedures.md.
The model registry enables versioning, approval workflows, and
downstream deployment via the endpoint deployer skill.
Step 7: Decide — READY vs BLOCKED vs COMPLETED
- READY. All pre-checks passed; the operation plan is complete
and awaiting the CONFIRM gate. Output the exact CLI sequence.
- BLOCKED. One or more pre-checks failed (role, quota, image,
S3, VPC, warm pool) OR a launched job entered
Failed with a
FailureReason. Output the specific blocker and the fix.
- COMPLETED. A launched job entered
Completed with model
artifacts populated, or a stop job entered Stopped, or a model
package was registered successfully. Output the verification.
Step 8: Post-completion cleanup
| Cleanup action |
When |
How |
| Delete warm pool |
After the final job in a sequence |
aws sagemaker delete-warm-pool --warm-pool-id <id> (warm pools are billed while idle) |
| Adjust log retention |
After job completes |
aws logs put-retention-policy --log-group-name /aws/sagemaker/TrainingJobs --retention-in-days 30 |
| Delete failed jobs' artifacts |
Periodically |
aws s3 rm s3://<output-bucket>/models/<failed-job>/ --recursive |
| Release Training Plan |
If a training plan was reserved |
aws sagemaker delete-training-plan --training-plan-name <name> |
Output format
OPERATION: <launch-training-job | launch-spot | launch-distributed | launch-hpo | stop | register-model | describe | warm-pool>
VERDICT: READY | BLOCKED | COMPLETED
TARGET: <job-name, instance-type, region>
PRE_CHECKS:
- [PASS] <check description>
- [FAIL] <check description> — <reason>
STEPS:
1. <CLI command>
2. <wait command>
3. <next step>
POST_VERIFY:
- [PASS] <verification description>
- [FAIL] <verification description> — <reason>
MODEL_ARTIFACT: <S3 URI of model.tar.gz, or N/A>
LOG_GROUP: /aws/sagemaker/TrainingJobs
Worked example — launch distributed P5 training with SMDDP
See examples/README.md for a full worked example: a 4 ×
ml.p5.48xlarge (32-GPU) SMDDP launch with Training Compiler, VPC
isolation, and warm-pool handoff. The contract below applies.
Expert edge cases
The nine expert edge cases (P5/Trn1 zero quota, spot without checkpoint, num_processes semantics, Training Compiler versions, warm-pool idle billing, network-isolation endpoints, dual KMS keys, TrainingInputMode choice, training plans): references/advanced-patterns.md.
Load on demand when a job fails for a non-obvious reason.
Expert heuristic — "Pre-check the execution role and the quota before anything else"
The full heuristic with the FailureReason lookup table (unauthorized S3, image not found, capacity, CUDA/OOM, connection timeout, KMS, compiler error): references/advanced-patterns.md.
Load on demand when triaging a Failed job.
Anti-Patterns — NEVER
- NEVER launch a training job without first running
iam simulate-principal-policy on the execution role for S3,
KMS, and ECR permissions. Most Failed jobs are role-permission
failures that surface within seconds.
- NEVER launch a P5 or Trn1 job without first checking the
Service Quota. Both default to zero and require an increase
request before launch.
- NEVER enable
EnableManagedSpotTraining without
CheckpointConfig. Without checkpointing, each spot interruption
restarts from scratch.
- NEVER set
sagemaker_distributed_dataparallel_num_processes
to the instance count. It is the total GPU count across all
instances (e.g., 32 for 4 × ml.p5.48xlarge).
- NEVER use
FullyReplicated for SMDDP at scale. Use
ShardedByS3Key so each instance receives a shard.
- NEVER leave a warm pool running after the work sequence ends.
Warm pools bill at full instance rate while idle; call
delete-warm-pool when done.
- NEVER mix a GPU image with a CPU instance (or vice versa).
The job fails immediately with a CUDA error.
- NEVER use
--enable-network-isolation without confirming S3
and ECR VPC endpoints exist in the job's VPC. The job cannot pull
the image or read inputs without them.
- NEVER assume
MaxRuntimeInSeconds is the same as
MaxWaitTimeInSeconds for spot jobs. MaxWaitTime is the
wall-clock budget including interruptions; set it >> MaxRuntime.
- NEVER declare
COMPLETED for a job without verifying
ModelArtifacts.S3ModelArtifacts is populated and the S3 object
exists. A Completed status without an artifact indicates a
custom output configuration issue.
- NEVER register a model in the model registry without
specifying
ModelApprovalStatus (default PendingManualApproval
is correct for safety, but the operator must know the model is
not auto-deployable until approved).
- NEVER use
WarmStartType: IdenticalDataAndAlgorithm when the
dataset or algorithm has changed. Use TransferLearning instead.
- NEVER launch an HPO job without
TrainingJobEarlyStoppingType: Auto. Without early stopping, weak candidates run to
MaxRuntimeInSeconds, wasting budget.
Recent AWS features (2024-2026)
Recent AWS features 2024-2026 (P5/P5e, Training Compiler GA, training plans, warm pools GA, SMDDP v2, SMDMP, registry approval workflows, warm starts, FastFile): references/advanced-patterns.md.
Load on demand when selecting instances or input modes.
References
See references/job-creation-procedures.md for the full
per-operation CLI playbook (single-instance, spot, distributed,
warm pool, HPO, model registration) with worked examples, and
references/spot-and-distributed-training.md for the spot training
interruption model, SMDDP/SMDMP configuration, checkpoint patterns,
and Training Compiler integration.
References (load on demand)
- Advanced patterns — expert edge cases, the pre-check-role-and-quota heuristic with the FailureReason lookup table, recent AWS features (2024-2026)
- Job creation procedures — full per-operation CLI playbook: single-instance, spot, distributed (SMDDP), warm pool, HPO, model registration
- Spot and distributed training — spot interruption model, SMDDP/SMDMP configuration, checkpoint patterns, Training Compiler integration
Domain
AWS CloudOps / AI-ML — Model Training Operations.
AWS documentation
1---2name: sagemaker-training-job-operator3description: Operates Amazon SageMaker training jobs end-to-end — job creation (algorithm spec, input data S3 channels, output S3, instance type, volume size, hyperparameters), spot training (SpotInstanceConfig with checkpointing S3), distributed training (multi-GPU, multi-instance, SageMaker Distributed Data Parallel and Model Parallel), warm pools (reuse provisioned instances), automatic model tuning (HPO with warm starts), and model artifacts (register-model, model registry versioning). Covers SageMaker Training Compiler, P5 instances (H100), and training plan management. Runs deterministic pre-checks (instance quota, image existence, S3 input access, KMS, IAM role, VPC, warm pool availability), executes behind a CONFIRM gate, and emits READY | BLOCKED | COMPLETED with the exact CLI sequence and post-verification. Use when launching a training job, configuring spot/distributed training, setting up HPO, registering a model, or resolving a BLOCKED training job.4license: Apache-2.05compatibility: Agent runtime that reads SKILL.md (Claude Code, Cursor, Windsurf, Codex, Gemini). Offline plan classification works on a supplied job configuration. Live-account operations use aws sagemaker create-training-job, describe-training-job, stop-training-job, create-hyper-parameter-tuning-job, describe-hyper-parameter-tuning-job, create-model, create-model-package, describe-model-package-group, update-training-job (warm pools), aws service-quotas get-service-quota, and aws ec2 describe-instances...6metadata:7 source: https://skillmd.com/skills/jhkchan/sagemaker-training-job-operator8 domain: aws-cloudops9 complexity: high10 requires_llm: 'true'11 phase: '3'12 supports_pipeline: 'true'13 entry_point: 'false'14 family: AI/ML15 task_type: operate16 skill_class: capability17 lifecycle_status: active18 verdict_shape: READY | BLOCKED | COMPLETED19 when_to_use: Launching or operating a SageMaker training job (single-instance, spot, distributed, or warm-pool), configuring SageMaker Distributed Data Parallel or Model Parallel for multi-GPU / multi-instance training, setting up checkpoint S3 for spot recovery, launching an automatic model tuning (HPO) job with warm starts, registering a trained model in the model registry (register-model, create-model-package), resolving a BLOCKED training job (instance quota, image access, S3 permissions, VPC misconfiguration, warm pool capacity), or selecting the correct instance type (P5 / P5e H100, P4de A100, G5, Trn1) and Training Compiler configuration.20 when_not_to_use: SageMaker endpoint deployment or real-time inference (use the sagemaker-endpoint-deployer skill), SageMaker Studio or domain setup (use the sagemaker-studio operator), SageMaker audit and security posture (use the sagemaker-endpoint-auditor), or non-SageMaker training (EC2-based training, ECS, EKS).21 activation_triggers: SageMaker training job, create-training-job, spot training, SpotInstanceConfig, checkpoint S3, distributed training, SageMaker Distributed Data Parallel, SageMaker Distributed Model Parallel, warm pool, hyperparameter tuning, automatic model tuning, HPO, register-model, model registry, Training Compiler, P5 instance, H100 training, training plan, SageMaker training BLOCKED, training job Failed22 invocation_schema: 'Input: either (a) a training job configuration with the algorithm spec, input/output S3, instance type, hyperparameters, and optional spot/distributed/warm-pool/HPO settings, OR (b) a job-name + operation for live-account execution (launch, describe, stop, register-model). Output: a deterministic OPERATION / VERDICT / PRE_CHECKS / STEPS / POST_VERIFY block per operation, where VERDICT is one of READY, BLOCKED, COMPLETED.'23 version: 0.1.024 author: Jacky Chan — AWS Community Builder25 keywords: SageMaker, training job, spot training, SpotInstanceConfig, checkpointing, distributed training, SageMaker Distributed Data Parallel, SageMaker Distributed Model Parallel, warm pools, hyperparameter optimization, HPO, automatic model tuning, model registry, register-model, Training Compiler, P5 instances, H100, training plan, capacity reservation, algorithm spec26 tags: sagemaker, ai-ml, operate, training, distributed-training, hpo, model-registry27---2829# SageMaker Training Job Operator3031## Activation3233Activate this skill when the user reports a SageMaker training job34operation. Trigger phrases: "SageMaker training job",35"create-training-job", "spot training", "SpotInstanceConfig",36"checkpoint S3", "distributed training", "SageMaker Distributed Data37Parallel", "SageMaker Distributed Model Parallel", "warm pool",38"hyperparameter tuning", "automatic model tuning", "HPO",39"register-model", "model registry", "Training Compiler",40"P5 instance", "H100 training", "training plan", "SageMaker training41BLOCKED", "training job Failed".4243## Mindset4445**One-line takeaway:** a SageMaker training job is a container that46runs on a managed EC2 instance, reads input from S3, writes model47artifacts to S3, and emits CloudWatch logs — the operator's job is to48ensure the configuration is internally consistent (image matches49instance type, input channels are reachable, the execution role can50read/write S3 and KMS, the VPC has the right endpoints, and spot /51distributed / warm-pool settings are coherent) before launching, and52to monitor `SecondaryStatus` + `AlgorithmSpecification` until53`Completed`.5455Five SageMaker realities shape every operation:5657- **The execution role is the most common failure point.** SageMaker58 assumes the role you provide to read inputs from S3, write outputs59 to S3, pull the container image (if private), encrypt/decrypt with60 KMS, and (for VPC jobs) create ENIs. A missing `s3:GetObject` on61 the input bucket, `s3:PutObject` on the output bucket, or62 `kms:Decrypt` on the volume KMS key produces a `Failed` job within63 seconds. Always run pre-checks on the role before launching.6465- **Instance type dictates image and framework compatibility.** A66 GPU image (e.g., the PyTorch GPU training container) requires a67 GPU instance (`ml.p3.*`, `ml.p4d.*`, `ml.p4de.*`, `ml.p5.*`,68 `ml.g4dn.*`, `ml.g5.*`). A CPU image requires a CPU instance69 (`ml.m5.*`, `ml.c5.*`, `ml.r5.*`). AWS Trainium (`ml.trn1.*`)70 requires the Neuron container. Mismatch produces a `Failed` job71 immediately. P5 (H100) and Trn1 (Trainium) also require Service72 Quota approval — the default quota is zero.7374- **Spot training requires checkpointing to be useful.** Spot75 instances can be interrupted with 2 minutes' notice. Without76 checkpointing to S3, each interruption restarts the job from77 scratch. Configure both `EnableManagedSpotTraining: true` and78 `CheckpointConfig` (S3 URI + local path) — the framework79 (PyTorch / TensorFlow) must also load/save checkpoints at the80 configured path.8182- **Distributed training configuration must match instance83 topology.** SageMaker Distributed Data Parallel (SMDDP) requires84 multiple GPUs across one or more instances.85 `smdistributed:dataparallel` is a `HyperParameters` entry, not a86 top-level field. SageMaker Distributed Model Parallel (SMDMP)87 requires `smdistributed:modelparallel` with explicit88 `pipeline_parallel_degree`, `tensor_parallel_degree`, and89 `microbatches`. The framework entry point must call SMDDP / SMDMP90 primitives correctly — misconfiguration produces a silent91 performance regression (training runs but uses only one GPU).9293- **Warm pools persist the compute cluster between jobs.** A94 `WarmPoolConfig` keeps the cluster alive for a configurable95 `MaxIdleSeconds` (max 3600 seconds) after the previous job96 completes, so the next job starts in seconds rather than minutes.97 The next job must request the same instance type and image as the98 warm pool's source job — otherwise it falls back to a cold start.99 Warm pools are charged at standard instance rates while idle; they100 count against the warm-pool Service Quota (separate from101 training-job quota).102103## Quick reference — operation to verdict104105| Operation | Trigger condition | Verdict |106|---|---|---|107| **Launch training job** | All pre-checks passed; awaiting CONFIRM gate | `READY` |108| **Launch blocked** | Instance quota exhausted, image not found, S3 input inaccessible, role missing permissions, VPC misconfigured, warm pool capacity unavailable | `BLOCKED` |109| **Job in progress** | `TrainingJobStatus: InProgress`, `SecondaryStatus` reports training | `COMPLETED` once `TrainingJobStatus: Completed`; `BLOCKED` if `Failed` |110| **Job completed** | `TrainingJobStatus: Completed`, `ModelArtifacts.S3ModelArtifacts` populated, `TrainingTimeInSeconds` set | `COMPLETED` with artifact S3 path |111| **Job failed** | `TrainingJobStatus: Failed`, `FailureReason` populated | `BLOCKED` with the failure cause from `FailureReason` and CloudWatch logs |112| **Stop job** | `TrainingJobStatus: InProgress`, operator requests stop | `COMPLETED` once `TrainingJobStatus: Stopped` |113| **Register model** | Job `Completed`, operator requests model registry version | `READY` to `create-model-package` after pre-checks |114| **HPO launch** | Tuning config valid, base job pre-checks pass, warm start config (if any) valid | `READY` |115| **Warm pool reuse** | Source job `Completed`, target job instance type + image match, idle time < `MaxIdleSeconds` | `READY` (warm start) — otherwise cold start |116117**Pre-check priority order (apply in this sequence, all must pass118for READY):**1191201. **Execution role** — `iam simulate-principal-policy` for121 `s3:GetObject` on input, `s3:PutObject` on output, `kms:Decrypt`122 on KMS key, `ecr:BatchGetImage` if private image, plus the123 SageMaker-managed `AmazonSageMakerFullAccess` baseline.1242. **Instance quota** — `service-quotas get-service-quota` for125 `ml.<instance-type>` (P5, Trn1 default to zero — request an126 increase first).1273. **Image + instance compatibility** — GPU image requires GPU128 instance; Trainium image requires Trn1; Training Compiler129 requires a supported image and framework version.1304. **S3 input/output accessibility** — the role can read input, the131 input channels point at valid S3 prefixes, the output bucket132 exists and accepts writes.1335. **VPC configuration** (if specified) — subnets exist, security134 groups allow S3 (VPC endpoint or NAT) and ECR (VPC endpoint or135 NAT), KMS endpoint if KMS is used.1366. **Warm pool availability** (if `WarmPoolConfig` specified) — the137 source job's instance type and image match; the warm pool has138 not been reaped by `MaxIdleSeconds`.139140## Quick navigation141142- **Step 0** — Capture the operation target (job name, region,143 operation type, configuration).144- **Step 1** — Run pre-flight (role, quota, image, S3, VPC, warm145 pool).146- **Step 2** — Launch training job (single-instance, spot,147 distributed, warm pool).148- **Step 3** — Monitor `TrainingJobStatus` and `SecondaryStatus`149 until `Completed` or `Failed`.150- **Step 4** — Handle interruptions (spot, hard failure, log-driven151 debugging).152- **Step 5** — Launch HPO (hyperparameter tuning) with optional153 warm start.154- **Step 6** — Register the model artifact in the model registry155 (create-model, create-model-package).156- **Step 7** — Decide VERDICT (READY / BLOCKED / COMPLETED).157- **Step 8** — Post-completion cleanup (delete warm pool, log158 retention).159160## STRICT output contract161162Every response MUST begin with this block — no preamble, no163conversational opening:164165```text166OPERATION: <launch-training-job | launch-spot | launch-distributed | launch-hpo | stop | register-model | describe | warm-pool>167VERDICT: READY | BLOCKED | COMPLETED168TARGET: <job-name, instance-type, region>169PRE_CHECKS:170 - [PASS] <check description>171 - [FAIL] <check description> — <reason>172STEPS:173 1. <CLI command with flags populated>174 2. <wait command — aws sagemaker wait training-job-completed-or-stopped>175 3. <next step>176POST_VERIFY:177 - [PASS] <verification description>178 - [FAIL] <verification description> — <reason>179MODEL_ARTIFACT: <S3 URI of model.tar.gz, or N/A if not completed>180LOG_GROUP: <CloudWatch log group /aws/sagemaker/TrainingJobs>181CONFIRM: Before executing any state-changing CLI, emit and await182 operator approval: "CONFIRM: About to <operation> on <job> in183 <region>. Proceed? (yes/no)"184```185186Do NOT omit any field. If a field is not applicable, write `N/A`187with a one-line reason.188189## Process — Operation execution plan (apply in order)190191### Step 0: Capture the operation target192193Gather these inputs. Each downstream step branches on which is194present.195196| Signal | Source | Why required |197|---|---|---|198| **Operation type** | User-provided | launch / stop / describe / register-model / launch-hpo |199| **Job name + region** | User-provided | All SageMaker calls need this; the name must be unique in the account-region |200| **Algorithm spec (image or algorithm ARN)** | User-provided | Drives the container that runs |201| **Input data config (S3 channels)** | User-provided | Each channel (train, test, validation) is an S3 prefix |202| **Output data config (S3)** | User-provided | Where model.tar.gz is written |203| **Instance type + volume size** | User-provided | Drives GPU/CPU image compatibility and quota check |204| **Hyperparameters** | User-provided | Framework entry point, batch size, learning rate, distributed config |205| **Execution role ARN** | User-provided | SageMaker assumes this role; must have S3/KMS/ECR permissions |206| **Optional: spot, distributed, warm pool, HPO** | User-provided | Each adds additional pre-checks |207208If the user has not provided the job name or operation, emit209`VERDICT: BLOCKED` with the list of missing inputs and the discovery210command (`aws sagemaker list-training-jobs --status-equals InProgress`211or `Completed`).212213### Step 1: Pre-flight (role, quota, image, S3, VPC, warm pool)214215Run these checks before launch (skip for offline plan audit). The216canonical CLI sequence is in `references/diagnostic-commands.md` of217the references folder.2182191. **Execution role** — `iam simulate-principal-policy` for220 `s3:GetObject` on input, `s3:PutObject` on output, `kms:Decrypt`221 on KMS key, `ecr:BatchGetImage` if private image.2222. **Instance quota** — `service-quotas get-service-quota` for the223 instance type. P5 / Trn1 default to zero — request an increase.2243. **S3 input/output** — `s3api list-objects-v2` on input prefix;225 verify output bucket accepts writes.2264. **VPC** — `ec2 describe-subnets` + `describe-vpc-endpoints`;227 confirm S3 / ECR endpoints or NAT gateway.2285. **Warm pool** — `sagemaker list-warm-pools` filtered by instance229 type; confirm `Status: Available` and source job matches.230231**Pre-check failure → BLOCKED reasons:**232233| Failure | Reason | Fix |234|---|---|---|235| `EvalDecision: implicitDeny` on `s3:GetObject` | Role cannot read input bucket | Attach an inline or managed policy granting `s3:GetObject` on `arn:aws:s3:::<input-bucket>/*` |236| `EvalDecision: implicitDeny` on `s3:PutObject` | Role cannot write output bucket | Attach `s3:PutObject` on `arn:aws:s3:::<output-bucket>/*` |237| `EvalDecision: implicitDeny` on `kms:Decrypt` | Role cannot use the volume/output KMS key | Attach `kms:Decrypt` and `kms:GenerateDataKey` on the KMS key ARN |238| Service Quota value `0` for P5 / Trn1 | Default quota is zero | Request a quota increase via the Service Quotas console; P5 / Trn1 may also require AWS approval |239| `NoSuchBucket` on input | Input bucket does not exist or is in another account without cross-account access | Confirm bucket name; add bucket policy granting the role read access |240| `VpcEndpoint State pending` | VPC endpoint not yet available | Wait for `available`; or use NAT gateway as fallback |241| `WarmPoolResources[]` empty for instance type | No warm pool of matching instance type / image exists | Either cold-start, or launch a warm-up job first |242243### Step 2: Launch training job244245#### 2a. Single-instance training246Full single-instance create-training-job CLI (algorithm spec, input channels, resource config, hyperparameters, VPC config, network isolation): [references/job-creation-procedures.md](references/job-creation-procedures.md).247Load on demand when emitting the launch command.248249#### 2b. Spot training with checkpointing250Full spot-training CLI (CheckpointConfig S3Uri + LocalPath, managed spot, MaxWaitTime vs MaxRuntime budget): [references/job-creation-procedures.md](references/job-creation-procedures.md).251Load on demand when configuring spot training.252253#### 2c. Distributed training (SMDDP)254Full SMDDP distributed CLI (sagemaker_distributed_dataparallel_enabled, num_processes, Training Compiler flag, SMDMP degrees): [references/job-creation-procedures.md](references/job-creation-procedures.md).255Load on demand when launching distributed training.256257#### 2d. Warm pool (reuse across sequential jobs)258Full warm-pool source/target job pair CLI (KeepAlivePeriodInSeconds, WarmPoolConfig PoolName): [references/job-creation-procedures.md](references/job-creation-procedures.md).259Load on demand when reusing clusters across jobs.260261### Step 3: Monitor job status262263```bash264# Watch training job status:265aws sagemaker describe-training-job \266 --training-job-name <name> \267 --query '{status:TrainingJobStatus,secondary:SecondaryStatus,reason:FailureReason,elapsed:TrainingTimeInSeconds,billable:BillableTimeInSeconds,artifact:ModelArtifacts.S3ModelArtifacts}'268269# Stream CloudWatch logs (live tail):270aws logs tail /aws/sagemaker/TrainingJobs --log-stream-name-prefix <name> --follow271272# Block until completion or failure:273aws sagemaker wait training-job-completed-or-stopped \274 --training-job-name <name>275```276277**Status transitions:**278279- `InProgress` / `Starting` → cluster provisioning280- `InProgress` / `Downloading` → input data download (or FastFile mode streaming)281- `InProgress` / `Training` → training loop282- `InProgress` / `Uploading` → model artifacts upload to S3283- `Completed` → `ModelArtifacts.S3ModelArtifacts` populated284- `Failed` → `FailureReason` populated (read it verbatim; cross-reference CloudWatch logs)285- `Stopped` → operator-initiated stop completed286- `Stopping` → stop requested, in progress287288### Step 4: Handle interruptions and failures289290| Symptom | Cause | Resolution |291|---|---|---|292| `TrainingJobStatus: Failed`, `FailureReason: ClientError: ... insufficient capacity` | AWS could not provision the instance type (common for P5, Trn1) | Retry; consider a training plan (capacity reservation) or fall back to P4de |293| `Failed`, `FailureReason: ... unauthorized S3 access` | Execution role missing `s3:GetObject` on input | Attach the policy; relaunch |294| `Failed`, `FailureReason: ... image not found` | ECR image URI wrong, or role lacks `ecr:BatchGetImage` | Verify the image URI; attach the policy |295| `Failed`, `FailureReason: ... CUDA error` | CPU image on GPU instance, or GPU image on CPU instance | Match the image to the instance type |296| `Failed`, `FailureReason: ... out of memory` | Batch size too large for GPU memory; or `VolumeSizeInGB` too small for dataset | Reduce batch size; increase volume size |297| `Interrupted` (spot training) | Spot capacity reclaimed | Ensure `CheckpointConfig` is set; SageMaker auto-relaunches and resumes from checkpoint |298| `Failed`, `FailureReason: ... connection timed out` | VPC missing S3 endpoint or NAT | Add S3 VPC endpoint (Gateway type) or NAT gateway; verify security group allows outbound HTTPS |299| `Failed`, `FailureReason: ... training compiler error` | Framework / image version not supported by Training Compiler | Check the supported versions matrix; fall back to non-compiler image |300301### Step 5: Launch HPO (hyperparameter tuning)302Full create-hyper-parameter-tuning-job CLI (tuning job config, parameter ranges, early stopping, warm start): [references/job-creation-procedures.md](references/job-creation-procedures.md).303Load on demand when launching HPO.304305Monitor via `describe-hyper-parameter-tuning-job`; the best training306job is reported in `BestTrainingJob`. The full HPO CLI script is in307`references/job-creation-procedures.md`.308309### Step 6: Register the model in the model registry310311After the training job `Completed`, the registration flow is:312(1) `create-model` linking the artifact to an inference image;313(2) `create-model-package-group` (one-time per model lineage);314(3) `create-model-package` with `InferenceSpecification`,315 `ModelMetrics`, and `--approval-status PendingManualApproval`;316(4) `update-model-package --model-approval-status Approved` once the317 model passes review.318319The full CLI script is in `references/job-creation-procedures.md`.320The model registry enables versioning, approval workflows, and321downstream deployment via the endpoint deployer skill.322323### Step 7: Decide — READY vs BLOCKED vs COMPLETED324325- **READY.** All pre-checks passed; the operation plan is complete326 and awaiting the CONFIRM gate. Output the exact CLI sequence.327- **BLOCKED.** One or more pre-checks failed (role, quota, image,328 S3, VPC, warm pool) OR a launched job entered `Failed` with a329 `FailureReason`. Output the specific blocker and the fix.330- **COMPLETED.** A launched job entered `Completed` with model331 artifacts populated, or a stop job entered `Stopped`, or a model332 package was registered successfully. Output the verification.333334### Step 8: Post-completion cleanup335336| Cleanup action | When | How |337|---|---|---|338| Delete warm pool | After the final job in a sequence | `aws sagemaker delete-warm-pool --warm-pool-id <id>` (warm pools are billed while idle) |339| Adjust log retention | After job completes | `aws logs put-retention-policy --log-group-name /aws/sagemaker/TrainingJobs --retention-in-days 30` |340| Delete failed jobs' artifacts | Periodically | `aws s3 rm s3://<output-bucket>/models/<failed-job>/ --recursive` |341| Release Training Plan | If a training plan was reserved | `aws sagemaker delete-training-plan --training-plan-name <name>` |342343## Output format344345```text346OPERATION: <launch-training-job | launch-spot | launch-distributed | launch-hpo | stop | register-model | describe | warm-pool>347VERDICT: READY | BLOCKED | COMPLETED348TARGET: <job-name, instance-type, region>349PRE_CHECKS:350 - [PASS] <check description>351 - [FAIL] <check description> — <reason>352STEPS:353 1. <CLI command>354 2. <wait command>355 3. <next step>356POST_VERIFY:357 - [PASS] <verification description>358 - [FAIL] <verification description> — <reason>359MODEL_ARTIFACT: <S3 URI of model.tar.gz, or N/A>360LOG_GROUP: /aws/sagemaker/TrainingJobs361```362363### Worked example — launch distributed P5 training with SMDDP364365See `examples/README.md` for a full worked example: a 4 ×366`ml.p5.48xlarge` (32-GPU) SMDDP launch with Training Compiler, VPC367isolation, and warm-pool handoff. The contract below applies.368369## Expert edge cases370The nine expert edge cases (P5/Trn1 zero quota, spot without checkpoint, num_processes semantics, Training Compiler versions, warm-pool idle billing, network-isolation endpoints, dual KMS keys, TrainingInputMode choice, training plans): [references/advanced-patterns.md](references/advanced-patterns.md).371Load on demand when a job fails for a non-obvious reason.372373## Expert heuristic — "Pre-check the execution role and the quota before anything else"374The full heuristic with the FailureReason lookup table (unauthorized S3, image not found, capacity, CUDA/OOM, connection timeout, KMS, compiler error): [references/advanced-patterns.md](references/advanced-patterns.md).375Load on demand when triaging a Failed job.376377## Anti-Patterns — NEVER378379- **NEVER** launch a training job without first running380 `iam simulate-principal-policy` on the execution role for S3,381 KMS, and ECR permissions. Most `Failed` jobs are role-permission382 failures that surface within seconds.383- **NEVER** launch a P5 or Trn1 job without first checking the384 Service Quota. Both default to zero and require an increase385 request before launch.386- **NEVER** enable `EnableManagedSpotTraining` without387 `CheckpointConfig`. Without checkpointing, each spot interruption388 restarts from scratch.389- **NEVER** set `sagemaker_distributed_dataparallel_num_processes`390 to the instance count. It is the total GPU count across all391 instances (e.g., 32 for 4 × ml.p5.48xlarge).392- **NEVER** use `FullyReplicated` for SMDDP at scale. Use393 `ShardedByS3Key` so each instance receives a shard.394- **NEVER** leave a warm pool running after the work sequence ends.395 Warm pools bill at full instance rate while idle; call396 `delete-warm-pool` when done.397- **NEVER** mix a GPU image with a CPU instance (or vice versa).398 The job fails immediately with a CUDA error.399- **NEVER** use `--enable-network-isolation` without confirming S3400 and ECR VPC endpoints exist in the job's VPC. The job cannot pull401 the image or read inputs without them.402- **NEVER** assume `MaxRuntimeInSeconds` is the same as403 `MaxWaitTimeInSeconds` for spot jobs. `MaxWaitTime` is the404 wall-clock budget including interruptions; set it >> `MaxRuntime`.405- **NEVER** declare `COMPLETED` for a job without verifying406 `ModelArtifacts.S3ModelArtifacts` is populated and the S3 object407 exists. A `Completed` status without an artifact indicates a408 custom output configuration issue.409- **NEVER** register a model in the model registry without410 specifying `ModelApprovalStatus` (default `PendingManualApproval`411 is correct for safety, but the operator must know the model is412 not auto-deployable until approved).413- **NEVER** use `WarmStartType: IdenticalDataAndAlgorithm` when the414 dataset or algorithm has changed. Use `TransferLearning` instead.415- **NEVER** launch an HPO job without `TrainingJobEarlyStoppingType:416 Auto`. Without early stopping, weak candidates run to417 `MaxRuntimeInSeconds`, wasting budget.418419## Recent AWS features (2024-2026)420Recent AWS features 2024-2026 (P5/P5e, Training Compiler GA, training plans, warm pools GA, SMDDP v2, SMDMP, registry approval workflows, warm starts, FastFile): [references/advanced-patterns.md](references/advanced-patterns.md).421Load on demand when selecting instances or input modes.422423## References424425See `references/job-creation-procedures.md` for the full426per-operation CLI playbook (single-instance, spot, distributed,427warm pool, HPO, model registration) with worked examples, and428`references/spot-and-distributed-training.md` for the spot training429interruption model, SMDDP/SMDMP configuration, checkpoint patterns,430and Training Compiler integration.431432## References (load on demand)433434- [Advanced patterns](references/advanced-patterns.md) — expert edge cases, the pre-check-role-and-quota heuristic with the FailureReason lookup table, recent AWS features (2024-2026)435- [Job creation procedures](references/job-creation-procedures.md) — full per-operation CLI playbook: single-instance, spot, distributed (SMDDP), warm pool, HPO, model registration436- [Spot and distributed training](references/spot-and-distributed-training.md) — spot interruption model, SMDDP/SMDMP configuration, checkpoint patterns, Training Compiler integration437438## Domain439440AWS CloudOps / AI-ML — Model Training Operations.441442## AWS documentation443444- **SageMaker training jobs** — https://docs.aws.amazon.com/sagemaker/latest/dg/how-it-works-training.html445- **Managed spot training** — https://docs.aws.amazon.com/sagemaker/latest/dg/model-managed-spot-training.html446- **SageMaker Distributed Training** — https://docs.aws.amazon.com/sagemaker/latest/dg/distributed-training.html447- **Warm pools** — https://docs.aws.amazon.com/sagemaker/latest/dg/warm-pools.html448- **Automatic model tuning** — https://docs.aws.amazon.com/sagemaker/latest/dg/automatic-model-tuning.html449- **Model registry** — https://docs.aws.amazon.com/sagemaker/latest/dg/model-registry.html450- **Training Compiler** — https://docs.aws.amazon.com/sagemaker/latest/dg/training-compiler.html451- **SageMaker P5 instances** — https://docs.aws.amazon.com/sagemaker/latest/dg/train-p5.html452- **Training plans** — https://docs.aws.amazon.com/sagemaker/latest/dg/training-plans.html453- **CLI Reference** — https://docs.aws.amazon.com/cli/latest/reference/sagemaker/