Skip to content

[Doc][TPU] Update TPU docs for TorchTPU, MPMD, and RL workloads - #66991

Merged
andrewsykim merged 14 commits into
ray-project:masterfrom
ryanaoleary:docs-tpu-torchtpu-mpmd
Oct 20, 2026
Merged

andrewsykim merged 14 commits into
ray-project:masterfrom
ryanaoleary:docs-tpu-torchtpu-mpmd

Conversation

@ryanaoleary

@ryanaoleary ryanaoleary commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Why are these changes needed?

Updates the Ray TPU documentation to cover per-device execution ({"TPU": 1}) with TorchTPU, TPU v6e and TPU7x (Ironwood) cluster setup, MPMD and reinforcement learning (RL) scheduling, and TPU observability metrics:

  • KubeRay & Core scheduling (doc/source/kuberay/user-guides/tpu.md, gcp-gke-tpu-cluster.md, accelerators.md): Documents host-level ({"TPU": 4}, JAX / vLLM-TPU) vs. per-device ({"TPU": 1}, TorchTPU / vLLM-TorchTPU) scheduling, RAY_TPU_RESOURCE_PER_CHIP=2 for dual-chiplet TPU7x hosts, GKE node pool setup for TPU v6e and TPU7x (including consumption options and multi-NIC DRANET networking), kuberay-tpu-webhook (v1.4.0+) environment variables, slice_placement_group + run_on_slice examples, and disaggregated vs. colocated RL architectures.
  • Ray Train (doc/source/train/user-guides/using-accelerators.md): Adds TorchTrainer examples on TPUs using the tpu_dist (TorchTPU) backend and resources_per_worker={"TPU": 1}.
  • Ray Serve LLM (doc/source/serve/llm/user-guides/tpu.md, serve_tpu_multihost.py): Adds multi-host serving configuration and examples for vLLM-TorchTPU (placement_group_config={"bundle_per_worker": {"TPU": 1}}) alongside vLLM-TPU.
  • Observability (doc/source/ray-observability/reference/system-metrics.md): Documents the five TPU system metrics (ray_tpu_tensorcore_utilization, ray_tpu_memory_bandwidth_utilization, ray_tpu_duty_cycle, ray_tpu_memory_used, ray_tpu_memory_total).

Related issue number

#64055

Checks

@ryanaoleary ryanaoleary changed the title [Doc][TPU] Update TPU docs for TorchTPU, MPMD, SubslicePlacementGroup, and RL [Doc][TPU] Update TPU docs for TorchTPU, MPMD, and RL workloads Oct 14, 2026
@ryanaoleary

Copy link
Copy Markdown
Contributor Author

Manual Testing

Verified the KubeRay manifests and code snippets on TPU v6e (4x4, 4 hosts / 16 chips) and TPU7x (2x2x1, 1 host / 4 chips / 8 logical devices) on GKE with kuberay-tpu-webhook (v1.4.0+).

1. KubeRay workerGroupSpecs & Webhook Injection (doc/source/kuberay/user-guides/tpu.md)

TPU v6e (4x4, 4 hosts):

NAME                                         READY   STATUS    IP             NODE
ray-pr66991-v6e-head-2mwdg                   1/1     Running   10.52.6.13     gke-aaronliang-ray-t-default-pool-b771b50d-7z8f
ray-pr66991-v6e-tpu-v6e-group-worker-49kbl   1/1     Running   10.52.2.21     gke-tpu-682666e0-h992
ray-pr66991-v6e-tpu-v6e-group-worker-7t8f7   1/1     Running   10.52.4.19     gke-tpu-682666e0-v0q5
ray-pr66991-v6e-tpu-v6e-group-worker-n54b8   1/1     Running   10.52.5.19     gke-tpu-682666e0-b2g6
ray-pr66991-v6e-tpu-v6e-group-worker-xq7w2   1/1     Running   10.52.3.18     gke-tpu-682666e0-c9c8

Resources
---------------------------------------------------------------
Total Usage:
 0.0/104.0 CPU
 0.0/16.0 TPU
 0.0/1.0 TPU-v6e-16-head
 0.0/4.0 tpu-v6e-group-0

TPU7x (RAY_TPU_RESOURCE_PER_CHIP: "2", resources: '"{\"TPU\": 8}"'):

NAME                                        READY   STATUS    IP            NODE
ray-pr66991-v7x-head-mccdh                  1/1     Running   10.228.6.74   gke-ray-llm-cluster-default-pool-f2ea4691-gcwx
ray-pr66991-v7x-tpu-7x-group-worker-5jvx6   1/1     Running   10.228.2.8    gke-tpu-0f200503-q3hd

Resources
---------------------------------------------------------------
Total Usage:
 0.0/24.0 CPU
 0.0/8.0 TPU
 0.0/1.0 TPU-v7x-8-head
 0.0/1.0 tpu-7x-group-0

2. placement_group with bundle_label_selector (doc/source/kuberay/user-guides/tpu.md)

import ray
from ray.util.placement_group import placement_group

pg = placement_group(
    [{"TPU": 4}] * 4,
    strategy="SPREAD",
    bundle_label_selector=[{"ray.io/tpu-pod-type": "v6e-16"}] * 4,
)
ray.get(pg.ready())
PlacementGroup ready: True, bundles: [{'TPU': 4.0}, {'TPU': 4.0}, {'TPU': 4.0}, {'TPU': 4.0}]

3. slice_placement_group & run_on_slice (doc/source/kuberay/user-guides/tpu.md)

One process per host (JAX on TPU v6e 4x4):

[{'slice': 'tpu-v6e-group-0', 'global_devices': 16}, {'slice': 'tpu-v6e-group-0', 'global_devices': 16}, {'slice': 'tpu-v6e-group-0', 'global_devices': 16}, {'slice': 'tpu-v6e-group-0', 'global_devices': 16}]

One process per device (resources_per_bundle={"TPU": 1}):

  • TPU v6e (4x4, 16 workers across 4 hosts):
    [{'rank': 0, 'tpu_ids': ['0'], 'tpu_visible_chips': '0'}, {'rank': 1, 'tpu_ids': ['1'], 'tpu_visible_chips': '1'}, {'rank': 2, 'tpu_ids': ['2'], 'tpu_visible_chips': '2'}, {'rank': 3, 'tpu_ids': ['3'], 'tpu_visible_chips': '3'}, {'rank': 4, 'tpu_ids': ['0'], 'tpu_visible_chips': '0'}, {'rank': 5, 'tpu_ids': ['1'], 'tpu_visible_chips': '1'}, {'rank': 6, 'tpu_ids': ['2'], 'tpu_visible_chips': '2'}, {'rank': 7, 'tpu_ids': ['3'], 'tpu_visible_chips': '3'}, {'rank': 8, 'tpu_ids': ['0'], 'tpu_visible_chips': '0'}, {'rank': 9, 'tpu_ids': ['1'], 'tpu_visible_chips': '1'}, {'rank': 10, 'tpu_ids': ['2'], 'tpu_visible_chips': '2'}, {'rank': 11, 'tpu_ids': ['3'], 'tpu_visible_chips': '3'}, {'rank': 12, 'tpu_ids': ['0'], 'tpu_visible_chips': '0'}, {'rank': 13, 'tpu_ids': ['1'], 'tpu_visible_chips': '1'}, {'rank': 14, 'tpu_ids': ['2'], 'tpu_visible_chips': '2'}, {'rank': 15, 'tpu_ids': ['3'], 'tpu_visible_chips': '3'}]
    
  • TPU7x (2x2x1 with RAY_TPU_RESOURCE_PER_CHIP=2, 8 workers across 4 physical chips):
    [{'rank': 0, 'tpu_ids': ['0'], 'tpu_visible_chips': '0'}, {'rank': 1, 'tpu_ids': ['1'], 'tpu_visible_chips': '0'}, {'rank': 2, 'tpu_ids': ['2'], 'tpu_visible_chips': '1'}, {'rank': 3, 'tpu_ids': ['3'], 'tpu_visible_chips': '1'}, {'rank': 4, 'tpu_ids': ['4'], 'tpu_visible_chips': '2'}, {'rank': 5, 'tpu_ids': ['5'], 'tpu_visible_chips': '2'}, {'rank': 6, 'tpu_ids': ['6'], 'tpu_visible_chips': '3'}, {'rank': 7, 'tpu_ids': ['7'], 'tpu_visible_chips': '3'}]
    

4. JaxTrainer & TorchTrainer (doc/source/train/user-guides/using-accelerators.md)

JaxTrainer (num_workers=4, use_tpu=True, topology="4x4", accelerator_type="TPU-V6E"):

(TrainController pid=3258) Using SlicePlacementGroup utility to reserve 1 slice(s) with topology '4x4'...
(TrainController pid=3258) Attempting to start training worker group of size 4 with the following resources: [{'TPU': 4, 'accelerator_type:TPU-V6E': 0.001}] * 4
(RayTrainWorker pid=3345, ip=10.52.2.21) Reporting training result 1: TrainingReport(checkpoint=None, metrics={'num_devices': 16}, validation=False)

TorchTrainer with TorchTPU tpu_dist (num_workers=16, use_tpu=True, topology="4x4", accelerator_type="TPU-V6E", resources_per_worker={"TPU": 1}):

(TrainController pid=4406) Using SlicePlacementGroup utility to reserve 1 slice(s) with topology '4x4'...
(TrainController pid=4406) Attempting to start training worker group of size 16 with the following resources: [{'TPU': 1, 'accelerator_type:TPU-V6E': 0.001}] * 16
(RayTrainWorker pid=4815, ip=10.52.2.21) Successfully renamed PrivateUse1 backend to 'tpu'. Device: device(type='tpu')
(RayTrainWorker pid=4815, ip=10.52.2.21) Initializing TPU distributed runtime
(RayTrainWorker pid=4815, ip=10.52.2.21) Reporting training result 1: TrainingReport(checkpoint=None, metrics={'all_reduce_sum': 16.0}, validation=False) from rank 0
(RayTrainWorker pid=4512, ip=10.52.5.19) Reporting training result 1: TrainingReport(checkpoint=None, metrics={'all_reduce_sum': 16.0}, validation=False) from rank 15 [repeated 15x across cluster]

TorchTrainer with TorchTPU tpu_dist on TPU7x (num_workers=8, use_tpu=True, topology="2x2x1", accelerator_type="TPU-V7X", resources_per_worker={"TPU": 1}):

(TrainController pid=1746) Using SlicePlacementGroup utility to reserve 1 slice(s) with topology '2x2x1'...
(TrainController pid=1746) Attempting to start training worker group of size 8 with the following resources: [{'TPU': 1, 'accelerator_type:TPU-V7X': 0.001}] * 8
(RayTrainWorker pid=8822, ip=10.228.2.8) Successfully renamed PrivateUse1 backend to 'tpu'. Device: device(type='tpu')
(RayTrainWorker pid=8822, ip=10.228.2.8) Initializing TPU distributed runtime
(RayTrainWorker pid=8822, ip=10.228.2.8) Reporting training result 1: TrainingReport(checkpoint=None, metrics={'all_reduce_sum': 8.0}, validation=False) from rank 4
(RayTrainWorker pid=8821, ip=10.228.2.8) Reporting training result 1: TrainingReport(checkpoint=None, metrics={'all_reduce_sum': 8.0}, validation=False) from rank 6 [repeated 7x across cluster]

@ryanaoleary
ryanaoleary force-pushed the docs-tpu-torchtpu-mpmd branch from 5ea288b to 444f0bc Compare October 15, 2026 09:46
Comment thread doc/source/kuberay/user-guides/tpu.md Outdated
- [TPUs in GKE](https://cloud.google.com/kubernetes-engine/docs/how-to/tpus)
- [TPU regions and zones](https://cloud.google.com/tpu/docs/regions-zones)
- [Cloud TPU system architecture](https://cloud.google.com/tpu/docs/system-architecture-tpu-vm)
- [Train a model on multi-host TPUs with Ray Train and TorchTPU](https://docs.cloud.google.com/kubernetes-engine/docs/tutorials/train-models-tpu-ray-torchtpu)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these guides are not public yet but will be before this is merged

@ryanaoleary
ryanaoleary force-pushed the docs-tpu-torchtpu-mpmd branch from 444f0bc to b78d4b5 Compare October 16, 2026 00:26
@ryanaoleary
ryanaoleary marked this pull request as ready for review October 16, 2026 00:26
@ryanaoleary
ryanaoleary requested review from a team as code owners October 16, 2026 00:26
@ryanaoleary

Copy link
Copy Markdown
Contributor Author

cc: @dstrodtman TPU docs update to cover the support added in the last few releases ahead of PyTorch conference. @liulehui PTAL at the relevant Train docs changes if you have time

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the documentation and code examples for running Ray and KubeRay on Google Cloud TPUs, specifically introducing support and configurations for TPU v6e and TPU7x. It covers SPMD/MPMD workloads, GKE node pool options, the SlicePlacementGroup scheduling utility, reinforcement learning patterns, and new TPU system metrics. The review feedback identifies several critical issues in the examples: the use of non-existent Ray versions (such as 2.59.0 and 2.58.0) which will cause deployment failures, and references to a non-existent model (Qwen/Qwen3-8B) which should be updated to a valid model like Qwen/Qwen2.5-7B-Instruct to ensure the examples are functional.

Comment thread doc/source/kuberay/user-guides/tpu.md Resolved
Comment thread doc/source/kuberay/user-guides/tpu.md Resolved
Comment thread doc/source/kuberay/user-guides/tpu.md Resolved
Comment thread doc/source/serve/llm/user-guides/tpu.md Resolved
@ray-gardener ray-gardener Bot added docs An issue or change related to documentation core Issues that should be addressed in Ray Core community-contribution Contributed by the community labels Oct 16, 2026
@ryanaoleary
ryanaoleary force-pushed the docs-tpu-torchtpu-mpmd branch from e065807 to f1dba2e Compare October 17, 2026 01:23

@liulehui liulehui left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm for Ray Train

Comment thread doc/source/kuberay/user-guides/tpu.md Resolved
Comment thread doc/source/kuberay/user-guides/tpu.md Resolved
Comment thread doc/source/kuberay/user-guides/tpu.md Resolved
Comment thread doc/source/kuberay/user-guides/tpu.md Resolved
Comment thread doc/source/kuberay/user-guides/tpu.md Resolved
Comment thread doc/source/kuberay/user-guides/tpu.md Outdated
```


## Multi-Host TPU autoscaling

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we generalize this section to talk about TPU autoscaling in general and have a subsection on how multi-host autoscaling works?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added a section below detailing autoscaling

Comment thread doc/source/kuberay/user-guides/tpu.md Resolved
@ryanaoleary

ryanaoleary commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor Author

Fixed the outstanding comments and notes from offline discussion, should be ready to merge once CI passes cc: @andrewsykim @dstrodtman

@andrewsykim andrewsykim added the go add ONLY when ready to merge, run all tests label Oct 20, 2026
@andrewsykim
andrewsykim enabled auto-merge (squash) October 20, 2026 13:38
@andrewsykim
andrewsykim merged commit fd3e914 into ray-project:master Oct 20, 2026
8 checks passed
dstrodtman added a commit that referenced this pull request Oct 20, 2026
## Description

A style and grammar pass on the prose that #66991 added to the TPU docs,
against [Ray's writing-style
guide](https://docs.ray.io/en/master/ray-contribute/writing-style.html).
#66991 merged before the docs team could review it, so these edits land
as a follow-up instead of review suggestions. The edits are scoped to
the lines #66991 added. Other text on these pages is unchanged.

The changes fall into these categories:

- Long multi-clause sentences split into shorter ones.
- Acronyms defined on first use, such as MPMD on the scheduling page.
GKE is no longer defined twice on the KubeRay TPU page.
- Lead-ins fixed so that each colon introduces the list, tab set, or
code block that follows it, and a missing lead-in added before the
TorchTPU training example.
- Second person and present tense in place of a few passive or
past-tense constructions.

No technical claim, value, flag, code block, label, or link target
changes.

### How meaning was checked

Every changed sentence was compared with its original for semantic
drift. The check verified each claim against the Ray source and the doc
examples at this commit. It found two edits that had changed a claim,
and both are fixed in this PR:

- On the scheduling page, splitting a sentence had separated "On TPU7x"
from the `RAY_TPU_RESOURCE_PER_CHIP=2` instruction. The instruction now
says "on TPU7x" explicitly.
- On the KubeRay TPU page, moving "For larger workloads" to the start of
a sentence made multi-host scale-down sound conditional. The original
scope is restored.

Two edits add or reword descriptions of example code. Both were checked
against the code:

- The new TorchTPU lead-in says the example "runs one training step with
TorchTPU on 16 per-device workers". The example makes a single
`optimizer.step()` call with `num_workers=16` and
`resources_per_worker={"TPU": 1}`.
- On the Serve LLM TPU page, "This example serves
`google/gemma-4-31B-it`" now names the vLLM-TPU example. That tab is the
only one that uses that model.

## Questions for maintainers

These are pre-existing issues the check surfaced. This PR doesn't change
any of them:

1. **`system-metrics.md`:** The sentence "Exported on Google Cloud TPU
nodes when the GKE TPU device plugin metric server is active" appears
only on the `ray_tpu_tensorcore_utilization` row. In
`reporter_agent.py`, all five `ray_tpu_*` gauges come from the same
device-plugin scrape, and none are emitted when `TPU_DEVICE_PLUGIN_ADDR`
is unset. Should the condition move to a lead-in that covers all five
rows? Separately, a source comment says some TPU types don't report
runtime metrics. On those types, `duty_cycle`, `memory_used`, and
`memory_total` read 0. Is that worth documenting?
1. **`serve/llm/user-guides/tpu.md`:** The instruction "Set
`model_source` to a local or mounted model path, or another path that
all TPU hosts can read" sits between the descriptions of the two
examples. The vLLM-TorchTPU example uses the Hugging Face ID
`Qwen/Qwen3-8B`. Does the shared-path requirement apply only to
vLLM-TPU, or to both engines?

## Additional information

This PR was prepared with AI assistance (Claude Code) and reviewed by a
human, who stands behind every change.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Signed-off-by: Douglas Strodtman <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
dstrodtman added a commit that referenced this pull request Oct 21, 2026
## Why are these changes needed?

A rolling batch of small, independent docs fixes. Ray's `AGENTS.md`
permits mechanical cleanups when they're bundled rather than opened one
per PR, so they collect here. Each fix is its own commit, so a reviewer
can drop any one without disturbing the rest. This stays a draft while
it collects fixes.

### Fixes

- **Show the never-run TorchTPU example as a plain code block**
(`train/user-guides/using-accelerators.md`). #66991 added the TorchTPU
example as a `testcode` block with `:skipif: True`. Since #66974,
`writing-code-snippets.md` says not to do that, because the block never
runs but reads as tested code. It's now a plain `python` block, like the
JAX TPU example above it. It was the last `:skipif: True` block under
`doc/source/`.
- **Fix the broken PyTorch Neuron setup link**
(`serve/tutorials/aws-neuron-core-inference-stable-diffusion.md`). AWS
moved the Neuron setup page, so `frameworks/torch/torch-setup.html`
returns 404 and the scheduled docs link check flags it. The link now
points at `setup/torch-neuronx.html`, which the sibling
`aws-neuron-core-inference.md` tutorial already uses.
- **Link the GIL to the Python glossary** (`core/actors/async-api.md`).
The Python wiki dropped its `/moin/` paths, so
`wiki.python.org/moin/GlobalInterpreterLock` returns 404. The link now
goes to the glossary entry in the official Python docs,
`docs.python.org/3/glossary.html#term-global-interpreter-lock`.

## Related issue number

None.

## Duplicate check

Not a duplicate. `gh pr list --repo ray-project/ray --state open
--search "using-accelerators skipif"` returns nothing, and #67194, which
restyled the same TPU pages, left this block as it was.

## Testing

- Both new link targets return 200, and the glossary page contains the
`term-global-interpreter-lock` anchor. The two old URLs return 404.
- `python doc/test_prose_doctest_targets.py` passes: "74 listed pages;
every runnable page is accounted for." The page still has other runnable
blocks, so it stays in `doctest[train-gpu]`.
- `git grep -n skipif -- doc/source` now finds only the guide's
instruction not to use it.
- Extracting the page's examples is unaffected for runnable blocks:
pytest-sphinx drops a `:skipif: True` block before it builds an example,
so this block was never collected.
- `pre-commit` passes on the changed file.

AI assistance (Claude Code) was used to find and make these fixes. I
reviewed every changed line.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: Douglas Strodtman <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution Contributed by the community core Issues that should be addressed in Ray Core docs An issue or change related to documentation go add ONLY when ready to merge, run all tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants