This document explains how to design, orchestrate, and manage artificial
intelligence (AI) and machine learning (ML) workloads on Google Cloud
infrastructure.

In a self-managed environment, you provision and control the Compute Engine
instances, graphics processing units (GPUs), tensor processing units (TPUs),
storage resources, and networks that run your models. Self-managed
infrastructure gives you control over your hardware topology, guest operating
system (OS), software stack, and job schedulers.

Based on your infrastructure requirements, choose one of the following
approaches:

- If you prefer a managed platform that abstracts the underlying
  infrastructure, then see
  [Gemini Enterprise Agent Platform](https://docs.cloud.google.com/gemini-enterprise-agent-platform/machine-learning.md.txt).

- If you require control over your clusters, accelerators, and runtime
  environments, then use the architectural patterns and tools in this
  document.

## Training versus inference setups

AI and ML workloads divide into the following operational phases. Each phase
places distinct demands on your compute, network, and storage architecture:

- **Model training**: teaches a model to recognize patterns and generate
  accurate outputs. During this phase, your infrastructure processes large
  datasets and updates model parameters across synchronized accelerators.

- **Model inference**: runs a trained model to generate predictions or content
  for users and applications. During this phase, your infrastructure processes
  live requests or batch inputs across independent model replicas.

The following table compares the architectural characteristics of model training
and model inference:

| Architectural dimension | Model training | Model inference |
|---|---|---|
| **Primary goal** | Maximize throughput and *goodput*, which is the rate of useful computation that advances model state. | Minimize response latency and maximize request throughput for client applications. |
| **Compute topology** | Hundreds or thousands of accelerators work as a single synchronous unit across multiple compute instances. | Single compute instances or small multi-host groups process requests in parallel across independent replicas. |
| **Network requirements** | Low-latency and high-bandwidth host-to-host fabrics synchronize gradients across every step. | Standard data center networks route client traffic to single-host endpoints, while multi-host and disaggregated inference setups also require high-bandwidth host-to-host fabrics. |
| **Storage pattern** | High-throughput sequential reads ingest large datasets, and periodic bursts write state checkpoints. | Fast initial reads load model weights into accelerator memory at startup. |
| **Elasticity and availability** | Reserved or scheduled capacity runs until job completion and recovers from faults through checkpoints. | Dynamic capacity adds or removes replicas to match real-time traffic demand and maintain high availability. |

### Model training architecture

Model training updates billions or trillions of parameters across large
datasets. A single compute instance can't hold a large foundation model or
complete a training run in a practical period. To overcome single-host limits,
distributed training splits the model and dataset across many compute
instances. During distributed training, all participating accelerators calculate
gradients and exchange state updates at the end of every step. If a single
compute instance slows down or drops offline, then the entire cluster waits and
accelerator capacity sits idle.

To help reduce these bottlenecks on
[clustered GPUs](https://docs.cloud.google.com/ai-hypercomputer/docs/evaluate-clustered-gpus.md.txt) or TPUs,
[AI Hypercomputer](https://docs.cloud.google.com/ai-hypercomputer/docs/overview.md.txt) provides cluster
management capabilities across placement, maintenance, and cluster health.

#### Dense colocation and compact placement policies

Physical distance between host machines introduces network latency that degrades
synchronous communication. Compute Engine provisions clustered GPUs
and TPUs as dense blocks and racks connected by high-speed network fabrics, such
as remote direct memory access (RDMA) for GPUs and Inter-Chip Interconnect
(ICI) for TPUs.

To colocate your compute instances and minimize network hops, apply
[compact placement policies](https://docs.cloud.google.com/compute/docs/instances/placement-policies-overview.md.txt)
or use the
[reservation-bound provisioning model](https://docs.cloud.google.com/ai-hypercomputer/docs/consumption-models.md.txt).

#### Synchronized maintenance

Standard cloud infrastructure staggers host maintenance events across compute
instances. For a synchronous training job, staggered maintenance disrupts the
cluster multiple times because a single-node restart halts the entire job.

For clustered GPUs and TPUs, Compute Engine supports synchronized
(*grouped*) maintenance across compute instances in a block. This approach
updates hosts at the same time to reduce total cluster downtime and maximize
goodput.

#### Operational modes and health checks

When you reserve capacity for clustered GPUs, the machine series determines
the cluster operational mode:

- **Managed mode**: Compute Engine holds back part of your reserved
  capacity as spare machines and replaces faulty hosts after host errors or
  faulty host reports.

- **All-capacity mode**: you get access to your full reserved capacity, and
  you manage host replacements and planned maintenance on your own.

To identify degraded compute instances before they stall a job, run automated
health checks and monitor node health predictions. For more information, see
[Cluster management capabilities](https://docs.cloud.google.com/ai-hypercomputer/docs/cluster-capabilities.md.txt).

### Model inference architecture

Unlike distributed training, where hundreds of compute instances operate as a
single system, an inference deployment distributes client requests or batch jobs
across independent model replicas. Each replica loads a copy of the trained
model weights into accelerator memory and processes inputs on its own.

#### Right-sized accelerator configurations

Most inference models fit on a single accelerator, a single multi-GPU instance,
or a small TPU slice. You can run standard inference on
[general GPUs](https://docs.cloud.google.com/ai-hypercomputer/docs/evaluate-general-gpus.md.txt), and use
clustered GPUs or TPUs for large frontier models or multi-host inference
workloads.

#### Model servers and traffic distribution

To maximize throughput and reduce latency, deploy an inference engine such as
[vLLM](https://docs.vllm.ai/), [SGLang](https://docs.sglang.ai/), or
[NVIDIA Triton Inference Server](https://developer.nvidia.com/triton-inference-server),
which batches concurrent requests and manages key-value (KV) caches. The
following table shows how Compute Engine and
Google Kubernetes Engine (GKE) distribute requests and deploy inference stacks:

| Platform | Traffic distribution and deployment tools |
|---|---|
| **Compute Engine** | To distribute requests across replicas, place [Cloud Load Balancing](https://docs.cloud.google.com/load-balancing/docs/load-balancing-overview.md.txt) in front of [managed instance groups (MIGs)](https://docs.cloud.google.com/compute/docs/instance-groups.md.txt) or use [Ray Serve](https://docs.ray.io/en/latest/serve/index.html). |
| **GKE** | To route requests based on model server metrics and KV cache utilization, use [GKE Inference Gateway](https://docs.cloud.google.com/kubernetes-engine/docs/concepts/about-gke-inference-gateway.md.txt). To deploy benchmarked single-host or multi-host configurations, use [GKE Inference Quickstart](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/machine-learning/inference/inference-quickstart.md.txt) or [Cluster Toolkit](https://docs.cloud.google.com/cluster-toolkit/docs/overview.md.txt) blueprints. |

#### Asynchronous maintenance

Inference fleets serve continuous traffic and can't tolerate simultaneous
downtime across all replicas. Compute Engine applies independent
(*asynchronous*) maintenance schedules to general GPUs so that compute
instances receive updates one at a time. Your load balancer routes traffic to
healthy replicas while individual compute instances undergo maintenance.

#### Elastic capacity and fast startup

Inference traffic fluctuates based on client demand. Your orchestration layer
adds or removes compute instances or containers in response to request queues or
accelerator utilization metrics. When new compute instances start, those
instances must load model weights from storage into accelerator memory with
minimal delay.

## Orchestration tools

To run AI and ML workloads on self-managed infrastructure, select a workload
orchestrator (such as Slurm, Kubernetes, or Ray) and a deployment tool. The
orchestrator schedules jobs, and the deployment tool provisions and manages your
cluster. Google Cloud provides four deployment and orchestration options
for self-managed AI and ML clusters.

### Cluster Director

Cluster Director is a managed service that automates deployment and
lifecycle management for AI, ML, and high performance computing (HPC) clusters
with NVIDIA GPUs or Google TPUs. Google sets up an
ML-optimized OS and configures login nodes, compute nodesets, storage,
high-speed networks, and Slurm orchestration for you.

If you want to train AI models or run jobs scheduled by Slurm without manual
network setup or cluster OS configuration tasks, then choose
Cluster Director. For more information, see
[Cluster Director overview](https://docs.cloud.google.com/cluster-director/docs/overview.md.txt).

### Cluster Toolkit

Cluster Toolkit is an open source tool that uses customizable
deployment templates called *blueprints* to provision repeatable AI, ML, and HPC
clusters on Google Cloud. With these Infrastructure as Code (IaC)
configuration files, you deploy standardized clusters with NVIDIA GPUs or
Google TPUs and orchestrate workloads with Slurm or
GKE.

If you want automated deployment templates and want to retain administrative
control over your OS, software stack, and cluster lifecycle, then choose
Cluster Toolkit. For more information, see
[Cluster Toolkit overview](https://docs.cloud.google.com/cluster-toolkit/docs/overview.md.txt).

### Compute Engine

Compute Engine is Google Cloud's core Infrastructure as a Service
(IaaS) platform, which lets you create and run virtual machine (VM) and bare
metal instances with attached NVIDIA GPUs or Google TPUs. You retain
complete control over your OS, kernel settings, and boot files, and you scale
capacity through MIGs or custom orchestrators such as Ray.

If your workloads require custom architectural configurations, specialized
kernel settings, or direct control over compute instances, then choose
Compute Engine. For more information, see
[Compute Engine overview](https://docs.cloud.google.com/compute/docs/overview.md.txt).

### GKE

GKE runs containerized training and inference workloads on a
managed Kubernetes control plane. GKE integrates with Kubernetes
job schedulers such as Kueue and JobSet, provisions GPU and TPU node pools, and
scales inference containers and compute instances with Horizontal Pod
Autoscalers (HPA) and the cluster autoscaler.

If you run containerized applications and want automated health repairs,
workload queues, and multi-host GPU or TPU orchestration, then choose
GKE. For more information, see
[AI infrastructure on GKE](https://docs.cloud.google.com/kubernetes-engine/docs/integrations/ai-infra.md.txt).

To compare these options in detail, see the following resources:

- For a decision tree that maps AI and ML workloads to these four tools, see
  [Choose an orchestrator and deployment option](https://docs.cloud.google.com/ai-hypercomputer/docs/choose-platform.md.txt).

- For a feature comparison table that also includes serverless and managed
  batch options such as Cloud Run and Batch, see
  [Choose compute options](https://docs.cloud.google.com/docs/compute-area/choose-compute-options.md.txt#comparison).

## Hardware selection for AI and ML workloads

To select hardware for your AI and ML workloads, match your model architecture,
parameter count, and software framework to Google Cloud accelerator
capabilities. Google Cloud offers both NVIDIA GPUs and Google
TPUs on self-managed infrastructure.

### Match accelerators to workload phase

Large-scale foundation model training requires multi-host clusters with
high-bandwidth interconnects and high-bandwidth memory (HBM). These workloads
run on clustered GPUs (A4X Max, A4X, A4, A3 Ultra, A3 Mega, or A3 High with 8
GPUs) or on multi-host TPU slices.

Standard inference, fine-tuning, and small-model training run on smaller
accelerator configurations. Choose general GPUs (G4, G2, A2, or A3 High with 1,
2, or 4 GPUs) or single-host TPU configurations for these workloads.

### Size HBM and interconnects for your model

Your accelerator memory must hold your model weights, activations, KV caches for
inference, and optimizer states for training. If your model exceeds the memory
of a single accelerator or compute instance, then select compute instances with
high HBM capacity and fast chip-to-chip interconnects. Interconnects such as
NVLink on GPUs or ICI on TPUs let you split the model across multiple chips.

### Match accelerators to your framework

If your workloads rely on CUDA-based custom kernels, third-party libraries, or
unmodified PyTorch code, then choose GPU instances. If you build models with
JAX, PyTorch/XLA, or TensorFlow and want purpose-built matrix
computation engines with 2D or 3D torus interconnects, then choose TPUs.

To explore detailed hardware specifications, machine series, and interconnect
topologies for each accelerator family, see the following documents:

- [Understand GPUs](https://docs.cloud.google.com/docs/compute-area/gpus.md.txt)

- [Understand TPUs](https://docs.cloud.google.com/docs/compute-area/tpus.md.txt)

After you identify candidate hardware for your workload, evaluate how those
accelerators perform under realistic conditions. Hardware specifications on
their own don't capture real-world throughput, latency, or price performance.
For more information about how to measure tokens per second per chip (TPS/chip),
run microbenchmarks, and perform roofline analysis, see
[AI accelerator performance and benchmarking](https://docs.cloud.google.com/docs/compute-area/accelerator-performance-benchmarking.md.txt).

## Self-managed infrastructure best practices

When you manage your own AI and ML infrastructure on Google Cloud, apply
architectural best practices across security, cost optimization, and data
management. This approach helps keep your environments resilient and
cost-effective.

### Secure clusters and model weights

AI training datasets and proprietary model weights represent high-value
intellectual property. Apply the following security controls across your
network, identity, and host layers to help protect your self-managed clusters:

- **Isolate cluster networks**: deploy your compute instances with private IP
  addresses inside a Virtual Private Cloud (VPC) network. Enable
  Private Google Access so that compute instances can reach
  Google Cloud APIs and storage buckets without external IP addresses,
  and use Cloud NAT for outbound internet access.

- **Enforce least-privilege identity and access**: attach dedicated service
  accounts with minimal Identity and Access Management (IAM) roles to your compute
  instances and GKE workloads. Don't use the
  Compute Engine default service account, which carries broad
  project-wide permissions.

- **Harden hosts and encrypt data**: enable Shielded VM features,
  including Secure Boot and virtual trusted platform module (vTPM) integrity
  monitoring, to help verify that your boot software and kernel drivers remain
  unaltered. If your organization requires control over encryption keys for
  model weights and training data at rest, then configure customer-managed
  encryption keys (CMEK) in Cloud Key Management Service.

### Optimize accelerator costs and utilization

Accelerators represent a significant portion of AI infrastructure budgets. Match
consumption models to your workload schedule, monitor cluster health, and scale
inference fleets to demand.

#### Match consumption options to workload duration

The following table maps workload durations and fault tolerance to
Google Cloud consumption options:

| Workload type | Recommended options | Capacity and pricing |
|---|---|---|
| **Long-running distributed workloads** | [Future reservations for capacity blocks](https://docs.cloud.google.com/compute/docs/instances/choose-reservation-type.md.txt#reserve-capacity-aihc) with [resource-based commitments](https://docs.cloud.google.com/compute/docs/instances/signing-up-committed-use-discounts.md.txt) (one year or longer), or [on-demand reservations](https://docs.cloud.google.com/compute/docs/instances/reservations-overview.md.txt) and [future reservations](https://docs.cloud.google.com/compute/docs/instances/future-reservations-overview.md.txt) for single-host or best-effort workloads. | Reserves blocks of GPUs, TPUs, Local SSD disks, and Google Cloud Hyperdisk pools for multi-month pre-training or multi-host inference. |
| **Short-running distributed workloads** | [Future reservations in calendar mode](https://docs.cloud.google.com/compute/docs/instances/future-reservations-calendar-mode-overview.md.txt) (up to 90 days) or [Flex-start VMs](https://docs.cloud.google.com/compute/docs/instances/about-flex-start-vms.md.txt) (up to 7 days). | Uses Dynamic Workload Scheduler pricing for discounts of up to 53%. |
| **Fault-tolerant workloads** | [Spot VMs](https://docs.cloud.google.com/compute/docs/instances/spot.md.txt). | Provides discounts of up to 91% for batch inference, data preparation, or evaluation jobs that tolerate preemption. |

For more information, see
[Choose a reservation type](https://docs.cloud.google.com/compute/docs/instances/choose-reservation-type.md.txt).

#### Maximize goodput with proactive diagnostics

Idle or degraded accelerators waste budget without advancing your workload.
Before you launch large jobs, run active cluster health checks to detect
network or GPU faults. Automate job restarts from saved checkpoints so that a
host error doesn't leave your cluster idle.

#### Scale inference fleets to match demand

Don't provision static inference capacity for peak traffic. Configure HPA in
GKE or MIG autoscaling in Compute Engine based on
custom accelerator metrics, such as GPU utilization or request queue depth. In
non-production environments, delete or scale down idle development instances to
avoid unnecessary charges.

### Manage storage and checkpoint pipelines

If your storage layer can't supply training data at the rate your accelerators
consume it, then your accelerators sit idle. Slow storage systems also delay
checkpoint writes and model weight loads.

#### Use a tiered storage architecture

Store your primary datasets, model artifacts, and archival checkpoints in
Cloud Storage for durability and cost efficiency. To prevent remote I/O
bottlenecks during training or model startup, pair Cloud Storage with
attached Local SSD disks that cache active training data close to your
accelerators. For block storage workloads, use
[Hyperdisk pools](https://docs.cloud.google.com/compute/docs/disks/pools.md.txt) to share provisioned
capacity and performance across disks.

#### Choose a storage service for your access pattern

The following table matches AI and ML data access patterns to Google Cloud
storage services:

| Access pattern | Recommended service | Primary benefit |
|---|---|---|
| Load read-only model weights across multiple compute instances | [Google Cloud Hyperdisk ML](https://docs.cloud.google.com/compute/docs/disks/hd-types/hyperdisk-ml.md.txt) | Reduces cold-start latency with shared read-only block storage. |
| Read sequential shards or download weights from object buckets | [Cloud Storage FUSE](https://docs.cloud.google.com/storage/docs/cloud-storage-fuse/overview.md.txt) with Local SSD read caches | Mounts Cloud Storage buckets as local file systems. |
| Perform high-throughput zonal reads and weight downloads | [Rapid Bucket](https://docs.cloud.google.com/storage/docs/rapid/rapid-bucket.md.txt) and [Rapid Cache](https://docs.cloud.google.com/storage/docs/rapid/rapid-cache.md.txt) | Colocates zonal object storage and read caches in the same zone as your compute instances. |
| Run synchronous checkpoint writes or KV cache transfers across thousands of instances | [Google Cloud Managed Lustre instances](https://docs.cloud.google.com/managed-lustre/docs/overview.md.txt) | Provides a POSIX-compliant parallel file system with sub-millisecond latency. |

#### Optimize checkpoint frequency and transfers

Frequent synchronous checkpoints help protect training progress against hardware
faults, but excessive checkpoint writes pause training computation. Balance your
checkpoint interval against your cluster's mean time between failures. To let
accelerators resume computation without delay, use asynchronous multi-tiered
writes from host memory or Local SSD disks to persistent storage.

For more information, see
[About storage services for AI and ML workloads](https://docs.cloud.google.com/ai-hypercomputer/docs/storage.md.txt).

## What's next

- [AI accelerator performance and benchmarking](https://docs.cloud.google.com/docs/compute-area/accelerator-performance-benchmarking.md.txt)

- [Understand GPUs](https://docs.cloud.google.com/docs/compute-area/gpus.md.txt)

- [Understand TPUs](https://docs.cloud.google.com/docs/compute-area/tpus.md.txt)

- [Choose compute options](https://docs.cloud.google.com/docs/compute-area/choose-compute-options.md.txt)

- [AI Hypercomputer overview](https://docs.cloud.google.com/ai-hypercomputer/docs/overview.md.txt)