GcpIntermediate

MLOps on Google Cloud: Building Production ML Pipelines

Admin KC
8 min read

TL;DR

Learn how to implement MLOps practices on Google Cloud Platform. Covers Vertex AI, Cloud Build, and automated ML pipelines.

MLOps on Google Cloud: Building Production ML Pipelines

Executive Summary

MLOps is the set of practices that makes machine learning repeatable: versioned data and code, pipelines that train the same way every time, evaluation gates that a model must pass before it serves traffic, and monitoring that notices when the world drifts away from the training data. On Google Cloud, Vertex AI is the centre of gravity — datasets, training, model registry, endpoints, pipelines, and monitoring in one platform — with Cloud Build and Cloud Storage around it. This guide walks through the pipeline stages and the decisions at each one, so you can move from a notebook that works to a system that keeps working.

Why This Matters

Most ML failures in production are not modelling failures. They are a training script that only runs on one person's machine, a model promoted because it felt better, training data nobody can reconstruct, or silent drift that degrades predictions for weeks before anyone checks. Each is a process failure, and each is preventable with the same discipline software engineering adopted years ago: version control, automated pipelines, tests, and monitoring. The cost of skipping it is asymmetric — a notebook takes a day to write and a quarter to productionise under incident pressure. MLOps is how you pay that cost gradually, on your own schedule, instead of all at once during an outage.

Core Concepts

The Platform Pieces

Vertex AI holds the ML-specific assets: managed datasets, training jobs (custom containers or AutoML), the Model Registry as the versioned catalogue of approved models, endpoints for online serving, batch prediction for offline scoring, and Vertex AI Pipelines — managed Kubeflow Pipelines — for orchestration. Cloud Storage holds the raw artefacts: training data, model binaries, pipeline outputs. Cloud Build (or your existing CI) builds training and serving containers and triggers pipeline runs. Everything is initialised and driven through one SDK:

from google.cloud import aiplatform
from google.cloud import storage
import tensorflow as tf

# Initialize Vertex AI
aiplatform.init(project='your-project-id')

Data and Versioning

A model is a function of its data and its code, so both must be versioned to make any result reproducible. Register datasets in Vertex AI rather than pointing training jobs at ad-hoc bucket paths, keep feature and label definitions in code review, and record the dataset version on every trained model. The practical test: given a model in production, can you check out the exact code and the exact data that produced it? If not, you cannot debug it, retrain it safely, or explain it to a regulator.

Training as a Pipeline, Not a Script

Training belongs in a pipeline with explicit steps — validate data, preprocess, train, evaluate, register — each producing artefacts the next step consumes. AutoML shows the shape of a managed training job:

# Define training pipeline
training_pipeline = aiplatform.AutoMLTabularTrainingJob(
    display_name="ml_training_job",
    optimization_objective="minimize-rmse"
)

# Start training
model = training_pipeline.run(
    dataset=dataset,
    target_column="target",
    budget_milli_node_hours=1000
)

For custom models, the same structure applies with your own training container: the pipeline passes dataset locations and hyperparameters in, and a trained model artefact plus evaluation metrics come out. Pipelines also give you caching for free — unchanged steps with unchanged inputs are skipped on rerun, which makes experimentation dramatically cheaper.

Evaluation Gates

A trained model is a candidate, not a release. Promotion should be gated on automated checks against a held-out dataset: quality metrics against a threshold and against the currently deployed model, plus sanity checks on prediction shape and latency. Express the gate as code that fails the pipeline:

def test_model_performance(model, test_data):
    predictions = model.predict(test_data)
    metrics = calculate_metrics(predictions, test_data.labels)
    
    # Performance thresholds
    assert metrics['accuracy'] > 0.85
    assert metrics['latency'] < 100  # ms

Thresholds must come from the model's actual requirements, not round numbers copied from a tutorial — and a candidate that cannot beat the incumbent on the evaluation set does not deploy, however new it is.

CI/CD for Models

The delivery pipeline builds containers, runs tests, executes the training pipeline, and deploys only on gate passage. Cloud Build is the native option:

steps:
- name: 'gcr.io/cloud-builders/docker'
  args: ['build', '-t', 'gcr.io/$PROJECT_ID/ml-pipeline', '.']

- name: 'gcr.io/cloud-builders/docker'
  args: ['push', 'gcr.io/$PROJECT_ID/ml-pipeline']

Deployment itself goes through the Vertex AI SDK or gcloud ai endpoints deploy-model, uploading the approved model version from the registry to an endpoint with an explicit traffic split, so a new model can take a fraction of traffic before it takes all of it. Keep humans in the loop where the blast radius is large: an approval step before production promotion is a feature, not a failure of automation.

Monitoring: Drift Is the Default

A deployed model begins decaying immediately, because the world changes and the training data does not. Vertex AI Model Monitoring watches deployed endpoints for two distinct problems: training-serving skew (live inputs differing from training data because a feature pipeline changed) and drift (live inputs gradually moving away from the training distribution). Configure monitoring on every production endpoint, with alert thresholds the team has agreed mean "retrain or roll back," and route alerts somewhere a human will see them. Prediction latency, error rates, and resource use belong on the same dashboard — a model can be accurate and still be failing its users by being slow.

Decision Framework

SituationRecommendation
Tabular problem, small team, speed mattersAutoML training inside a Vertex pipeline; spend your time on data quality
Custom architecture or framework needsCustom training containers orchestrated by Vertex AI Pipelines
Model already trained elsewhereImport it into the Model Registry and still gain versioning, endpoints, and monitoring
High-throughput offline scoringBatch prediction jobs instead of an online endpoint
Regulated or high-impact decisionsAdd human approval gates, model cards, and full lineage before automation
Prototype or one-off analysisA notebook is fine — but keep it out of production until the pipeline exists

Implementation Checklist

  • [ ] Training data registered as versioned Vertex AI datasets; no training directly from ad-hoc files
  • [ ] Code, configuration, and data version recorded for every registered model
  • [ ] Training expressed as a pipeline with separate validate, train, and evaluate steps
  • [ ] Automated evaluation gate compares candidates against thresholds and the incumbent model
  • [ ] CI builds containers and runs unit and integration tests before any training run
  • [ ] Deployment uses traffic splitting, with a tested rollback to the previous model version
  • [ ] Model monitoring enabled on every production endpoint, with drift alerts routed to the owning team
  • [ ] Retraining triggers defined (schedule, drift alert, new data) instead of left to memory
  • [ ] Model card or equivalent documentation written for each production model
  • Trade-offs

    Pipelines and gates add latency to ideas: the first model takes longer to ship inside an MLOps system than as a notebook, and the payoff arrives on the second, fifth, and fiftieth model. Vertex AI's integration is convenient and creates platform gravity — pipelines, registry, and monitoring are GCP-shaped, so portability to another cloud means rebuilding the operational layer even if the model artefacts move. Managed training also costs more per run than a hand-tuned VM you babysit yourself; what you are buying is repeatability and an audit trail. Finally, monitoring tells you the world changed, not what to do about it — retraining on drifted data without understanding why it drifted can automate a mistake.

    When Not to Use

  • One-off analysis or a model that will never serve traffic: a notebook and a saved artefact are enough; pipeline infrastructure would be ceremony.
  • Trivial, stable heuristics: if a rules engine or a SQL query matches the model's accuracy, ship that instead — it is cheaper to run and easier to explain.
  • You cannot maintain the data pipeline: a model whose features cannot be produced reliably in production should not be deployed, however good its offline metrics look.
  • Ultra-low-latency or on-device inference: export the model (for example to an optimised runtime or TensorFlow Lite) and serve it in your own stack rather than through a managed endpoint.
  • Conclusion

    MLOps on Google Cloud is mostly the disciplined assembly of Vertex AI parts: versioned datasets, pipeline-based training, gated promotion from the Model Registry, traffic-split deployment, and monitoring that assumes drift. Build the pipeline once and every subsequent model is cheaper, safer, and easier to explain. The goal is not more process — it is never having to ask how the model in production was produced.

    References

  • Vertex AI Documentation
  • Cloud Build Documentation
  • MLOps Best Practices
  • Why This Matters

    Understanding the business and technical context helps you make informed decisions rather than blindly following patterns.

    Trade-offs to Consider

    Every architectural decision involves trade-offs. Consider your specific requirements, team expertise, and scale when evaluating options.

    When NOT to Use This

    Knowing when a solution doesn't apply is as valuable as knowing when it does. Consider alternatives for your specific situation.

    Decision Framework

    Use this framework to evaluate whether this approach is right for your use case based on your specific constraints and requirements.

    Share this articleShare on XShare on LinkedIn

    Keep the decision frameworks coming

    One practical architecture guide a week — patterns, trade-offs, and when not to use them. No spam, unsubscribe anytime.