Domain 2 of 4 · Chapter 2 of 3

Training & Refining Models

Unlock the complete study guide + 1,040 practice questions across 16 full exams.

Bundled into the existing AWS Certified Machine Learning Engineer - Associate premium course — no separate purchase.

Included in this chapter:

  • The training loop, and how to make it faster and cheaper
  • Hyperparameter tuning with SageMaker AMT
  • Bringing your own model, fighting overfitting, and versioning
  • Reading the question: which lever, which strategy

SageMaker AMT tuning strategies and when each fits

StrategyHow it searchesBest forConstraint
Bayesian optimizationLearns from completed jobs to propose better next configurationsContinuous ranges where each job is expensive; the efficient defaultLess parallelizable because each round informs the next
HyperbandMulti-fidelity: stops weak runs early and reallocates budget to strong onesLong deep-learning jobs with a meaningful intermediate metricNeeds an objective that improves during training
Random searchSamples configurations independently at randomA fair baseline; fully parallel across many jobsNo learning between jobs, so it can waste budget
Grid searchExhaustively tries every combinationSmall, fully categorical spaces you must cover completelyCategorical parameters only; combinations explode fast

Decision tree

Model fits on one GPU?does the model fit in device memoryModel-parallel trainingpartition layers across GPUsNoDataset large /job too slow?YesSingle instancedo not split a small jobNoData-parallel trainingmodel replica per GPUYesCan tolerate interruption?checkpointing in placeManaged spot trainingup to 90% off + checkpointsYesOn-demand instancesdeadline-critical, no reclaimNoAlways: early stoppingend when validation metric stalls

Cheat sheet

  • An epoch is one full pass over the data; a step processes one batch
  • Hyperparameters are set before training; parameters are learned during it
  • Use AMT Bayesian optimization when each training job is expensive
  • Use AMT Hyperband for long jobs with a useful intermediate metric
  • AMT grid search is categorical-only and exhaustive
  • Early stopping ends training when the validation metric stops improving
  • Pick distributed training by what does not fit: model vs data
  • Do not distribute a model that fits comfortably on one GPU
  • Managed spot training cuts training cost up to 90%
  • Pair managed spot with checkpointing so a reclaim resumes, not restarts
  • Warm pools keep clusters alive to skip cold start on the next job
  • Model size is driven by architecture, not data volume
  • Regularization fixes overfitting (high variance), never underfitting
  • L1 zeros weights (feature selection); L2 shrinks them smoothly
  • Dropout randomly disables neurons each step to stop co-adaptation
  • Use script mode to run your own TensorFlow or PyTorch code
  • Fine-tune a pre-trained model with JumpStart or Bedrock instead of training from scratch
  • Avoid catastrophic forgetting when fine-tuning on a narrow dataset
  • Ensembling: bagging is parallel, boosting is sequential, stacking learns a combiner
  • Shrink a model with pruning and quantization for a cheaper endpoint
  • Register every model version in the Model Registry for repeatable, auditable promotion
  • AMT warm start seeds a tuning job from up to 5 prior tuning jobs
  • In script mode, save the model to SM_MODEL_DIR and read inputs from SM_CHANNEL_
  • Add extra Python packages with a requirements.txt in source_dir, not a custom image
  • AMT early stopping needs TrainingJobEarlyStoppingType=AUTO and per-epoch objective metrics
  • Use AMT completion criteria to stop the whole tuning job once it stops improving
  • Use Logarithmic scaling for orders-of-magnitude ranges and ReverseLogarithmic near 1.0
  • Enable SMDDP for optimized multi-node AllReduce/AllGather on AWS
  • Scale the learning rate up (with warmup) as the global batch size grows
  • Combine sharding and tensor/context parallelism (SMP v2) to fit and scale huge models
  • Match the fine-tuning variant to your data: labeled pairs vs unlabeled domain text
  • Track runs with load_run()/log_metric() and pull results with ExperimentAnalytics

Unlock with Premium — includes all practice exams and the complete study guide.

References

  1. https://docs.aws.amazon.com/sagemaker/latest/dg/model-managed-spot-training.html
  2. https://docs.aws.amazon.com/sagemaker/latest/dg/train-warm-pools.html
  3. https://docs.aws.amazon.com/sagemaker/latest/dg/automatic-model-tuning-how-it-works.html
  4. https://docs.aws.amazon.com/sagemaker/latest/dg/automatic-model-tuning-warm-start.html
  5. https://docs.aws.amazon.com/sagemaker/latest/dg/pipelines-sdk.html
  6. https://docs.aws.amazon.com/sagemaker/latest/dg/tf.html
  7. https://docs.aws.amazon.com/sagemaker/latest/dg/pytorch.html
  8. https://docs.aws.amazon.com/sagemaker/latest/dg/your-algorithms.html
  9. https://docs.aws.amazon.com/sagemaker/latest/dg/studio-jumpstart.html
  10. https://docs.aws.amazon.com/bedrock/latest/userguide/custom-models.html
  11. https://docs.aws.amazon.com/sagemaker/latest/dg/model-registry-approve.html