How to Deploy an XGBoost Model with Custom Pre/Postprocessing on Vertex AI?
Short answer
C Use the Predictor interface to implement a custom prediction routine. Build the custom container, upload the container to Vertex AI Model Registry and deploy it to a Vertex AI endpoint.
Question
Key Takeaways
Tests understanding of Vertex AI custom prediction routines while highlighting the trap of separating model logic from transformation steps across different services.
This question evaluates deploying machine learning workloads on Google Cloud using Vertex AI custom containers to reduce infrastructure overhead. Community consensus confirms that leveraging the Predictor interface to bundle preprocessing, inference, and postprocessing together is the most efficient approach.
Common mistake: Option D is often selected due to familiarity with managed prebuilt containers, but it fails because offloading preprocessing to a separate Golang backend breaks the requirement for tightly integrated serving-time processing and increases operational complexity.
Expert Analysis
Why the Answer Is Correct
Option C correctly implements Vertex AI Custom Prediction Routines (CPR), allowing developers to extend the base Predictor class to handle custom load and predict workflows. Packaging the XGBoost model with Python-based preprocessing and postprocessing into a single custom container ensures all transformations execute within the same deployment unit. This strategy aligns with Google Cloud best practices for maintaining version consistency between data transformations and model weights while leveraging Vertex AI's managed endpoints for automatic scaling.
Why the Other Options Are Wrong
Options A and B propose building a generic FastAPI HTTP server, which introduces unnecessary boilerplate code and shifts infrastructure management responsibilities away from Vertex AI's optimized serving runtime. Option D suggests using the prebuilt XGBoost container but recommends moving critical data transformations to the Golang microservice, which creates inter-service latency, complicates dependency tracking, and directly contradicts the prompt's requirement to keep processing steps integrated at serving time.
Community Comment Notes
Multiple high-voted comments emphasize that custom containers provide full control over execution flow while simplifying deployment through a unified package. Comment [4] explicitly references the official Vertex AI documentation on custom prediction routines, validating that CPR natively supports embedding preprocessing and postprocessing logic. Although several users initially favored the managed prebuilt container for its simplicity, the discussion converged on Option C once the necessity of co-locating model and transformation code was clarified.
Official Reference
https://cloud.google.com/vertex-ai/docs/predictions/use-custom-container
This link opens the official vendor documentation in a new tab.
Exam Strategy
When scenarios emphasize bundled preprocessing or postprocessing alongside a trained model, immediately prioritize Vertex AI Custom Prediction Routines over custom web frameworks or external microservices. Familiarize yourself with how Vertex AI manages custom containers versus prebuilt images to quickly identify solutions that minimize both code complexity and ongoing infrastructure maintenance.
Community Votes
58% of anonymous learners picked answer C. Votes are pick records left by other test-takers — they are not the verified answer.
Discussion 9 contributions
Compiled from public community threads and reader submissions, lightly edited for clarity. Handles and vote tallies are shown as recorded, and comments reflect the views of individual contributors.
From public community threads 9
-
ddogg 👍 6 Answered CUse the Predictor interface to implement a custom prediction routine. This allows you to include the preprocessing and postprocessing steps in the same deployment package as your model. Build the custom container, which packages your model and the associated preprocessing and postprocessing code together, simplifying deployment. Upload the container to Vertex AI Model Registry. This makes your model available for deployment on Vertex AI. Deploy it to a Vertex AI endpoint. This allows your model to be used for online serving. https://blog.thecloudside.com/custom-predict-routines-in-vertex-ai-46a7473c95db
-
36bdc1e 👍 4C . Build the custom container, upload the container to Vertex AI Model Registry, and deploy it to a Vertex AI endpoint. This option allows you to leverage the power and simplicity of Vertex AI to serve your XGBoost model with minimal effort and customization. Vertex AI is a unified platform for building and deploying machine learning solutions on Google Cloud. Vertex AI can deploy a trained XGBoost model to an online prediction endpoint, which can provide low-latency predictions for individual instances. A custom prediction routine (CPR) is a Python script that defines the logic for preprocessing the input data, running the prediction, and postprocessing the output data.
-
guilhermebutzke 👍 2 Answered CMy answer C: Considering pre- and postprocessing implementation, The option C directly deals with implementing the processing steps in a custom container, offering full control over their placement and execution. This documentation says: “Custom prediction routines (CPR) lets you build [custom containers](https://cloud.google.com/vertex-ai/docs/predictions/use-custom-container) with pre/post processing code easily, without dealing with the details of setting up an HTTP server or building a container from scratch.” https://cloud.google.com/vertex-ai/docs/predictions/custom-prediction-routines So, it is better to use C instead of A or B. D is better because it offers the option of pre and post-processing, which is not available in D due to its use of prebuilt serving.
-
pikachu007 👍 2 Answered DConsidering the goal of minimizing code changes, infrastructure maintenance, and quickly deploying the model into production, option D seems to be a pragmatic approach. It leverages the prebuilt XGBoost serving container in Vertex AI, providing a managed environment for serving. The pre- and postprocessing steps can be implemented in the Golang backend service, maintaining consistency with the existing Golang implementation and reducing the need for significant code changes.
-
Prakzz 👍 2 Answered BThis approach minimizes code changes and infrastructure maintenance by leveraging Vertex AI's managed services for deployment. Implementing the preprocessing and postprocessing steps in a FastAPI server within a Docker container allows you to handle these steps at serving time efficiently. Deploying this Docker image to a Vertex AI endpoint simplifies the deployment process and reduces the burden of managing the infrastructure.
Show 4 more comments
-
AzureDP900 👍 1Option C is a good choice if You have specific requirements for preprocessing or postprocessing that can't be met by the prebuilt XGBoost serving container. You need more control over the deployment process or want to integrate with other services. You're comfortable building and managing custom containers. However, if you just want a simple, straightforward way to deploy your model as a RESTful API, Option D (using the XGBoost prebuilt serving container) might be a better fit!
-
Yan_X 👍 1 Answered Dし Pre-built XGBoost container already includes pre- and postprocessing steps.
-
livewalk 👍 1 Answered BFastAPI allows to create a lightweight HTTP server with minimal code.
-
vale_76_na_xxx 👍 1I would say D
Reader comments & corrections
No reader corrections yet — spotted an error or have a note? Share it below.
Related Analysis
Practice All PMLE Questions
Access 65 questions with complete answers and detailed explanations.
View Full PMLE Practice Test →