MLS-C01 TorchScript Practice Question
A data scientist is deploying a model on Amazon SageMaker for real-time inference. The model is a PyTorch model that requires custom inference code. The data scientist needs to handle variable-length inputs and optimize inference latency. Which TWO steps should the data scientist take? (Choose TWO.)
⚠ Common exam trap
A common trap is assuming that batch transform can be used for real-time inference. However, SageMaker Batch Transform is meant for offline, asynchronous processing and cannot meet real-time latency requirements.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Use TorchScript to compile the model for optimized inference.
TorchScript compiles PyTorch models for optimized inference, reducing execution time and handling variable-length inputs efficiently. Option E is correct because a custom inference script (inference.py) is required to define preprocessing, prediction, and postprocessing logic for variable-length inputs. Option A is incorrect because SageMaker Batch Transform is designed for offline, asynchronous inference and cannot be used for real-time endpoints with sub-second latency. Options B and C are also incorrect: using the PyTorch container without modifications would not support custom inference code, and multiple variants are for A/B testing, not latency optimization.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Enable SageMaker batch transform to process requests in batches.
Why it's wrong here
Incorrect. SageMaker Batch Transform is designed for offline, asynchronous inference, not for real-time endpoints with sub-second latency. It cannot optimize real-time inference latency.
- ✗
Use the SageMaker PyTorch container without any modifications.
Why it's wrong here
Incorrect. Using the SageMaker PyTorch container without modifications does not allow custom inference code, which is required for variable-length inputs.
- ✗
Set the endpoint to use multiple variants for A/B testing.
Why it's wrong here
Incorrect. Setting up multiple endpoint variants is for A/B testing, not for handling variable-length inputs or optimizing inference latency.
- ✓
Use TorchScript to compile the model for optimized inference.
Why this is correct
Correct. TorchScript compiles PyTorch models for optimized inference, reducing execution time and efficiently handling variable-length inputs.
- ✓
Provide a custom inference script (inference.py) that defines how to load the model and process requests.
Why this is correct
Correct. A custom inference script is necessary to define how to load the model, preprocess variable-length inputs, and postprocess predictions.
Go deeper
Related to this question
About these practice questions
This MLS-C01 question is part of Courseiva's 1,672-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This MLS-C01 practice question is part of Courseiva's free Amazon Web Services certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the MLS-C01 exam.