auto-dat

Vertex AI – GCP’s ML Platform Deep Dive | How Training Works, Cost, Security, vs SageMaker/Azure ML

Kim (THK)

Vertex AI machine learning training pipeline
Figure 1: Vertex AI – unified MLOps platform. This deep dive explains how training actually works under the hood.

Vertex AI is Google Cloud’s end-to-end machine learning platform that brings together AutoML, custom training, model registry, feature store, pipelines, and online/batch prediction. But how does it actually train models? This guide explains the internal mechanics of training on Vertex AI – from data ingestion to distributed computing, AutoML vs custom code, and how Vertex manages compute, storage, and orchestration. We'll also cover pricing, IAM, security risks (leaked keys), and compare with AWS SageMaker and Azure ML. Interactive buttons throughout let you explore tips and warnings.

🧠 Core training architecture
Vertex AI training runs on Google’s Borg cluster (same infrastructure as Search, YouTube, Gemini). It provisions isolated VMs (or TPU pods) with your chosen framework, copies your code and data, executes the training script, streams logs to Cloud Logging, and persists the output model to Cloud Storage. All orchestrated by the Vertex Training service.

I. How Vertex AI Actually Trains Models – Under the Hood

Training on Vertex AI follows a consistent workflow, whether you use AutoML or custom code. Here’s the step-by-step internal process:

1. Data preparation
You point Vertex to data in BigQuery, Cloud Storage, or a connected source. Vertex does not copy data unless you specify. For AutoML, Vertex performs automatic data validation, splitting (train/val/test), and feature engineering (imputation, scaling, encoding).
2. Training job submission
You submit a training job via SDK, console, or API. Vertex creates a training request that includes: machine type (CPU/GPU/TPU), replica count, accelerator count, container image (custom or pre-built), and command line arguments.
3. Resource provisioning
Vertex’s scheduler allocates VMs from Google’s global pool. For GPU/TPU, it reserves slices from accelerators. Preemptible VMs are reclaimed after 24h (80% cheaper). For distributed training, Vertex sets up network fabric (NVMe over PCIe for TPU pods).
4. Container execution
Your code runs inside a container (e.g., tensorflow/tensorflow:latest). Vertex injects environment variables: AIP_MODEL_DIR (output location), AIP_TRAINING_DATA_URI, and cluster spec for multi‑worker. Logs are streamed to Cloud Logging.
5. Hyperparameter tuning (optional)
If you enable Vizier (Vertex’s Bayesian optimization), Vertex launches parallel trials. Each trial runs on a separate replica, reports objective metrics, and Vizier suggests next hyperparameters using Gaussian Process.
6. Model saving & versioning
Training script must write the model artifact to AIP_MODEL_DIR. Vertex uploads it to Cloud Storage, calculates checksums, and registers it in the Model Registry with evaluation metrics.
# Custom training job – behind the scenes
from google.cloud import aiplatform

job = aiplatform.CustomTrainingJob(
    display_name="my-training",
    script_path="train.py",
    container_uri="us-docker.pkg.dev/vertex-ai/training/pytorch-gpu.1-13:latest",
    requirements=["scikit-learn"]
)
# Vertex provisions n1-standard-4 + T4 GPU, runs `python train.py --epochs=10`
model = job.run(
    replica_count=1,
    machine_type="n1-standard-4",
    accelerator_type="NVIDIA_TESLA_T4",
    accelerator_count=1,
    args=["--epochs", "10"]
)
🔬 AutoML training internals
AutoML does not run a single algorithm. Vertex performs neural architecture search (NAS) for image models, gradient boosted trees (XGBoost/LightGBM) for tabular data, and Transformer-based search for text. It trains multiple candidate models in parallel (on internal TPU pods), evaluates them on validation split, and selects the best one. You only pay for the final training time, not the search overhead.

II. Real-World Applications of Vertex AI

📸 Computer Vision
Object detection, image classification, OCR using AutoML Vision or custom models (EfficientNet, ViT) on Cloud TPUs.
📝 Natural Language Processing
Sentiment analysis, entity extraction, fine-tune BERT/Gemini models.
💰 Forecasting & Anomaly Detection
Time series forecasting (AutoML Forecast) for demand planning. Anomaly detection for fraud.
🎯 Recommendation Systems
Two-tower models, collaborative filtering deployed to endpoints for real-time personalization.
🏥 Healthcare
Predicting patient readmissions, analyzing MRI scans, drug discovery.
🤖 Generative AI
Vertex Model Garden hosts Gemini 1.5 Pro, Llama 3, Claude 3 – fine-tune and deploy.

III. Vertex AI Pricing – How Training Costs Add Up

ComponentPricing (us-central1)Notes
AutoML training (tabular)$20.40 per node hourMinimum 1 node, billed per second
Custom training (vCPU)$0.0784 per vCPU hourPlus GPU/TPU extra
Custom training (GPU – T4)$0.35 per GPU hourPreemptible reduces 60-80%
Custom training (TPU v4)$3.22 per TPU chip hour8-chip pod = $25.76/hour
Prediction (online)$0.10 – $0.30 per node hourAuto-scaling, scale to zero available
Batch predictionSame as training compute + $0.01/1k predictionsNo minimum nodes
Vertex Pipelines$0.03 per execution (first 10/month free)+ underlying compute
Model monitoring$0.20 per 1,000 predictions analyzedFirst 1M free
💵 Training cost optimization
• Use preemptible VMs for fault‑tolerant training (saves 80%).
• Use batch prediction instead of online for non‑realtime.
• Set min_replicas=0 for prediction endpoints (scale to zero).
• Use committed use discounts if you train >50% of the month.

IV. Vertex AI vs. AWS SageMaker vs. Azure ML

✅ Vertex AI strengths

  • Deep BigQuery integration – train directly from petabytes without moving data.
  • TPU support – unmatched for large transformers (faster/cheaper than GPUs).
  • Unified MLOps – fewer services to stitch together.
  • Model Garden – 500+ pretrained models including Gemma, Llama.
  • Pipelines native – based on Kubeflow (open standard).

⚠️ Weaknesses

  • SageMaker has more third‑party integrations (Databricks, Snowflake).
  • Azure ML integrates better with Power BI and Microsoft Fabric.
  • Vertex Feature Store less mature than SageMaker Feature Store.
  • Fewer built‑in algorithms than SageMaker.
CapabilityVertex AISageMakerAzure ML
AutoML (tabular, text, image)✅✅ Autopilot✅ Automated ML
Distributed trainingTF, PyTorch, MPITF, PyTorch, MPIHorovod, TF
Hyperparameter tuningVizier (Bayesian)Bayesian, randomHyperDrive
Model monitoring (drift)YesModel MonitorData drift
ExplainabilityIntegrated Gradients, ShapleyClarify (SHAP)InterpretML
TPU support✅ (v4, v5e)❌❌

V. IAM & Security – What Happens If Your API Key Leaks?

🔐 IAM best practices

  • Use workload identity federation instead of service account keys.
  • Assign minimal roles: aiplatform.user (prediction), aiplatform.modelDeployer, aiplatform.customCodeTrainer.
  • Enable VPC Service Controls to prevent data exfiltration.
  • Use Customer-Managed Encryption Keys (CMEK) for models/datasets.

⚠️ Risk of leaked key (real impact)

  • Attacker can launch GPU training jobs – cost explosion ($350+/hour).
  • They can deploy models to endpoints and exfiltrate training data via model inversion.
  • They can access BigQuery datasets linked to Vertex.
  • They can poison your model registry with backdoored models.
# Least privilege example: service account for ONLY batch prediction
gcloud iam service-accounts create vertex-batch-predictor
gcloud projects add-iam-policy-binding my-project \
    --member="serviceAccount:vertex-batch-predictor@my-project.iam.gserviceaccount.com" \
    --role="roles/aiplatform.batchPredictionJobRunner"

VI. Pro Tips for Production ML on Vertex AI

⚡ Tip 1: Pre-built prediction containers
Use Vertex’s optimized containers for TF, PyTorch, Sklearn – faster cold starts.
📦 Tip 2: Batch prediction with Dataflow
For millions of rows, preprocess with Dataflow, then use batch prediction – cheaper than online.
🔁 Tip 3: Canary deployments
Deploy two model versions to same endpoint with traffic splitting (90/10) to test new version.
📈 Tip 4: Enable Explainable AI only when needed
Explainability adds cost and latency. Disable for high‑throughput production.
🕒 Tip 5: Schedule retraining with Cloud Scheduler + Pipelines
Automate daily/weekly retraining using Vertex Pipelines and Cloud Scheduler.
🔔 Tip 6: Alert on model drift
Set up Vertex Model Monitoring + Cloud Monitoring to get Slack alerts when drift >20%.

VII. Decision Guide – Is Vertex AI Right for You?

✅ Choose Vertex AI if...
You are already on Google Cloud (BigQuery, GCS, GKE), need TPUs for large models, want a unified MLOps platform, or require deep integration with BigQuery for training data.
❌ Choose SageMaker or Azure ML if...
You are heavily invested in AWS (Redshift, S3, Glue) or Microsoft ecosystem (Power BI, Azure Data Lake), or need a more mature feature store with low‑latency online serving at global scale.
🎯 Final Verdict

Vertex AI – The Most Integrated ML Platform for Google Cloud Users

Vertex AI is not just another ML platform – its training engine is deeply optimized for Google’s infrastructure, from TPU pods to BigQuery columnar scans. The unified MLOps experience reduces complexity, and the training cost can be 30-50% lower than SageMaker for TPU‑compatible workloads. However, the risk of leaked API keys is real: an attacker can drain your budget in hours. Always enforce IAM least‑privilege, use workload identity, and set budget alerts. If your team lives in Google Cloud, Vertex AI is the obvious choice. For multicloud, use Vertex AI for analytics‑heavy training and SageMaker for feature‑store‑centric applications.