This document explains the architecture, slice topologies, OS image families,
and capacity consumption options when you use Cluster Toolkit to
deploy Slurm clusters with Cloud TPU compute nodes for artificial
intelligence (AI) and machine learning (ML) workloads. For background
information, see the [Slurm overview](https://slurm.schedmd.com/overview.html)
and [Introduction to Cloud TPU](https://docs.cloud.google.com/tpu/docs/intro-to-tpu.md.txt).

## About Slurm in Cluster Toolkit

Slurm is an open-source cluster management and job scheduling system for high
performance computing (HPC) and AI/ML workloads. Cluster Toolkit
provides [blueprints](https://docs.cloud.google.com/cluster-toolkit/docs/setup/cluster-blueprint.md.txt) and
[modules](https://docs.cloud.google.com/cluster-toolkit/docs/modules/overview.md.txt) that automate the deployment
of Slurm clusters on Google Cloud, including the Slurm controller, login nodes,
networking, shared storage, and compute partitions.

In a Slurm cluster that is deployed with Cluster Toolkit, you
organize compute nodes into
[nodesets](https://docs.cloud.google.com/cluster-toolkit/docs/modules/slurm-nodeset.md.txt) and
[partitions](https://docs.cloud.google.com/cluster-toolkit/docs/modules/slurm-partition.md.txt). Each nodeset can
provision either always-on static nodes or on-demand dynamic nodes that
autoscale. To learn how to choose between static and dynamic nodes, see [About
node types](https://docs.cloud.google.com/cluster-toolkit/docs/slurm/node-types).

> [!NOTE]
> **Note:** Deployments for TPU v5e and later TPU generations use the standard [`schedmd-slurm-gcp-v6-nodeset`
> module](https://docs.cloud.google.com/cluster-toolkit/docs/modules/slurm-nodeset) with the `accelerator_topology` setting, rather than the legacy [`schedmd-slurm-gcp-v6-nodeset-tpu`
> module](https://docs.cloud.google.com/cluster-toolkit/docs/modules/slurm-nodeset-tpu) that is used for earlier TPU generations.

## Cloud TPU Slurm deployments in Cluster Toolkit

Cloud TPU is Google's custom-developed application-specific integrated
circuit (ASIC) used to accelerate machine learning workloads. On
Compute Engine, you can provision and manage Cloud TPU resources by
using standard Compute Engine instances and managed instance groups
(MIGs). For more information, see [TPU resources in
Compute Engine](https://docs.cloud.google.com/tpu/docs/tpus-in-compute-engine).

In a Slurm cluster, the Slurm controller provisions these
Compute Engine instances and MIGs as compute nodes in your nodesets
and partitions. When you submit a job, Slurm schedules your workload across
those nodes.

To deploy a Slurm cluster with Cloud TPU nodes, you work with the
following hardware concepts:

- **TPU slices**: a Cloud TPU slice is a collection of Cloud TPU chips located inside the same pod that are physically connected over a dedicated, high-speed inter-chip interconnect (ICI).
- **TPU topologies** : a topology defines the number and physical arrangement of Cloud TPU chips within a slice. Each supported `*-4t` compute instance contains 4 Cloud TPU chips. Depending on the Cloud TPU generation, chips are arranged in either a 2D (`AxB`) or 3D (`AxBxC`) torus interconnect topology. For static Cloud TPU partitions in Slurm, the number of static nodes, as defined by the `tpu_static_nodes` field, must be a multiple of the number of compute instances per slice.

The following table lists the Cloud TPU generations and machine types
supported in Slurm blueprints:

| TPU generation | Machine type (`tpu_machine_type`) | Slurm `--layout` type | Topology format | TPU chips per compute instance |
|---|---|---|---|---|
| [Ironwood (TPU7x)](https://docs.cloud.google.com/tpu/docs/tpu7x.md.txt) | `tpu7x-standard-4t` | `tpu7x` | 3D torus (`AxBxC`) | 4 (8 TPU cores) |
| [TPU v6e](https://docs.cloud.google.com/tpu/docs/v6e.md.txt) | `ct6e-standard-4t` | `v6e` | 2D torus (`AxB`) | 4 (4 TPU cores) |
| [TPU v5p](https://docs.cloud.google.com/tpu/docs/v5p.md.txt) | `ct5p-hightpu-4t` | `v5p` | 3D torus (`AxBxC`) | 4 (8 TPU cores) |
| [TPU v5e](https://docs.cloud.google.com/tpu/docs/v5e.md.txt) | `ct5lp-hightpu-4t` | `v5e` | 2D torus (`AxB`) | 4 (4 TPU cores) |

The following table lists common 2D and 3D slice topologies and their
corresponding chip and compute instance counts per slice:

| 2D topology for TPU v6e and TPU v5e | 3D topology for Ironwood (TPU7x) and TPU v5p | TPU chips per slice | Compute instances per slice |
|---|---|---|---|
| `2x2` | `2x2x1` | 4 | 1 |
| `2x4` | `2x2x2` | 8 | 2 |
| `4x4` | `2x2x4` | 16 | 4 |
| `4x8` | `2x4x4` | 32 | 8 |
| `8x8` | `4x4x4` | 64 | 16 |

## Slurm cluster architecture

Each blueprint organizes cluster resources into two deployment groups so that
you can update or redeploy the Slurm cluster and keep your foundational network
and storage:

- **`cluster-env` group** : provisions a [Virtual Private Cloud (VPC)
  network](https://docs.cloud.google.com/cluster-toolkit/docs/modules/vpc), configures [private services
  access](https://docs.cloud.google.com/vpc/docs/private-services-access), and creates a [Google Cloud Managed Lustre](https://docs.cloud.google.com/managed-lustre/docs/overview.md.txt) file system that is mounted at the `/home` directory across all of the nodes in the cluster for shared environments, datasets, and checkpoints.
- **`cluster` group**: provisions a Slurm controller, a login node, and two
  Cloud TPU partitions:

  - **Static partition (`-p tpu`)**: provisions always-on static Cloud TPU nodes that are grouped into slices with a fixed 2D or 3D topology.
  - **Dynamic partition (`-p tpu-dyn`)** : provisions on-demand dynamic Cloud TPU nodes that create a slice to match your job's `--layout` flag and power down when idle.

## Image families and boot disks

Compute nodes in the Cloud TPU partitions use prebuilt
[Advanced Compute Images](https://docs.cloud.google.com/compute/docs/images/workload/aci-images.md.txt) that require 100 GB of
disk space. You configure the type of boot disk, such as Google Cloud Hyperdisk or
the `pd-ssd` disk type, in the blueprint rather than in the image.

The following table lists the prebuilt image family and default boot disk for
each Cloud TPU generation:

| TPU generation | Image family | Default boot disk |
|---|---|---|
| Ironwood (TPU7x) | `aci-tpu-tpu7x-u2404-slurm-2605-amd64` | Hyperdisk Balanced |
| TPU v6e | `aci-tpu-v5e-v5p-v6e-u2204-slurm-2605-amd64` | Hyperdisk Balanced |
| TPU v5p | `aci-tpu-v5e-v5p-v6e-u2204-slurm-2605-amd64` | Balanced Persistent Disk (`pd-balanced`) |
| TPU v5e | `aci-tpu-v5e-v5p-v6e-u2204-slurm-2605-amd64` | Balanced Persistent Disk (`pd-balanced`) |

## Consumption options

To balance capacity availability, workload duration, and cost,
Cluster Toolkit supports on-demand capacity, reserved capacity,
Dynamic Workload Scheduler with Flex-start mode, and Spot VMs for your
Cloud TPU partitions:

- **On-demand** : provisions standard [on-demand
  instances](https://docs.cloud.google.com/compute/docs/instances/provisioning-models#standard) without a reservation. This option is the default in the blueprint.
- **Reservation-bound** : consumes capacity from a specific local or shared [Compute Engine
  reservation](https://docs.cloud.google.com/compute/docs/instances/reservations-overview). This option is the default in the example deployment files.
- **Dynamic Workload Scheduler with Flex-start mode** : requests Cloud TPU capacity on demand for up to seven days by using [Dynamic Workload Scheduler with Flex-start
  mode](https://docs.cloud.google.com/compute/docs/instances/provisioning-models#flex-start-vms).
- **Spot VMs** : provisions preemptible [Spot VMs](https://docs.cloud.google.com/compute/docs/instances/spot.md.txt) at a discounted price for fault-tolerant workloads.

## What's next

- [Deploy an Ironwood (TPU7x) Slurm
  cluster](https://docs.cloud.google.com/cluster-toolkit/docs/deploy/slurm/slurm-tpu-7x)
- [Deploy a Slurm TPU v6e
  cluster](https://docs.cloud.google.com/cluster-toolkit/docs/deploy/slurm/slurm-tpu-v6e)
- [Deploy a Slurm TPU v5p
  cluster](https://docs.cloud.google.com/cluster-toolkit/docs/deploy/slurm/slurm-tpu-v5p)
- [Deploy a Slurm TPU v5e
  cluster](https://docs.cloud.google.com/cluster-toolkit/docs/deploy/slurm/slurm-tpu-v5e)