Compute Engine provides the foundational virtual machine instances for training, offering machine families including general-purpose, compute-optimized, memory-optimized, and accelerator-optimized types. The accelerator-optimized machine family (A2, A3, A4, G2) is specifically designed with attached NVIDIA GPUs like the H100, A100, L4, or B200 to provide computational power for AI/ML workloads. The choice between a CPU and a GPU or TPU depends on the workload's parallelism and framework compatibility: CPUs handle general-purpose logic, GPUs accelerate deep learning tasks like model training and inference, and TPUs optimize large-scale tensor operations common in TensorFlow.
Selecting appropriate hardware requires matching the machine type and accelerator configuration to the model's size and training strategy. For foundational model training and large-scale fine-tuning, the A4X, A4, or A3 Ultra machine series with high-end GPUs are recommended. For mainstream model inference and fine-tuning, A3 Mega or A3 High machines are suitable, while A3 Edge serves inference workloads. The decision criteria involve analyzing the model's memory footprint, computational intensity, and the training framework's support for distributed strategies. The tradeoff is between higher-cost, high-performance accelerators for faster training and lower-cost options for longer but more budget-friendly runs.
Google Cloud offers several accelerator consumption options to manage cost and resource availability. The on-demand model provides immediate access without reservations but offers no capacity guarantees. For critical, time-sensitive workloads requiring assured capacity, future reservations (including calendar mode for up to 90 days) reserve resources for a specific future period. For short-duration, flexible workloads, Flex-start (powered by Dynamic Workload Scheduler) queues jobs and provisions densely allocated resources for up to seven days when capacity becomes available, offering discounts. For fault-tolerant workloads like experimentation, Spot VMs provide the deepest discounts but can be preempted with short notice. Choosing between these models involves a tradeoff between cost, start-time predictability, and job stability.
Training architectures are deployed and managed using orchestration services. Google Kubernetes Engine (GKE) is a managed Kubernetes service ideal for containerized AI/ML workloads, offering features like auto-scaling and support for specialized hardware. Within GKE, you can use custom compute classes to define a hierarchy of node configurations (prioritizing Spot VMs, then Flex-start) for cost-optimized provisioning. For High-Performance Computing style workloads, Slurm is an open-source orchestrator often deployed via Cluster Toolkit, which simplifies cluster configuration. The choice between GKE and Slurm depends on the team's expertise and the workload's need for container orchestration versus traditional job scheduling.
A scalable training architecture automatically adjusts resources based on demand. In GKE, this is achieved through the cluster autoscaler, node auto-provisioning, and the Horizontal Pod Autoscaler based on metrics like CPU, memory, or GPU utilization. For Vertex AI custom training, you define worker pool specifications and can use Spot VMs to reduce costs for interruptible jobs. High availability for production workloads is built through redundancy: deploying GKE regional clusters across multiple zones, using Cloud Storage multi-regional buckets for data and checkpoints, and distributing Vertex AI endpoints across regions with global load balancing. Fault tolerance involves monitoring for hardware errors (like GPU Xid errors) and implementing resilient training logic such as checkpointing and using libraries like the Google Resiliency Library for recovery.
Google Cloud Platform offers multiple compute and accelerator options for machine learning workloads: CPUs for general-purpose computing, GPUs (particularly NVIDIA GPUs) for parallel processing tasks, and Tensor Processing Units (TPUs) specifically designed for matrix multiplication operations in deep learning. TPUs are optimized to handle the enormous datasets and complex models of ML and are more cost-effective and energy efficient for ML workloads due to their superior performance in matrix operations. You can use TPUs through Compute Engine, Google Kubernetes Engine (GKE), and Vertex AI, with the Cloud TPU API now deprecated in favor of direct integration with these services.
TPUs contain a Matrix Multiplication Unit structured as a 128x128 systolic array, and the XLA compiler tiles matrix multiplications into 128x128 blocks for efficient execution on this hardware. The TPU memory subsystem prefers dimensions that are multiples of 8, so tensor dimensions should ideally be multiples of 8 to extract high performance from the memory subsystem. Programs whose computation is dominated by non-matrix operations such as add, reshape, or concatenate will likely not achieve high MXU utilization because these operations are often memory bound on the Cloud TPU. Additionally, models with tensors having dynamic shapes are not well suited to TPUs because the XLA compiler compiles an ML graph just in time for the first batch, and if any subsequent batches have different shapes, the model does not work.
When a matrix computation cannot occupy an entire MXU, the XLA compiler pads tensors with zeros, which causes two drawbacks: padded tensors underutilize the TPU core, and padding increases on-chip memory storage required for a tensor, which can lead to out-of-memory errors. To avoid padding, choose tensor dimensions that are well suited to TPUs by making either the batch size or a feature dimension a multiple of 128, as the XLA compiler attempts to use one of these to maximally use the MXU. Ideally, both batch size and feature dimensions should be multiples of 8. You can determine the amount of padding performed by using the op_profile tool to analyze your model's TPU efficiency.
Pre-training foundation models involves large clusters of accelerators, continuously reading large volumes of data, and adjusting weights through forward and backward passes to learn from the data, with these training jobs running for weeks or even months at a time. For pre-training on Google Cloud, the recommended accelerator-optimized machines are the A4X, A4, A3 Ultra, A3 Mega, and A3 High, which should be deployed using an orchestrator such as GKE or Slurm with Cluster Toolkit. For high assurance in obtaining large clusters of accelerators at minimum costs, use a reservation and request this reservation for a long duration. For storage, use Google Cloud Managed Lustre for continuous and quick access to training data, along with frequent and fast checkpointing of the model being trained; Cloud Storage FUSE with Anywhere Cache is an alternative.
Fine-tuning large foundational models involves smaller clusters of accelerators, reading moderate volumes of data, and adjusting the model to perform specific tasks, with these fine-tuning jobs running for days or even weeks. The recommended accelerator-optimized machines for fine-tuning are the A3 Mega or A3 High, deployed using Cluster Toolkit as an orchestrator. Similar to pre-training, use reservations for consumption type and Google Cloud Managed Lustre or Cloud Storage FUSE for storage services to ensure data is ready continuously and quickly.
The A4X accelerator-optimized machine type (a4x-highgpu-4g) is an exascale platform based on the NVIDIA GB200 NVL72 rack-scale architecture, differing from A3 and A4 families in several key ways: it uses ARM CPU architecture rather than X86, has 4 GPUs per node rather than 8, uses All capacity mode reservation type rather than Managed Mode, and requires Strict (Compact) placement policy rather than Flexible. Your A4X node pool VM count must be a multiple of 18 (for example, 18, 36, 54) because A4X capacity is provisioned in fixed, non-shareable 18-node blocks called NVLink domains, which are bound by a strict Compact Placement Policy where any partially allocated blocks cannot be used by other clusters. Due to the ARM-based architecture, all training jobs must use a container image built for the ARM architecture, and your distributed training logic must be updated to correctly recognize and use the 4 GPUs available on each A4X node.
In GKE, you can create single-host TPU slice node pools (where all TPU chips are on one VM) or multi-host TPU slice node pools (where TPU chips are distributed across multiple VMs). GKE scales single-host TPU slice node pools by adding or removing TPU nodes within the existing node pool, while multi-host TPU slice node pools scale atomically from zero to the number of nodes required to satisfy the TPU topology. When deploying TPU workloads in GKE, you must specify the TPU version in the spec.nodeSelector field, the TPU topology (the number and physical arrangement of TPU chips), and the number of TPU chips in the resources.requests and resources.limits fields. Creating a TPU slice node pool that consumes a TPU reservation does not require any TPU quota, while creating on-demand or Spot TPU slice node pools requires Compute Engine API quota.
To achieve linear scaling on larger TPU types, keep the per-core batch size the same; for example, if you use a batch size of 1024 on a v6e-8, use a batch size of 4096 (4 × 1024) on a v6e-32 to fully utilize the TPU hardware. When you increase the batch size, scale down the number of training steps so that the total number of training examples remains the same—for instance, if you have a batch size of 1000 for 100 steps (100,000 examples), with 4 workers and an effective batch size of 4000, you would adjust steps to 25 to process the same 100,000 examples. Larger batch sizes can change convergence behavior of the model, so you might also need to tune hyperparameters like learning rate. When developing a new TPU workload, begin development on the smallest TPUs (for example, v6e-8), test for expected behavior and validate performance, then gradually scale up to larger TPU types while validating scalability until you reach the target TPU size.
NVIDIA GPUs in GCP attach to accelerator-optimized and general-purpose Compute Engine VM series to accelerate linear algebra and deep learning tasks. GCP maps specific NVIDIA GPU models directly to dedicated machine types. The A4X Series is designed for foundational model training and high-scale inference, requires capacity acquisition through future reservations, and is not covered by the Compute Engine Service Level Agreement. The A4 Series features NVIDIA B200 GPUs and is intended for large-scale foundation model pre-training, fine-tuning, and multi-node inference. The A3 Series features NVIDIA H100 80GB GPUs (A3 High and A3 Mega), NVIDIA H200 141GB GPUs (A3 Ultra), and lower-footprint serving options (A3 Edge) for large-scale training and inference. The A2 Series features NVIDIA A100 GPUs available in 40 GB and 80 GB VRAM variants for mainstream model fine-tuning and distributed training. The G2 and G4 Series features NVIDIA L4 GPUs with 24 GB VRAM on the G2 series for inference and graphics rendering. The N1 Series supports legacy attachments of NVIDIA T4, V100, P100, and P4 GPUs. Workloads request GPU accelerators in GKE standard clusters or GKE Autopilot via the specialized Accelerator compute class. Serverless containerized inference deployments can attach a single NVIDIA L4 GPU per Cloud Run instance using at least 4 vCPUs and 16 GiB of instance memory, scaling down to zero when idle. Cloud Dataflow Runner v2 pipelines leverage attached GPUs (such as L4, A100, T4, and H100) to accelerate numeric data transformations and embedded inference pipelines.
Cloud TPUs are Google's custom-developed application-specific integrated circuits optimized for matrix computation and high-throughput model training and inference. The platform supports multiple TPU generations across distributed environments. The TPU v5p is a high-performance TPU architecture designed for large-scale model pre-training and serving. The TPU v6e (Trillium) is a TPU architecture optimized for balanced cost and high-throughput training and inference. The TPU7x (Ironwood) is an advanced TPU architecture designed for scalable training and serving workloads. Cloud TPU resources integrate natively into Compute Engine TPU VMs, GKE container deployments using tools such as JobSet, Kueue, and KubeRay, Vertex AI custom training, and Dataflow pipelines. Distributed training architectures employ multi-slice orchestration or frameworks like Pathways and Optimum TPU to coordinate execution across TPU pods.
Compute Engine CPU platforms deliver general compute capabilities and specialized instruction set extensions for preprocessing, standard batch jobs, and lower-complexity inference. 4th Generation and later Intel Xeon Scalable Processors offer hardware acceleration engines on bare metal and VM instances. Intel Advanced Matrix Extensions (AMX) accelerates deep learning matrix operations for frameworks like TensorFlow 2.9.1+ and Intel Optimization for PyTorch. Intel QuickAssist Technology (Intel QAT) offloads and accelerates data compression, encryption, and decryption tasks. Intel Dynamic Load Balancer (Intel DLB) accelerates data queue handling and workload distribution across CPU cores. Intel In-Memory Analytics Accelerator (Intel IAA) accelerates database and query processing throughput. Intel Data Streaming Accelerator (Intel DSA) optimizes high-performance data movement and copy operations. Compute Engine provides automated machine type recommendations generated from eight days of historical CPU and memory utilization metrics. Workloads utilizing third-party licenses can apply custom machine types or disable simultaneous multithreading (SMT) to scale CPU cores independently of system memory.
Consumption options govern the provisioning model, obtainability, duration, and billing rates for GCP compute accelerators. Infrastructure architectures balance cost and availability across four primary provisioning strategies. Future Reservations (AI Hypercomputer / 1 Year+) guarantees capacity assurance for A4X, A4, A3 Ultra, and Cloud TPUs via account teams or committed use discounts (CUDs), offering up to a 53% discount on vCPUs, GPUs, and TPUs with dense resource allocation. Future Reservations in Calendar Mode is a self-service capacity reservation for up to 80 VMs running for up to 90 days (supporting A4, A3 Ultra, TPU v5p, TPU v6e, and TPU7x), delivering high obtainability and up to a 53% discount. Flex-start (Dynamic Workload Scheduler) provides dynamic provisioning for short-duration workloads lasting up to seven days; requests are queued and automatically fulfilled as densely allocated capacity becomes available at up to a 53% discount using preemptible quota. Spot VMs are deeply discounted compute (60% to 91% discount on Compute Engine) utilizing preemptible quota; instances can be preempted at any time with a 30-second warning, making them ideal for fault-tolerant batch training with checkpointing, hyperparameter search, and evaluation.
The selection of accelerator hardware and consumption models depends on model size, latency constraints, throughput requirements, and tolerance for interruption. For pre-training large foundation models, select A4X, A4, A3 Ultra, or TPU v5p/v6e clusters using Future Reservations to secure dense resource placement, high network performance, and long-term committed use pricing. For fine-tuning and short-duration training, select A3 High/Mega, A2 (A100), or TPU v6e via Flex-start or Future Reservations in Calendar Mode to avoid long-term idle commitments while achieving up to 53% cost reductions. For fault-tolerant batch jobs and experiments, deploy Spot VMs on GKE or Vertex AI Custom Training with multi-tier checkpointing across regional Cloud Storage buckets to minimize compute expense. For production generative AI serving, deploy multi-replica Vertex AI Endpoints or GKE Autopilot clusters on A3, A2, or TPU v6e across multiple zones behind global load balancers. For low-latency microservice and edge inference, deploy single NVIDIA L4 GPUs on Cloud Run or G2 series VMs to scale on-demand from zero requests without paying for idle capacity.
Choose TPUs when your workload is dominated by matrix multiplication operations in frameworks like TensorFlow, your model uses static tensor shapes, and you need cost-effective performance for large-scale training. Choose GPUs when your framework supports NVIDIA acceleration (like PyTorch), your model involves diverse operations beyond matrix math, or you need broader ecosystem compatibility.
A4X machines use NVIDIA GB200 NVL72 rack-scale architecture with ARM CPUs (instead of X86), have 4 GPUs per node (instead of 8), require All capacity mode reservation type, and need Strict Compact placement policy. A4X is designed for foundational model training while A3 series offers more flexibility with H100 and H200 GPU options.
Use Future Reservations (1 year or longer) or Future Reservations in Calendar Mode to secure capacity with up to 53% discounts. Deploy with GKE or Slurm using custom compute classes that prioritize Spot VMs, then Flex-start. Implement frequent checkpointing to Cloud Storage multi-regional buckets to enable recovery from preemptions.
Professional Machine Learning Engineer
Prepare and test your skills
Prepare and test your skills