Prepare and test your skills
Prepare and test your skills
Developing end-to-end ML pipelines is the practice of connecting data validation, preprocessing, training, evaluation, and deployment into one automated and traceable system. Gemini Enterprise Agent Platform Pipelines (opens in a new tab) is the managed serverless orchestrator for directed acyclic graphs (DAGs), where developer code flows to the managed control plane and the control plane launches each containerized component, passes output artifacts as inputs to later components, and records lineage in Vertex ML Metadata. Data flows from ingestion through validation to feature engineering and training, only validated data flows forward, and validation metrics flow to observability and retraining triggers.
Model evaluation separates predictive effectiveness from operational acceptability and fairness. Vertex AI Model Evaluation runs evaluations alone or as a pipeline component, compares model versions on defined metrics and datasets, and logs results to Vertex ML Metadata for lineage. A model moves to production only when it meets predictive thresholds, satisfies operational limits, and performs similarly across sensitive data slices.
| Metric type | What it measures | Decision rule |
|---|---|---|
| Optimizing metrics | Predictive effectiveness such as accuracy, f-measure, mean absolute percentage error, discounted cumulative gain, perplexity, and BLEU | Higher is better; improve during experimentation |
| Satisficing metrics | Operational constraint such as prediction latency below 200 milliseconds or model size for mobile and embedded devices | Must stay within threshold; reject if violated |
Fairness requires the same optimizing metrics to be compared across slices such as customer demographics. Similar effectiveness across slices indicates equitable behavior, while a large gap signals bias even when overall accuracy looks high. Experiment discipline keeps comparisons honest by fixing thresholds before work starts, keeping a baseline such as heuristics or a mean predictor, tracking hyperparameters and random seeds, tuning on a validation split, and reserving an unseen holdout test split for the final check.
Exam tip: A model with high overall accuracy can still fail review if one demographic slice scores much lower; gate deployment on per-slice thresholds, not only the aggregate metric.
Data quality enforcement validates data as it flows from ingestion through preprocessing, training, and serving. TensorFlow Data Validation (TFDV) infers a baseline schema from trusted training data, computes per-feature statistics, and emits anomalies when features are missing, mistyped, or out of range. Because the schema depends on that baseline, an intentional change such as a new category requires a versioned schema update before new data is accepted.
BigQuery handles large-scale SQL quality rules and historical tracking, while Cloud Dataflow (Dataflow) handles complex programmatic rules on batch and streaming data with Apache Beam. Validation results flow to BigQuery for trend analysis and validation artifacts flow to Cloud Storage for audit and debugging. Distribution monitoring closes the loop when TFDV statistics flow into Cloud Monitoring alerts, which then trigger a retraining pipeline after a meaningful shift is confirmed.
Data skew and data drift are two different distribution failures that degrade accuracy even when model code has not changed. Data skew is a significant difference between the feature distribution in training data and the feature distribution in serving data in production. Data drift is a significant change in feature distribution in production over time, detected across consecutive spans of serving data such as different days.
Basic monitoring uses built-in BigQuery ML functions without managing TFDV protocol buffers. ML.DESCRIBE_DATA computes descriptive statistics to confirm datasets are within expected parameters. ML.VALIDATE_DATA_SKEW compares serving statistics to training statistics saved inside the model at creation time, and it only computes statistics for serving columns that match training feature columns for better performance and lower cost. ML.VALIDATE_DATA_DRIFT compares two serving datasets, for example current serving data versus a table snapshot or versus output from ML.FEATURES_AT_TIME. Advanced monitoring uses ML.TFDV_DESCRIBE to generate fine-grained statistics as JSON protocol buffers and ML.TFDV_VALIDATE to compare two payloads in SKEW or drift mode for integration with external monitoring. The basic skew workflow runs in order: first describe training and serving data, then train the model to save training statistics, then run ML.VALIDATE_DATA_SKEW, then investigate, adjust training data, and retrain if skew is found.
Robustness and operational validation prove a model stays correct, safe, and fast under corrupted inputs and production load. All models are tested for common data corruptions and malicious modifications, with tests orchestrated by Vertex AI Pipelines. Security-critical models add full adversarial attack simulations, containerized models add vulnerability scanning with Artifact Analysis in Artifact Registry, and drift findings feed back into re-evaluation or retraining so validation is continuous.
Stress testing uses automated bulk evaluation across diverse datasets plus load tools such as Locust, Grafana k6, and Apache JMeter to measure latency, error rate, and resource use. Generative AI adds perplexity, image fidelity, toxicity, coherence, grounding against source text, and human-in-the-loop review for creativity and safety. Operational gates quantify service level objectives (SLOs) from the user perspective, such as 99.9% API success, 95th percentile inference latency below 300 ms, time to first token below 500 ms for 99% of requests, and harmful output rate below 0.1%. The gated promotion sequence runs in order: evaluate on validation or holdout data, compare versions against metric and fairness thresholds, log lineage to Vertex ML Metadata, and register the passing version in Model Registry. Traffic then shifts only after endpoint checks for correctness, latency, throughput, and API function pass. Once deployed, Vertex Model Monitoring tracks prediction distributions, low-confidence spikes, data drift, and prediction drift, feeds Cloud Monitoring dashboards, and triggers notifications or retraining pipelines when thresholds are breached.
Pipeline orchestration architecture is the decision about how machine learning steps are defined, packaged, and run as one connected system. Choose the managed service when serverless operation, automatic artifact tracking, scheduled runs, and execution metrics outweigh direct cluster control, and choose self-managed Kubeflow or self-hosted Airflow when portability across Kubernetes and direct cluster control outweigh maintenance overhead. Managed orchestration automates data processing, training, evaluation, and deployment with modular components, schedules or triggers such as new data arrivals, automated parameterization and versioning, and monitoring through logging, tracing, and Cloud Monitoring alerts.
SDK selection determines how much structure and TensorFlow optimization the DAG inherits. Kubeflow Pipelines (KFP) SDK v2.0 or later defines reusable workflows where each step is a containerized component with input parameters and output artifacts, supporting control-flow logic, prompt management, batched inference, and coordination of agent components. TensorFlow Extended (TFX) v0.30.0 or later provides pipeline components whose data libraries use Apache Beam directly, so TensorFlow Transform calls translate to Beam operations without extra configuration. Building a KFP-based pipeline follows an ordered workflow where each stage depends on the prior stage: first define the workflow with the KFP domain-specific language and configure authentication, then compile the definition to YAML and integrate compilation into CI/CD, then submit the YAML for execution optionally on a Cloud Scheduler trigger with conditional gates. Choose TFX when the workflow processes terabytes of structured or text data in TensorFlow and benefits from built-in Beam integration, and choose KFP for general-purpose modular components and broad reuse.
Dataflow integration determines where Apache Beam code lives and who manages packaging and dependencies. Dataflow runs scalable batch and stream preprocessing inside the DAG with the Apache Beam runner, where data flows from upstream components into a Dataflow job and transformed output flows back to training with a CustomJob, registration in Model Registry, and deployment to endpoints.
| Integration option | How Beam code is packaged | Complexity and control tradeoff |
|---|---|---|
| Built-in Beam integration with TFX or KFP | Use native libraries or operators that already invoke Beam and the Dataflow runner | Least complex; fastest development, least custom control |
| Dataflow template called from pipeline | Build Beam logic as a template, then call it from a component | Medium complexity; isolates processing for reuse with separate versioning |
| Fully custom component with inline Beam pipeline | Define custom Python Beam code inside the component with the Dataflow runner | Most complex; maximum control, team manages all dependencies |
ML accelerator selection determines whether intensive Dataflow steps scale through parallelism alone or through specialized hardware. Dataflow workers can attach NVIDIA GPUs of types T4, L4, A100, H100, and V100, but GPU use requires a custom container with drivers and libraries. Dataflow also supports Cloud TPUs in single-host configurations where each worker manages one or more devices. Choose GPUs for broadly supported acceleration with explicit driver control, and choose TPUs for TPU-optimized frameworks such as PyTorch, JAX, and TensorFlow where the workload fits the single-host model.
Reliable pipeline components are containerized steps with typed interfaces, controlled resources, and validation that decides whether to stop or retrain. Each component runs in its own container with its own runtime and libraries, which makes code reproducible across development and production. Preprocessing uses Dataflow for Beam batch and stream work, Managed Service for Apache Spark for Spark-native work, or BigQuery for SQL transforms with data-quality scans. Training uses the CustomJob resource to submit jobs without provisioning infrastructure, defining machine type, accelerator type and count, and worker pools, with Spot VMs for interrupt-tolerant jobs that checkpoint and endpoint autoscaling with a minimum of two replicas for high availability.
Reliability depends on validation at the right boundary. Data schema skews such as unexpected or missing features require stopping the pipeline for investigation, while data values skews or significant statistical changes require retraining to capture new patterns. Offline model validation then runs in order: evaluate the new model on a test set, compare against production or baseline and promote only on improvement, verify consistent performance across slices such as per-region accuracy, and verify infrastructure compatibility followed by canary or A/B online validation. Operational excellence detects failures quickly and proves what ran and why. Pipeline execution metrics flow into Cloud Monitoring for dashboards and alerts, component events flow to Cloud Logging, request flow is traced with Cloud Trace, and code bottlenecks are profiled with Cloud Profiler. Governance ties runs to artifacts through Model Registry versions, Cloud Storage model files, Artifact Registry images, Experiments lineage, Knowledge Catalog discovery, least-privilege Identity and Access Management (IAM) service accounts, and Cloud Audit Logs streamed to Cloud Logging and exported to BigQuery.
Consistent preprocessing between training and serving means the same transformation code produces features for both training examples and live prediction requests. Vertex AI Inference enforces this by running preprocessing inside the serving container boundary, so traffic flows from the raw request through preprocessing, model inference, and postprocessing inside one versioned artifact. When preprocessing lives outside in a separate client, gateway, or feature pipeline, the training path and serving path can drift through separate code or mismatched libraries.
Custom prediction routines run custom preprocessing and postprocessing on a prebuilt serving stack with a declared model signature for inputs and outputs. Custom containers package the full serving application, including web server, preprocessing code, model loader, and dependencies, and follow a fixed request lifecycle: first preprocess the raw payload into model-ready features, then pass features to the loaded model for scores, then postprocess outputs to the declared response schema. Use Private Service Connect private endpoints to keep inference inside a Virtual Private Cloud (VPC) network while the container enforces its schema. Use a custom prediction routine when a prebuilt container supports the framework but identical custom preprocessing is needed, and use a full custom container when dependencies or logic cannot be expressed on the prebuilt stack. Versioned transformation artifacts such as a TensorFlow Transform graph, a scikit-learn pipeline, an Apache Beam pipeline, or a container that embeds preprocessing code must travel with the model binary. Model Registry is the system of record for model versions, where each version links to artifacts, training parameters, evaluation metrics, dataset version, and code version, while Artifact Registry is the immutable store for images, components, and configs with Binary Authorization gating. Vertex AI Feature Store strengthens consistency by centralizing feature definitions with an online store and feature views backed by BigQuery, so offline training and low-latency online serving resolve to identical definitions.
Continue with this study guide: Developing end-to-end ML pipelines
Automating model retraining is the controlled automation that decides what data a model relearns from, how prior learning is reused, when a new run starts, and when a candidate is safe to replace production. The policy combines a data window with a computation mode and constrains both by label latency, feature freshness, and Cloud compute budget. The full loop flows from trigger to training to evaluation gate to registry to staged rollout, with monitoring signals flowing back to trigger retraining or rollback.
Cold-start retraining and warm-start training are two computation modes that differ in initialization, cost, and adaptation behavior. Cold-start retraining trains from new initialization on the full selected window, so each schedule is an independent job that depends only on the curated window. Warm-start training initializes from the previous production checkpoint and continues optimization on new data, so the new model depends on prior model weights, optimizer state, and compatible architecture.
| Strategy | Initialization | Compute and Time Cost | Adaptation Behavior |
|---|---|---|---|
| Cold-start retraining | New initialization on full window | High, scales with total window size on every run | Relearns long-term and recent patterns; robust to large drift and architecture or hyperparameter changes |
| Warm-start training | Prior production checkpoint as starting point | Low to moderate, scales mainly with incremental data and fine-tuning steps | Adapts quickly to gradual drift; can carry forward bias or degraded weights if drift is large |
Cold-start retraining is chosen when distribution shift is large, when features or labels were corrected historically, or when the team changes model structure, loss, or major hyperparameters. Warm-start training is chosen when drift is incremental, when retraining frequency is high, and when compute budget cannot support full retraining on every schedule. An expert policy often mixes both modes, using frequent warm-start updates for responsiveness and periodic cold-start runs to reset accumulated error. Data windows bound what the model learns. A sliding window keeps a fixed-length recent interval, so older records flow out as time advances, which prioritizes current behavior and limits cost but can lose rare signals and seasonality. An expanding window keeps a fixed start point and grows forward, which preserves long-term context but grows cost and lets old distributions dominate unless sampling, weighting, or decay gives higher weight to recent records.
Exam tip: Use warm-start training for fast, low-cost adaptation to gradual drift, but require periodic cold-start retraining when drift is large or prior weights may carry forward degraded representations.
Ground-truth label latency and Feature Store freshness determine when a retraining window is actually trainable. Label latency is the delay between a prediction event and the arrival of its verified outcome, so the training dataset depends on the labeling system and cannot include recent events whose labels have not yet arrived. Feature Store freshness is the delay between real-world state and the point-in-time correct feature values available for training, so the training job depends on the Feature Store snapshot that joins features to labels without leakage. A robust schedule separates event time from availability time by defining the window on labeled, materialized data rather than on raw event arrival.
The gated promotion sequence enforces this order:
Cloud compute budget turns frequency, window size, and training mode into a joint optimization problem. Every schedule consumes data processing for window assembly, accelerator time for training, and validation and storage for candidate evaluation. Under tight budgets, reduce window size with sliding windows, prefer warm-start updates, and require a larger expected gain to pass validation gating. Under looser budgets or high-risk applications, favor larger or expanding windows and periodic cold-start runs.
Champion-challenger gating is the rule that a retrained candidate becomes production only when it measurably beats or ties the registered champion under identical conditions. The pipeline pulls the champion from Vertex AI Model Registry as the baseline, trains and evaluates the challenger on new data, and writes both results to Vertex AI Experiments for comparison. Promotion depends on the gate passing, so the endpoint serving the champion remains unchanged when the challenger fails.
Offline evaluation gates compare candidate and champion on held-out and backtest datasets before any live traffic is affected. The gate first computes primary business-aligned metrics such as AUC, F1, RMSE, or MAPE on the same time-split test set, then requires the candidate to exceed the champion by a minimum delta with statistical confidence. The gate then checks secondary constraints including calibration, slice performance, fairness indicators, prediction latency, and model size. A candidate passes only after all blocking metrics pass and guardrail metrics stay within tolerance, including no protected slice degrading beyond allowed tolerance and data validation passing for schema, distribution, and label coverage. Live validation then sequences from lowest to highest blast radius:
| Strategy | User impact | Choose when |
|---|---|---|
| Offline evaluation | No live traffic | The decision can be made from historical labels and latency estimates |
| Shadow deployment | No user impact; live requests mirrored to candidate | Live feature distribution, skew, and latency must be validated safely |
| Canary deployment | Small share of users served by candidate | Real user feedback and business KPI response must be measured before full rollout |
Shadow deployment analysis in Vertex AI Endpoints mirrors a copy of production requests to the candidate while the champion continues to serve all user responses. Traffic flows from the live endpoint to both the champion serving path and the shadow candidate, and prediction logs flow from both models to BigQuery or Cloud Logging for side-by-side comparison. Canary monitoring routes a small percentage of live traffic from the champion endpoint to the candidate and compares live metrics. The fallback sequence runs in fixed order: monitor the canary, stop traffic expansion when any blocking rollback criterion breaches its threshold for consecutive windows, shift serving traffic from the candidate back to the prior champion version on the same endpoint, then freeze further auto-promotion, tag the candidate version as rejected in the registry, and route artifacts to root-cause analysis.
Retraining triggering mechanisms are policies that decide when an automated pipeline starts a new training run. Schedule-based triggers start retraining on a fixed calendar interval, such as daily, weekly, or monthly, regardless of current performance. Data flows from the feature store or BigQuery tables to Vertex AI Pipelines on a Cloud Scheduler cron invocation, and the pipeline depends on the availability of a complete training window at that time. Event-driven triggers start retraining when a system event signals that new data or context is available. Data flows from the source system to an event bus, typically Pub/Sub or Cloud Storage notifications, which then invokes the retraining job only after the event arrives. Common events include arrival of a new partitioned batch in BigQuery, accumulation of N new labeled examples, or deployment of a new feature version.
Vertex AI Model Monitoring continuously compares live serving data against a training baseline to generate metric-based signals. The monitoring job samples prediction requests and responses from the Vertex AI Endpoint, stores analysis in BigQuery, emits metrics to Cloud Monitoring, and publishes alerts to Pub/Sub when thresholds are breached. Three signal groups drive metric-based retraining: data drift and training-serving skew where input or prediction distributions diverged from training, measured by Jensen-Shannon divergence or L-infinity distance; concept drift where the relationship between features and target changed, detected via drops in accuracy, AUC, precision, recall, or prediction-label attribution shifts; and performance and operational signals such as sustained KPI degradation, increased prediction uncertainty, or growth in fallback rates. In practice, production systems layer the triggers with validation gating. A schedule provides a maximum staleness bound, events provide freshness on arrival, and Model Monitoring metrics provide an early override when drift occurs first. First the trigger fires and stages a candidate dataset, then data validation runs before any training starts, and only after validation passes does the pipeline train, evaluate against the champion, and promote only if the challenger exceeds performance and safety gates.
Continuous delivery for machine learning is the automated path from a newly trained model to a safe production deployment on Vertex AI Endpoints. The path flows from a continuous training trigger to an automated evaluation gate, then from Vertex AI Model Registry to a staged endpoint rollout, with monitoring signals flowing back to trigger retraining or rollback. Vertex AI custom training (opens in a new tab) runs managed jobs for hyperparameter tuning and distributed training, training output flows to artifact storage, and parameters, code versions, dataset versions, and results flow to Vertex AI Experiments for tracking.
Vertex AI Model Evaluation runs evaluation automatically, including rapid evaluation, custom metrics, human-in-the-loop review, and adversarial testing. The evaluation gate compares the candidate against explicit thresholds before promotion, including minimum accuracy, maximum error rate, minimum F1 score, traditional metrics such as precision, recall, AUC-ROC, and log loss, and generative AI quality metrics such as factual accuracy, safety attributes, grounding, instruction adherence, and verbosity. Only a model that meets all thresholds passes the gate and becomes eligible for registration. Vertex AI Model Registry is the versioned system of record that stores approved artifacts and preserves lineage for governance and reproducibility. After a successful run, artifacts flow from the training job to Cloud Storage buckets or directly to Model Registry, where each version retains its training data, code, parameters, and evaluation results. Promotion through environments depends on infrastructure as code integrated into the delivery pipeline. Terraform defines resources such as GKE clusters, endpoint configurations, and Cloud Storage buckets, Cluster Toolkit provides curated Terraform blueprints for HPC and AI clusters, and Config Connector manages Google Cloud resources as Kubernetes objects from YAML manifests.
Automated pipeline CI/CD and containerization with Cloud Build is the practice of testing ML pipeline code on every source change and packaging each component into versioned containers. Cloud Build imports source from GitHub, Bitbucket, or Artifact Registry, then executes containerized build steps defined in cloudbuild.yaml to produce artifacts such as Docker containers or Python tar files. Each build step runs in its own Docker container, and steps share the build workspace in order, so test results, built images, and compiled pipeline definitions flow from one step to the next. Cloud Build triggers are automated rules that execute configured steps whenever changes are pushed to the source. A trigger can fire on any change or only when changes match a branch, tag, or file filter, and the build can also be started manually through the CLI or API.
Build-time substitutions in Cloud Build are environment variables resolved when a build starts, which makes builds traceable and reusable:
$COMMIT_SHA identifies the source commit and is used to tag per-component Docker images for traceability.$REPO_NAME, $BRANCH_NAME, $TAG_NAME, and $REVISION_ID identify which repository and ref triggered the build, which supports branch-specific routines.$PROJECT_ID and $BUILD_ID identify the Google Cloud project and the specific build execution, even for manually submitted builds.The ML source repository keeps pipeline logic, component logic, containers, tests, and deployment settings together so Cloud Build can validate and package them atomically. A complete repository keeps Python pipeline workflow source code, Python component source code with matching component specification files, Dockerfiles for one image per component, Python unit and integration tests, build scripts including cloudbuild.yaml and pipeline deployment scripts, configuration files such as settings.yaml, and notebooks for exploratory analysis. The automated test, build, and containerization sequence runs in explicit order:
/workspace directory.$COMMIT_SHA.component.yaml file to point to the newly built images.pipeline.json definition file.pipeline.json to Artifact Registry for versioned storage.The ordering matters because the image build depends on passing tests, the component.yaml update depends on the pushed image URLs, and pipeline compilation depends on the updated specifications. Storing custom training and serving containers in Artifact Registry isolates dependencies per task, so feature engineering, training, and inference can evolve without creating a single point of failure.
Event-driven and scheduled continuous training triggers are automated signals that start a Vertex AI Pipelines retraining run without manual intervention. Scheduled retraining starts a run on a fixed time cadence even when no explicit event has fired. The scheduled run pulls the current versioned dataset from Cloud Storage buckets, launches managed jobs for hyperparameter tuning and distributed training, and includes foundation-model fine-tuning when required. Event-driven retraining on new data arrival starts a run when fresh training data lands or pipeline code changes. Data flows from the source system to Cloud Storage buckets, and the arrival event flows from storage to the pipeline trigger, so the workflow depends on both the data object and the pipeline definition being versioned.
Performance-degradation triggers start a run when Vertex AI Model Monitoring or Cloud Monitoring detects skew, drift, or quality loss. Monitoring signals flow from Model Monitoring to Cloud Monitoring alerting and Cloud Logging, and the alert flows to Vertex AI Pipelines to create a feedback loop for automatic retraining. Safe deployment to Vertex AI Endpoints limits blast radius by splitting traffic between the stable version and the canary version so live performance, latency, and error rate can be compared under real load. Rollback is the automated return of endpoint traffic from a degraded version to the last stable Registry version. For traditional ML, Model Monitoring detects training-serving skew and prediction drift by comparing live inputs against a golden dataset and baseline schema built with TFDV. For generative AI, the Gen AI evaluation service continuously monitors output quality and safety, while Cloud Logging and Cloud Monitoring track shifts in quality or harmful content and trigger the same rollback procedure. Every triggered CT run moves through an ordered lifecycle: trigger, train on the versioned dataset, version artifacts in Model Registry or Cloud Storage and log in Vertex AI Experiments, evaluate against development metrics and subgroup checks, then promote the candidate that passes thresholds or hold the failed candidate with lineage preserved for rollback.
Continue with this study guide: Automating model retraining
A complete automation loop connects timing, learning, and safety into one system. Triggering policies decide when Vertex AI Pipelines should fire, data windows with cold-start versus warm-start modes decide what the model learns at what cost under label and budget limits, and CI/CD/CT automation with Cloud Build, Model Registry, evaluation gates, and shadow, canary, and rollback controls decides whether the candidate is reproducible and safe to keep.
cloudbuild.yaml where per-component images tagged with $COMMIT_SHA are pushed to Artifact Registry before component.yaml is updated and pipeline.json is compiled.Optimizing metrics measure predictive effectiveness such as accuracy, f-measure, mean absolute percentage error, discounted cumulative gain, perplexity, and BLEU where higher is better and improvement is pursued during experimentation. Satisficing metrics measure operational constraints such as prediction latency below 200 milliseconds or model size for mobile and embedded devices where the model must stay within threshold and is rejected if violated.
Data skew is a significant difference between the feature distribution in training data and the feature distribution in serving data in production, checked with ML.VALIDATE_DATA_SKEW which compares serving statistics to training statistics saved inside the model at creation time. Data drift is a significant change in feature distribution in production over time, checked with ML.VALIDATE_DATA_DRIFT which compares two serving datasets such as current serving data versus a table snapshot.
Use cold-start retraining which trains from new initialization on the full selected window when distribution shift is large, features or labels were corrected historically, or model structure, loss, or major hyperparameters change. Use warm-start training which initializes from the previous production checkpoint and continues optimization on new data when drift is incremental, retraining frequency is high, and compute budget cannot support full retraining on every schedule.
Choose TensorFlow Extended (TFX) v0.30.0 or later when the workflow processes terabytes of structured or text data in TensorFlow and benefits from built-in Apache Beam integration where TensorFlow Transform calls translate to Beam operations without extra configuration. Choose Kubeflow Pipelines (KFP) SDK v2.0 or later for general-purpose modular components and broad reuse where each step is a containerized component with input parameters and output artifacts.
Last updated