PMLE - Serving and Scaling Models - Section 4.1

Serve models for batch and online inference using Agent Platform, Model Garden, Cloud Run, and GKE, packaging models from frameworks such as PyTorch and XGBoost with prebuilt and custom containers, versioning in the Model Registry, implementing rollout strategies such as A/B testing and canary deployments, and handling inference pre- and postprocessing.

Deploy models for online and batch inference on Agent Platform, Cloud Run, and GKE, packaging frameworks such as PyTorch and XGBoost in prebuilt or custom containers and versioning them in the Model Registry. Design rollout strategies such as canary deployments and A/B testing to reduce risk, and implement inference pre- and postprocessing to handle input transformation and output formatting.

Online and batch inferenceCustom containersModel RegistryCanary deployments

Practice question for this objective

Free sampleServing and Scaling Modelshard

A PyTorch model relies on a custom C++ operator and a SentencePiece tokenizer that are not present in any Vertex AI prebuilt serving container, and the team's inference handler must run tokenisation before the forward pass. They need online serving on Vertex AI. Which packaging approach lets them deploy this model successfully?

  • AUse the prebuilt PyTorch serving container and pass the tokeniser and custom operator as extra files in the model artifact directory at deploy time.
  • BConvert the model to the XGBoost format so the prebuilt XGBoost container can run the custom operator and tokeniser without extra dependencies.
  • CBuild a custom serving container that installs the C++ operator and tokeniser dependencies and implements the prediction route, then deploy it to a Vertex AI online endpoint. Correct
  • DDeploy the model to a batch prediction job, because batch jobs automatically install any missing system libraries the handler imports.
Choose a custom serving container when a model needs system libraries or custom operators that prebuilt containers do not include. Prebuilt containers ship a fixed dependency set and cannot gain unlisted system libraries or compiled custom operators at deploy time, so a model needing those plus custom preprocessing must run in a custom container that installs them and implements the prediction route.

Why A is wrong: Bundling extra files seems to extend the prebuilt container, but that container only installs its fixed dependency set, so an unlisted system library and a compiled custom operator will not be available at runtime and serving fails.

Why B is wrong: Switching to the XGBoost container sounds like a way to dodge missing PyTorch dependencies, but XGBoost is a gradient-boosting runtime that cannot execute a PyTorch graph or a custom C++ operator, so the model could not run at all.

Why C is correct: A custom container lets the team install the exact system libraries, compile the custom operator, and implement the preprocessing prediction route, which is the supported path when prebuilt containers lack required dependencies.

Why D is wrong: Choosing batch prediction appears to sidestep container limits, but batch jobs use the same container constraints and do not auto-install arbitrary system libraries, and the requirement is online serving rather than offline scoring.

See more PMLE practice questions with worked answers.

More in this domain

Back to all Serving and Scaling Models objectives, or the PMLE cert hub.

Examworthy is not affiliated with or endorsed by Google Cloud. Original, blueprint-aligned practice material only.