training
Use SageMaker Python SDK v3 training workflows with ModelTrainer, distributed drivers, JumpStart training, HPO, AWS Batch queues, and remote-function training concepts.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- training
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Use SageMaker Python SDK v3 training workflows with ModelTrainer, distributed drivers, JumpStart training, HPO, AWS Batch queues, and remote-function training concepts.
- disable-model-invocation
- true
02 资源文件 5
- 参考文档references/distributed-training.md2.6 KB
- 参考文档references/hyperparameter-tuning.md2.6 KB
- 参考文档references/modeltrainer-workflows.md3.3 KB
- 参考文档references/remote-function-and-advanced-training.md1.8 KB
- 参考文档references/troubleshooting.md1.9 KB
03 SKILL.md 正文
SageMaker Python SDK v3 Training Sub-skill
Use this sub-skill when the task is about general SageMaker training with the
v3 sagemaker-train package. Keep generated code v3-first and SDK-first.
Do not fall back to raw boto3 training-job requests unless the user explicitly
asks for low-level API calls or the SDK does not expose the needed feature.
Trigger phrases
Read this sub-skill when the user says or implies:
- "train a model on SageMaker" or "create a training job".
- "use ModelTrainer", "sagemaker-train", or "SDK v3 training".
- "local mode training", "local container training",
local_cpu, orlocal_gpu. - "distributed training", "torchrun", "MPI", "SMP", "multi-node", or "multi-GPU".
- "custom training container", "training image URI", or "retrieve a framework image".
- "JumpStart training" or
ModelTrainer.from_jumpstart_config(...). - "hyperparameter tuning", "HPO",
HyperparameterTuner,tune(), oranalytics(). - "AWS Batch training queue",
TrainingQueue, fair-share, priority, or quota share. - "remote function training job",
@remote,RemoteExecutor, or container drivers. - "migrate Estimator/framework estimator/fit to v3 training".
When not to read this sub-skill
- Foundation model customization, evaluation, data mixing, recipe overrides,
SFT, DPO, RLVR, RLAIF, CPT, or MultiTurnRL: route to
../model-customization/SKILL.md. - Model deployment, endpoint prediction, serverless/async real-time hosting,
local/in-process inference, or ModelBuilder: route to
../serving/SKILL.md. - Processing jobs, batch transform, low-level resources, sessions, default
buckets, image URI internals, or lineage primitives not tied to training:
route to
../core-resources/SKILL.md. - Pipelines, workflow steps, model registry, feature store, Clarify, or lineage
governance around training: route to
../mlops/SKILL.md. - Deprecated v2 maintenance work only: use the root migration reference first, then return here only for the v3 replacement.
V3 default policy
- Use
from sagemaker.train import ModelTrainerfor training orchestration. - Prefer current config imports from
sagemaker.core.training.configsforSourceCode,Compute,InputData,StoppingCondition,OutputDataConfig,CheckpointConfig, andNetworking. Some examples usesagemaker.train.configs; it is a v3 compatibility shim in this repo. - Use
from sagemaker.core import image_urisandimage_uris.retrieve(...)for framework image URI resolution. - Use
Session()andget_execution_role()fromsagemaker.core.helper.session_helperrather than hardcoded buckets, regions, account IDs, or role ARNs. - Use placeholders such as
<training-image-uri>,<role-name-or-arn>, ands3://<bucket>/<prefix>when exact customer resources are unknown. - Do not introduce v2
Estimator, framework estimator classes,fit(), v2Model, v2Predictor, v2Processor, or old workflow imports except in an explicitly labeled deprecated migration note.
Short workflow
- Classify the training task: single-job ModelTrainer, local container, distributed, JumpStart, HPO, AWS Batch queue, remote function, or migration.
- Confirm required execution substrate: no-submit config drafting, Docker local mode, SageMaker cloud job, AWS Batch queue, or MLOps pipeline.
- Establish AWS prerequisites if any cloud job may be submitted: region, credentials, execution role, S3 staging/output location, ECR image access, service quotas, and IAM permissions.
- Build config objects first:
SourceCode,Compute,InputData,StoppingCondition, optionalNetworking,OutputDataConfig,CheckpointConfig, and optional distributed config. - Resolve the training image with
image_uris.retrieve(...)or accept a user-provided custom image URI placeholder. - Construct
ModelTrainer(...); setroleexplicitly outside SageMaker managed notebooks if automatic role discovery is not guaranteed. - Validate before spend: prefer
trainer.train(..., dry_run=True)for cloud job configuration checks; for local mode also verify Docker/compose and local paths before callingtrain(). - Submit only when authorized:
train(wait=True, logs=True)for a blocking job,train(wait=False, logs=False)for fire-and-check-later, or use HPO/Batch entry points when the task requires them. - After training, route deployment to
../serving/SKILL.mdand route pipeline integration to../mlops/SKILL.md.
Reference map
references/modeltrainer-workflows.md: ModelTrainer signatures, imports, region/role/session setup, image retrieval, hyperparameters, local/SageMaker training, JumpStart, and validation.references/distributed-training.md: Torchrun, MPI, SMP, customDistributedConfig, driver environment variables, local multi-container training, and distributed troubleshooting.references/hyperparameter-tuning.md:HyperparameterTuner, parameter ranges, metrics,tune(),analytics(), warm starts/autotune, and MLOps handoff.references/remote-function-and-advanced-training.md: AWS BatchTrainingQueue, remote function andRemoteExecutor, container driver concepts, queue monitoring, and advanced routing boundaries.references/troubleshooting.md: region, credentials, role, Docker/local mode, image URI, source packaging, hyperparameters, distributed, HPO, JumpStart, Batch, and remote-function fixes.
Migration guardrail
Deprecated v2 training patterns map as follows; keep details concise here and
route broader migrations to ../../references/migration-v2-to-v3.md.
- Deprecated
sagemaker.estimator.Estimator-> v3sagemaker.train.ModelTrainer. - Deprecated framework estimators such as PyTorch, TensorFlow, SKLearn, XGBoost,
and HuggingFace classes -> v3
ModelTrainerplusimage_uris.retrieve(...). - Deprecated
estimator.fit(...)-> v3model_trainer.train(...)withInputData(channel_name=..., data_source=...). - Deprecated
instance_type/instance_counton estimators -> v3Compute(instance_type=..., instance_count=...). - Deprecated
entry_point/source_direstimator parameters -> v3SourceCode(entry_script=..., source_dir=...).
Quality checks before returning training guidance
- Confirm examples use v3 imports and do not contain real account IDs, role ARNs, bucket names, subnet IDs, security group IDs, regions hardcoded as the only option, or credentials.
- If examples use
sagemaker.train.configs, consider replacing withsagemaker.core.training.configsunless compatibility with an existing notebook is the explicit goal. - Verify
SourceCode.source_dircontains the namedentry_scriptand optionalrequirementsfile, or explain that cloud validation will fail. - For local mode, say Docker and Docker Compose are required and set
local_container_rootdeliberately when output location matters. - For distributed jobs, require
source_code.entry_scriptand pick one driver:Torchrun,MPI, or a customDistributedConfig. - For HPO, define metric regexes that match the training script logs and use
tuner.analytics()only after a tuning job exists. - For AWS Batch, require
Mode.SAGEMAKER_TRAINING_JOB; Batch queues do not accept local-container ModelTrainer jobs.
Common safe defaults
- Start with
Compute(instance_type="ml.m5.xlarge", instance_count=1)for CPU examples unless the user asks for GPU or a framework requires GPU. - Use
StoppingCondition(max_runtime_in_seconds=3600)in examples to bound cost. - Use
Session().boto_region_namefor region andSession().default_bucket()for sample S3 URI assembly. - Use
dry_run=Truewhen the user asks to validate configuration without launching a chargeable job. - Use
wait=Falseonly when the user wants asynchronous submission and you also show how to inspect or wait for the resulting job/tuner/queue object.
Handoff after training
- For deployment from a completed training job or model artifact, load
../serving/SKILL.md. - For a train/tune step inside a SageMaker Pipeline, load
../mlops/SKILL.md. - For low-level inspection of
TrainingJobresources or image URI behavior, load../core-resources/SKILL.md. - For foundation model customization/evaluation recipes, do not duplicate here;
load
../model-customization/SKILL.md.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).