Prepare and test your skills
Prepare and test your skills
Designing scalable and cost-optimized training architectures means combining distributed orchestration with the right capacity and pricing model to balance training speed, model accuracy, and budget. On Google Cloud, Google Kubernetes Engine (GKE) (opens in a new tab) , Slurm, Cluster Director, Cluster Toolkit, and Ray form the orchestration layer, while committed use discounts (CUDs), Spot VMs, and Dynamic Workload Scheduler (DWS) modes control cost and availability. Training traffic flows from job queues and autoscalers to colocated GPU or TPU hosts, and the choice of machine type, reservation mode, and management model determines throughput, stability, and price.
Optimizing availability and cost for training capacity is the practice of matching training duration and fault tolerance to a pricing and provisioning model. For stable, long-running training with fixed or predictable capacity, use committed use discounts (CUDs) (opens in a new tab) for Compute Engine VMs and accelerators to lower cost. For fault-tolerant evaluation and experimentation, use Spot VMs on GKE nodes and Compute Engine VMs, because Spot VMs carry the deepest discount but can be preempted at any time.
To improve obtainability of high-demand accelerators, use DWS (opens in a new tab) to queue and provision GPUs and TPUs when capacity appears. For complex batch training that needs high-end GPUs for up to seven days, use DWS Flex-Start mode, where GKE persists the GPU request and automatically provisions Flex-Start VMs when capacity becomes available. For longer runs up to three months, use DWS Calendar mode to reserve specific GPUs such as H100 and H200 and TPUs such as Trillium for a future date and time. Flex-Start is billed pay as you go with up to a 53% discount for vCPUs, GPUs, TPUs, and attached Local SSD disks, and it requires no complex quota management.
Consumption options for clustered GPUs define how dense multi-host capacity is requested, how long it lasts, and what discount applies. Clustered GPUs support dense allocation with colocation for multi-GPU training, and the request flows from Compute Engine, Cluster Director, Cluster Toolkit, or GKE to the available accelerator pool.
| Consumption option | Best for | Duration and discount |
|---|---|---|
| Future reservations in AI Hypercomputer | Pre-training foundation models or multi-host inference needing extended stability | Extended period, dense allocation, up to 53% discount for vCPUs and GPUs; requested through account team for a future start date and time |
| Future reservations in calendar mode | Pre-training or fine-tuning needing stability up to 90 days | Up to 90 days, dense allocation, up to 53% discount; self-service request that Google Cloud must approve |
| Flex-Start | Short-lived, dense clusters without a fixed start date | Up to seven days, dense allocation, up to 53% discount on supported types, otherwise on-demand rates; provisioned when capacity appears, start is not immediate |
| Spot | Fault-tolerant, batch, or short-lived training | Immediate creation, deepest discount between 61% and 90%, but resources can be preempted at any time |
Choose Future reservations or Calendar mode when training cannot tolerate interruption and needs guaranteed topology for weeks to months. Choose Flex-Start when batch training can wait for capacity and finish within seven days, and choose Spot only when checkpoints and retries can absorb preemption.
Exam tip: Flex-Start lasts up to seven days with queued provisioning when capacity appears, while Calendar mode reserves H100, H200, and Trillium capacity for up to 90 days or three months.
Distributed training orchestration automates job queuing, resource allocation, colocation, and scaling across many accelerator hosts so developers do not manage each instance. Cluster Director (opens in a new tab) deploys and manages accelerator groups with colocation and scheduling for multi-GPU training on A3 Ultra H200 and A4 B200, and Cluster Director supports GKE and Slurm clusters. Ray on Gemini Enterprise Agent Platform abstracts distributed infrastructure and lets applications request resources for training and serving without directly managing VMs and containers.
The level of control determines the deployment path. Highly managed deployment automates setup of compute, networking, and storage and reduces operational overhead:
For more granular control, create a Compute Engine cluster by using managed instance groups (MIGs) or by creating instances in bulk, then manually install required software. The orchestrator then governs daily operations: Slurm handles job queuing and resource allocation for high-performance computing, AI, or ML workloads; GKE handles container orchestration, autoscaling, and hardware-aware scheduling; and a bring-your-own orchestrator on Compute Engine leaves setup, maintenance, and updates to the operator.
Accelerator and image selection determines what training nodes can execute and how fast multi-host jobs communicate. Graphical processing units (GPUs) accelerate machine learning and data processing, and GKE offers nodes with NVIDIA H100, A100, and L4 GPUs plus clustered options including A3 Ultra H200, A4 B200, and A3 Edge machine types. All clustered GPU types except A4X Max and A4X support Flex-Start, Calendar mode, and Spot, while Future reservations in AI Hypercomputer also cover A3 Edge. TPUs including Trillium are obtainable through the same DWS Flex-Start and Calendar mechanisms with matching vCPU, GPU, TPU, and Local SSD discount treatment.
The operating system image depends on GPU infrastructure and deployment target. For GKE clusters, use the default Container-Optimized OS images for Standard and Autopilot modes, with Ubuntu available as an alternative in Standard mode, and Cluster Toolkit blueprints use container OS images. For Compute Engine and Slurm clusters, select an accelerator-optimized OS such as Rocky Linux 9 accelerator, Rocky Linux 8 accelerator, Ubuntu 24.04 LTS accelerator, or Ubuntu 22.04 LTS accelerator, where Cluster Toolkit extends the Ubuntu LTS Accelerator images. For a ready-to-use deep learning environment, use Deep Learning Software Layer (DLSL) container images that install NVIDIA CUDA, NCCL, and ML frameworks such as PyTorch and are tested for GKE clusters.
Analyzing workload characteristics for hardware selection means mapping the computational demands of a machine learning (ML) workload to the processor that executes it most efficiently. On Google Cloud, the choice centers on central processing units (CPUs), graphics processing units (GPUs), and Tensor Processing Units (TPUs) (opens in a new tab), Google's custom application-specific integrated circuits (ASICs) for ML. The optimal compute profile follows from four signals: the dominance of matrix computation in the model architecture, the effective batch size and memory footprint, the need for data-parallel scale, and the precision and shape constraints the code can satisfy.
Compute patterns by model architecture describe whether an accelerator can stay busy with the math it was built to accelerate. TPUs are purpose-built for large-scale matrix multiplication, which is the foundation of deep learning, and they efficiently train models by executing large matrix operations in hardware. Models dominated by matrix computations, models that train for weeks or months, and models with ultra-large embeddings common in advanced ranking and recommendation workloads fit TPUs well. By contrast, a program dominated by non-matrix operations such as add, reshape, or concatenate will likely not achieve high matrix unit (MXU) utilization, and linear algebra programs that require frequent branching or many element-wise operations are not suited to TPUs.
Efficient models are often co-designed for a specific platform, so a model tuned for one generation or vendor may not fully utilize another without configuration or software changes. Sparse models, for example, can improve quality and reduce computation by 3-10 times compared with dense models, while a distilled model such as DistilBERT can deliver similar performance to BERT with far less overhead. Frontier models spanning hundreds of billions to trillions of parameters, such as large language models (LLMs) like Gemini, and large models spanning tens to hundreds of billions of parameters therefore demand a hardware decision that considers both architecture and scale, not advertised peak specifications alone.
Batch size, memory, and data parallelism decide how much parallelism the hardware can exploit and how large a model can fit. TPUs provide on-chip high-bandwidth memory (HBM) that lets teams use larger models and larger batch sizes, and TPUs can be connected in groups called slices that scale workloads with little to no code changes. Pre-training foundation models illustrates the extreme: large clusters of accelerators continuously read large volumes of data, adjust weights through forward and backward passes, and run for weeks or even months. Fine-tuning the same large models uses smaller clusters and moderate data volumes to adapt weights to specific tasks, while inference splits by whether the load fits on one host or must be shared across multiple hosts.
The practical selection rule follows effective batch size and training duration:
Microbenchmarking of floating point operations per second (FLOPS), HBM, and networking bandwidth, combined with roofline analysis of operational intensity, shows what a platform can theoretically achieve before model benchmarking measures real tokens per second per chip across training and inference.
Precision, shapes, and compilation constraints determine whether code can compile and stay efficient on TPUs. Code that runs on TPUs must be compiled by the accelerated linear algebra (XLA) compiler, a just-in-time compiler that takes the graph emitted by the ML framework and compiles the linear algebra, loss, and gradient components into TPU machine code while the rest of the program runs on the TPU host machine. Neural network workloads that contain custom operations in the main training loop are not suited to TPUs, and workloads that require high-precision arithmetic are also excluded. When lower precision is acceptable, quantization that reduces parameters from 32-bit floating-point to 8-bit integers can significantly decrease memory footprint and power consumption without a noticeable loss in accuracy.
TPU efficiency also depends on static, tile-friendly shapes because the MXU hardware is a 128x128 systolic array and the memory subsystem prefers dimensions that are multiples of 8. The XLA compiler tiles matrix multiplies into smaller blocks and compiles the graph just in time for the first batch, so tensors with dynamic shapes are not well suited because recompiling on every shape change is too slow. When a computation cannot fill an entire MXU, the compiler pads tensors with zeros, which underutilizes the core and increases on-chip memory that can lead to out-of-memory errors in the extreme case. To maximize MXU use, either the batch size or a feature dimension must be a multiple of 128 or the compiler will pad it to 128, and ideally both batch and feature dimensions are multiples of 8; the op_profile tool can reveal how much padding occurred.
Exam tip: Choose TPUs only when shapes are static and batch or feature dimensions can be sized to multiples of 128, ideally multiples of 8, to avoid automatic zero-padding and wasted MXU capacity.
The training or serving profile converts workload size and duration into a concrete accelerator and deployment shape. For pre-training foundation models on AI Hypercomputer (opens in a new tab), Google Cloud recommends A4X Max (NVIDIA GB300), A4X (NVIDIA GB200), A4 (NVIDIA B200), A3 Ultra (NVIDIA H200 141GB), A3 Mega (NVIDIA H100 80GB), or A3 High (NVIDIA H100 80GB) machine types deployed as orchestrated clusters through Google Kubernetes Engine (GKE) or Slurm with Cluster Director or Cluster Toolkit. Data flows from high-throughput storage into the accelerator cluster, gradients flow between accelerators during forward and backward passes, and checkpoints flow back to multi-regional or dual-region Cloud Storage buckets for redundancy. For sustained multi-week runs, a reservation long enough to earn committed use discounts provides assurance of large-scale capacity.
The three processor families divide work by flexibility, operation support, and scale:
| Option | Best-fit workload pattern | Batch and scale signal | Key constraint |
|---|---|---|---|
| CPUs | Prototyping and simple models, including models with many custom TensorFlow operations written in C++ | Small effective batch sizes, I/O or host-bandwidth limited | Limited throughput for large matrix-heavy training |
| GPUs | Medium-to-large models needing broader operation coverage | Larger effective batch sizes on single hosts or managed clusters | Custom PyTorch or JAX operations or unavailable TensorFlow operations force partial CPU execution |
| TPUs | Matrix-dominated large models, long training runs, and ultra-large embedding workloads | Large effective batch sizes, TPU slices for data-parallel scale | Requires XLA-compilable graphs, static shapes, and no custom operations in the main loop |
TPUs are available through Compute Engine, Google Kubernetes Engine, and Gemini Enterprise Agent Platform, and parameter-efficient fine-tuning such as low-rank adaptation (LoRA), which freezes base weights and trains only small new layers, further reduces the compute profile for adaptation work.
Comparing performance and cost metrics across Google Cloud accelerators means weighing training throughput and inference latency against memory capacity, interconnect scale, and cost per training hour. AI Hypercomputer (opens in a new tab) is the unified portfolio that packages performance-optimized infrastructure, open software, and flexible consumption models to maximize goodput, the measure of actual machine learning productivity. The choice centers on three families: high-end NVIDIA GPUs in A-series machines for pre-training and large-model work, cost-efficient G-series and N1 GPUs for inference and graphics, and Cloud Tensor Processing Units (TPUs) for large matrix operations with high-bandwidth memory.
Accelerator families on Google Cloud map directly to workload intensity, from large-scale pre-training to small-model serving. A-series machines including A4X Max, A4X, A4, A3 Ultra, A3 Mega, A3 High, and A2 (opens in a new tab) cover pre-training, while fine-tuning adds G4 and serving inference adds A3 Edge and G4 for lower-cost deployment. Graphics-intensive workloads use G4, G2, and N1 with T4, and high performance computing can use any accelerator-optimized series depending on how much computation must be offloaded to the GPU. Within GPUs, General GPUs are managed as independent compute units with asynchronous maintenance, while Clustered GPUs are managed as a single tightly coupled system with synchronized maintenance.
| Workload | High-end choice | Cost-efficient choice |
|---|---|---|
| Model fine-tuning | A100 and H100 GPUs in A4 and A3 series are recommended | G4 provides a lower-cost entry point for smaller fine-tuning jobs |
| Large model inference | A100 and H100 GPUs are recommended for largest models | RTX PRO 6000 and L4 GPUs are also recommended |
| Medium and small model inference | High-end GPUs are typically not required | RTX PRO 6000, L4, and T4 GPUs in G4, G2, and N1 machines are recommended |
The table shows that A100 and H100 class hardware justifies its higher hourly cost when model size, batch size, or distributed training demands exceed what L4, T4, or RTX PRO 6000 can serve efficiently. Choose A-series clustered capacity when training must scale across many accelerators as one system, and choose G-series or N1+T4 when inference latency targets can be met with smaller memory and lower hourly rates.
Memory, interconnect, and scaling architecture determines whether additional accelerators produce linear speedup or stall on communication and I/O. Cloud TPUs use hardware designed for large matrix operations and include on-chip high-bandwidth memory (HBM) to hold larger models and batch sizes, and TPUs connect in groups called slices that scale workloads with little to no code changes. Clustered GPUs provide automated hardware health monitoring and proactive node replacement for tightly coupled multi-GPU training, while General GPUs use standard node auto-repair to maintain pod-level uptime for serving fleets. Dynamic Workload Scheduler (DWS) (opens in a new tab) provides atomic provisioning of entire blocks of interconnected nodes for large-scale training, so either all requested nodes start together or none start.
Cluster Director builds on this foundation by deploying and managing accelerator groups with colocation and scheduling for multi-GPU training on A3 Ultra with H200 and A4 with B200, supporting both Google Kubernetes Engine (GKE) and Slurm clusters. Storage completes the data path with Google Cloud Managed Lustre, a parallel file system that can attach to 10,000 or more Pods, Cloud Storage Rapid and Cloud Storage FUSE for high-throughput weight access, and Hyperdisk ML block storage that can attach to up to 2,500 Pods. Together, colocated compute, synchronized maintenance, atomic scheduling, and parallel storage keep accelerators spending time on productive computation rather than waiting for data or failed nodes.
Inference performance metrics separate how fast the first result appears from how fast the full response streams and how many requests the system sustains. Latency indicators focus on token timing for generative models, while throughput indicators focus on aggregate token and request rates under load. These metrics flow from the model server, such as vLLM or Triton, into Cloud Monitoring and the model observability dashboard for queries per second, token throughput, and first-token latency.
High TTFT points to prefill, weight-loading, or accelerator bottlenecks, while high TPOT or ITL points to decode bottlenecks during streaming. Choose higher-memory accelerators and parallel storage when TTFT dominates startup, and choose scaled-out GPU or TPU replicas with model-aware routing when tokens-per-second throughput must grow under concurrent load.
Cost per training hour on Google Cloud is the sum of attached GPUs plus predefined vCPU, memory, and bundled Local SSD, with only one discount type applying to a resource at any time. For stable 24x7 inference or training with fixed capacity, committed use discounts (CUDs) lower the hourly rate, while elastic or fault-tolerant work uses discounted preemptible or scheduled capacity. GKE Inference Gateway (opens in a new tab) and custom compute classes further control cost by routing compute-intensive generative AI tasks to reserved GPU and TPU instances and falling back to Spot VMs when reserved capacity is unavailable.
For longer horizons, DWS Calendar mode reserves specific GPUs such as H100 and H200 and TPUs such as Trillium for up to three months. A vLLM engine with GPU and TPU fungibility can shift dynamically between accelerator types to balance fluctuating capacity, performance, and cost.
Exam tip: Compute flexible CUDs cover GPUs only on G2 and G4; A3, A4, and A2 GPU discounts require reservations with resource-based commitments.
Central processing units (CPUs) fit quick prototyping, simple models, and small effective batch sizes especially when limited by host input/output or networking bandwidth, graphics processing units (GPUs) fit medium-to-large models with larger effective batch sizes needing broader operation coverage, and Tensor Processing Units (TPUs) fit matrix-dominated large models with large effective batch sizes that train for weeks or months. GPUs are needed when code depends on TensorFlow operations not available on Cloud TPU or on custom PyTorch or JAX operations that must run at least partially on CPUs. TPUs require graphs compiled by accelerated linear algebra (XLA), static shapes, and no custom operations in the main training loop, with batch or feature dimensions sized to multiples of 128 to avoid zero-padding of the 128x128 matrix unit (MXU).
Dynamic Workload Scheduler (DWS) Flex-Start mode supports complex batch training on high-end GPUs for up to seven days, where Google Kubernetes Engine (GKE) persists the request and automatically provisions Flex-Start virtual machines when capacity appears. Flex-Start is billed pay as you go with up to a 53 percent discount for vCPUs, GPUs, TPUs, and attached Local SSD disks. Calendar mode reserves specific GPUs such as H100 and H200 and TPUs such as Trillium for a future date and time for longer runs up to 90 days or three months.
Use committed use discounts (CUDs) for stable, long-running training with fixed or predictable capacity to lower the hourly rate, and use Spot VMs for fault-tolerant evaluation and experimentation. Spot VMs carry the deepest discount between 61 percent and 90 percent but can be preempted at any time, so they fit only training where checkpoints and retries can absorb preemption.
Time to First Token (TTFT) measures time in milliseconds to generate the first token for a request, while Time Per Output Token (TPOT) measures time per token as request latency minus TTFT divided by total output tokens minus one. High TTFT points to prefill, weight-loading, or accelerator bottlenecks, while high TPOT points to decode bottlenecks during streaming.
Last updated