ladderlore
  • Type a service name, like S3 or IAM.

Concept

Training jobs, script mode and ML libraries

Bring your own training script to an AWS framework container: you write the model code and SageMaker AI runs the job.

S3 as the ML data lake
Training script
Training job
S3 as the ML data lakeData channelsEntry pointmodel.tar.gz
What a training job reads and writes.
  • Built-in algorithm

    You bring
    Data and hyperparameters
    Pick when
    An algorithm in the list fits
  • Script mode

    You bring
    A training script
    Pick when
    Your own model code, common framework
  • Own container

    You bring
    The whole image
    Pick when
    Special libraries or runtime
Three ways to supply the algorithm.

What it is

A SageMaker AI training job runs a container on instances you name. You define it with the SageMaker Python SDK, using an estimator (SDK v2, still common on the exam) or ModelTrainer (the single class that replaces the estimators in SDK v3): the instance type and count, the container or framework version, hyperparameters, input data channels in Amazon S3 and an output location. SageMaker AI starts the instances, runs the training code, uploads the model to S3 and stops the instances, so you pay only while the job runs.

What it is

You have three ways to supply the algorithm. Built-in algorithms: AWS supplies the code and you supply data and hyperparameters. Script mode: AWS supplies a prebuilt framework container (scikit-learn, TensorFlow, PyTorch, Hugging Face, XGBoost and others) and you supply your own training script as the entry point. Bring your own container: you supply the whole image, for a library or setup no AWS container has.

What it is

Your script finds what it needs through environment variables and fixed paths. Hyperparameters arrive as command-line arguments, and as SM_HP_ variables. SM_CHANNEL_ followed by the channel name in capitals, such as SM_CHANNEL_TRAIN, is the folder with that input channel. SM_MODEL_DIR is where to save the model: whatever you save there is packed as model.tar.gz and uploaded to S3. SM_OUTPUT_DATA_DIR is for other output files, and SM_NUM_GPUS tells you how many GPUs the instance has.

What it is

Script mode keeps your code close to a laptop script while AWS handles the container, scaling and logs. Choose it over built-in algorithms when you need a custom model or library, and over your own container when a framework container is enough.

Remember

  • A training job is instances, a container, data channels, hyperparameters and an S3 output.
  • Script mode: your script in an AWS framework container.
  • Built-in: AWS supplies the code. Bring your own container: you supply the image.
  • Read data from SM_CHANNEL_<NAME>. Write the model to SM_MODEL_DIR.

Remember

  • Hyperparameters arrive as arguments and as SM_HP_ variables.
  • You pay for the time the job runs.

On the exam

  • “Run existing PyTorch code with few changes on managed GPU instances” points to script mode with the PyTorch framework container.
  • “A library that is in no AWS container” points to bring your own container.
  • “Model files must end up in S3” points to saving them to SM_MODEL_DIR.