Skip to content

[Core][TPU] Add per_slice_pgs paramater to SlicePlacementGroup - #64072

Merged
ryanaoleary merged 8 commits into
masterfrom
tpu-per-slice-pgs
Jul 23, 2026
Merged

[Core][TPU] Add per_slice_pgs paramater to SlicePlacementGroup#64072
ryanaoleary merged 8 commits into
masterfrom
tpu-per-slice-pgs

Conversation

@ryanaoleary

Copy link
Copy Markdown
Contributor

Description

Currently SlicePlacementGroup accepts a num_slices parameter - atomically reserving that many slices- and returns a single PG handle spanning all the Ray nodes across those num_slices slices. This works well for multi-slice training or inference where the MEGASCALE backend it utilized to perform collectives across all the TPU hosts.

However, for other use-cases like RL or disaggregated serving it'd be useful for users to be able to reserve multiple TPU slices, but utilize the individual slices at their discretion for different workloads. This PR introduced a per_slice_pgs that when set exposes a per_slice_placement_groups property. per_slice_placement_groups is a list of placement group handles where each PG reserves 1 TPU slice.

Related issues

#64071

Additional information

Optional: Add implementation details, API changes, usage examples, screenshots, etc.

@ryanaoleary

Copy link
Copy Markdown
Contributor Author

cc: @spencer-p

Comment thread python/ray/util/tpu.py Outdated
Comment thread python/ray/util/tpu.py Outdated

@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 introduces the per_slice_pgs option to slice_placement_group, allowing users to create individual placement groups per TPU slice instead of a single placement group across all slices. It also updates the cleanup logic and adds unit tests for this new feature. The review comments point out two critical issues: first, a potential resource leak if an exception occurs during slice reservation because partially created placement groups are not yet tracked in self._managed_pgs; second, a potential IndexError when accessing placement_group after shutdown() has cleared self._managed_pgs.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread python/ray/util/tpu.py Outdated
Comment thread python/ray/util/tpu.py Outdated
@ray-gardener ray-gardener Bot added core Issues that should be addressed in Ray Core community-contribution Contributed by the community labels Jun 13, 2026
@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had
any activity for 14 days. It will be closed in another 14 days if no further activity occurs.
Thank you for your contributions.

You can always ask for help on our discussion forum or Ray's public slack channel.

If you'd like to keep this open, just leave any comment, and the stale label will be removed.

@github-actions github-actions Bot added the stale The issue is stale. It will be closed within 7 days unless there are further conversation label Jun 27, 2026
@ryanaoleary

Copy link
Copy Markdown
Contributor Author

not stale, just needs review

@github-actions github-actions Bot added unstale A PR that has been marked unstale. It will not get marked stale again if this label is on it. and removed stale The issue is stale. It will be closed within 7 days unless there are further conversation labels Jul 10, 2026
Comment thread python/ray/util/tpu.py
Signed-off-by: Ryan O'Leary <ryanaoleary@google.com>

Fix release_head_pgs for per-slice mode

Fix tests, allow dispatch to target specific slices, and free all head pgs

Signed-off-by: Ryan O'Leary <ryanaoleary@google.com>

@andrewsykim andrewsykim left a comment

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.

Very minor nits on naming, feel free to ignore

Comment thread python/ray/util/tpu.py Outdated
Comment thread python/ray/util/tpu.py Outdated
Signed-off-by: Ryan O'Leary <ryanaoleary@google.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit b2fd409. Configure here.

Comment thread python/ray/util/tpu.py
@ryanaoleary

Copy link
Copy Markdown
Contributor Author

cc: @andrewsykim some changes made in 660450d after approval to fix a cursor comment, otherwise I think this is good to merge

Comment thread python/ray/util/tpu.py Outdated
Signed-off-by: Ryan O'Leary <113500783+ryanaoleary@users.noreply.github.com>
@ryanaoleary
ryanaoleary enabled auto-merge (squash) July 23, 2026 03:06
@github-actions github-actions Bot added the go add ONLY when ready to merge, run all tests label Jul 23, 2026
@ryanaoleary
ryanaoleary merged commit 001eee1 into master Jul 23, 2026
7 of 8 checks passed
@ryanaoleary
ryanaoleary deleted the tpu-per-slice-pgs branch July 23, 2026 05:34
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 go add ONLY when ready to merge, run all tests unstale A PR that has been marked unstale. It will not get marked stale again if this label is on it.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants