Prepare and test your skills
Prepare and test your skills
Validating data and models is the practice of proving that input data is correct and that a model is accurate, fair, and ready for production load. Vertex AI Model Evaluation (opens in a new tab) 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 and tracking. A model moves to production only when it meets predictive thresholds, satisfies operational limits, and performs similarly across sensitive data slices.
Optimizing, satisficing, and slice-based evaluation separate how well a model predicts from whether it is acceptable to operate. Optimizing metrics measure predictive effectiveness, including accuracy and f-measure for classification, mean absolute percentage error for regression and forecasting, discounted cumulative gain for ranking, and perplexity and BLEU scores for language models. Satisficing metrics measure fixed operational constraints such as prediction latency below 200 milliseconds or model size small enough for mobile and embedded devices.
| Metric type | What it measures | Decision rule |
|---|---|---|
| Optimizing metrics | Predictive effectiveness such as accuracy, f-measure, and BLEU | Higher is better; improve during experimentation |
| Satisficing metrics | Operational constraint such as latency or model size | 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 between slices 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 pipelines validate data as it flows from ingestion through preprocessing, training, and serving. TensorFlow Data Validation (TFDV) (opens in a new tab) 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. Data flows from source tables, files, or streams into validation logic, only validated data flows forward to feature engineering and training, and validation metrics flow to observability and retraining triggers. Validation results are stored in BigQuery for trend analysis and validation artifacts are archived in 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 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. Both degrade accuracy even when model code has not changed, because models perform best on serving data that resembles training data.
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 and visualization.
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. The drift workflow follows the same order but validates two serving datasets for serving-versus-serving change.
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 (opens in a new tab). Security-critical models add full adversarial attack simulations, containerized models add vulnerability scanning with Artifact Analysis (opens in a new tab) 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 (opens in a new tab) 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.
Continue with this study guide: Validating data and models
Pipeline orchestration architecture is the decision about how machine learning (ML) steps are defined, packaged, and run as one connected end-to-end system. Gemini Enterprise Agent Platform Pipelines (opens in a new tab) is the managed serverless orchestrator for directed acyclic graphs (DAGs), where the definition flows from developer code 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. 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 with Agent Platform Pipelines 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) (opens in a new tab) 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) (opens in a new tab) 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. Cloud Dataflow (Dataflow) (opens in a new tab) 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 and lets notebook experiments coexist with production components. 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 (opens in a new tab) 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. Idempotency comes from the ML metadata store, which records versions, timing, executor, parameters, artifact pointers, prior model pointers for rollback, and metrics so a failed run resumes from the last completed step.
Operational excellence for pipelines detects failures, regressions, and drift quickly, recovers safely, 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. Coverage spans infrastructure signals such as CPU, GPU, TPU, memory, and disk I/O, application signals of latency, traffic, error rate, and saturation, and data signals such as ingestion rate, transformation latency, schema adherence, and freshness.
Boundary validation prevents bad data and configs from propagating. TFDV validates schemas and distributions, BigQuery runs large-scale SQL checks and stores results, Dataflow runs programmatic batch and streaming validation, and Cloud Run functions handle lightweight file-upload checks. Configuration files and parameters are validated with schemas and type checks before execution. Controlled release limits blast radius through traffic splitting and canary deployment, which runs in order: route a small subset of live traffic to the new version, monitor performance and error rates, establish reliability against thresholds, then roll out fully or roll back automatically. 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.
Exam tip: Stop the pipeline for data schema skews that violate the expected schema, but retrain the model for data values skews that change statistical patterns.
Consistent preprocessing between training and serving means the same transformation code produces features for both training examples and live prediction requests. Vertex AI Inference (opens in a new tab) (formerly Agent Platform 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. Because one implementation runs in both phases, small differences in scaling, encoding, imputation, or vocabulary mapping cannot change the feature distribution the model sees in production.
Embedded preprocessing in the serving container prevents training-serving skew by coupling model artifacts, preprocessing logic, and pinned dependencies in one image. 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. Isolating feature engineering, training, and inference into different containers further protects consistency, because a change to training libraries does not silently alter serving behavior.
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.
| Option | Preprocessing control | Choose when |
|---|---|---|
| Prebuilt containers | Limited to supported frameworks plus custom prediction routines | Framework is supported and routines can express identical training transforms |
| Custom containers | Full control to embed any code, libraries, and native packages | Libraries or complex transforms cannot be reproduced on the prebuilt stack |
Exam tip: Use a custom prediction routine when a prebuilt container supports the framework but you need identical custom preprocessing; use a full custom container when dependencies or logic cannot be expressed on the prebuilt stack.
Versioned transformation artifacts package preprocessing logic and learned parameters into a reusable object that travels with the model binary. Examples include a TensorFlow Transform graph, a scikit-learn pipeline, an Apache Beam Dataflow pipeline, or a container that embeds preprocessing code. Model Registry (opens in a new tab) is the system of record for model versions, where each version links to its artifacts, training parameters, evaluation metrics, dataset version, code version, and framework details. Artifact Registry is the immutable store for build outputs such as container images, pipeline components, custom packages, and validated configs with versioning, tagging, vulnerability scanning, and deployment gating.
The two registries divide ownership: model files, weights, and transform graphs stage in Cloud Storage before import into Model Registry, while training and serving images, components, and configs store in Artifact Registry or Cloud Storage with explicit tags and semantic versions. Programmatic registration through the SDK lets a pipeline run register the model, transform, dataset, and evaluation result as one traceable release. Governance applies least-privilege IAM with dedicated service accounts and IAM Conditions, while Cloud Audit Logs capture endpoint, model, and artifact changes. To harden releases, store vetted images in a private Artifact Registry repository, build with Cloud Build in CI with tests for correctness and latency, and enforce Binary Authorization (opens in a new tab) so only passing images deploy to platforms such as Google Kubernetes Engine (GKE) or Cloud Run.
Consistent feature engineering defines the full workflow as one automated pipeline where the same preprocessing code feeds training and serving. Vertex AI Pipelines (opens in a new tab) orchestrates modular components with typed inputs and outputs, so data flows explicitly from preparation to training to evaluation to deployment. A consistent run moves in order: raw data flows into preprocessing and TFDV validation, processed features flow to custom training, trained model and evaluation data flow to evaluation with metric logging, and the validated artifact flows to Model Registry and the serving endpoint.
The preprocessing component owns the transform, so a feature change requires a new versioned pipeline run rather than a serving-side patch. The engine choice depends on processing model: Dataflow with Apache Beam for unified batch and streaming, Managed Service for Apache Spark for Spark-native work, and BigQuery for SQL transforms with quality scans. Vertex AI Feature Store (opens in a new tab) 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. TensorFlow Data Validation (TFDV) generates statistics, enforces schema at component boundaries, and flags serving data that violates training expectations before errors propagate. Validation results flow to BigQuery for history, artifacts archive in Cloud Storage, configs validate with schemas before runs, and Model Monitoring detects data and prediction drift to trigger a new versioned transform and model pair through the same path.
Continue with this study guide: Ensuring consistent data preprocessing between training and serving
Data skew is a significant difference between the feature distribution in training data and the feature distribution in serving data in production, while data drift is a significant change in feature distribution in production over time across consecutive spans of serving data. ML.VALIDATE_DATA_SKEW compares serving statistics to training statistics saved inside the model at creation time, while ML.VALIDATE_DATA_DRIFT compares two serving datasets such as current serving data versus a table snapshot.
Use a custom prediction routine when a prebuilt container supports the framework but you need identical custom preprocessing for training and serving. Use a full custom container when libraries or complex transforms cannot be reproduced on the prebuilt stack, since it packages the full serving application including web server, preprocessing code, model loader, and dependencies.
Optimizing metrics measure predictive effectiveness such as accuracy, f-measure, and BLEU scores where higher is better and they are improved during experimentation. Satisficing metrics measure fixed operational constraints such as prediction latency below 200 milliseconds or model size small enough for mobile devices, where the model must stay within threshold and is rejected if violated.
Last updated