Repository navigation
[TPU] feat: add TPU distributed/runtime patches and torchrun PJRT env setup - #11
Merged
Merged
Conversation
askhat-g
force-pushed
the
feat/tpu-sft-and-runtime-patches
branch
from
October 8, 2026 20:11
50d94d7 to
a63484a
Compare
askhat-g
force-pushed
the
feat/tpu-sft-and-runtime-patches
branch
from
October 8, 2026 20:43
a63484a to
16dbdcb
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Part 1 of 2 (Platform & Runtime Patches):
verl_hardware_plugin/accelerators/tpu/patches/reduce_avg_allreduce_patch.py):torch.distributed.all_reduce(op=ReduceOp.AVG)intoReduceOp.SUM+tensor.div_(world_size)ontpu_distprocess groups (matching the XPUreduce_avg_allreduce_patchpattern).torch.distributed.all_gather_object(..., group=dp_group)ontpu_distdevice-mesh subgroups through either the default Gloo group (whengroup_size == world_size) or fixed-shapeint32byte tensors viadist.all_gather(avoidingtensor.resize_()crashes on PJRT/XLA), and detaches any TPU metric tensors to CPU.verl.utils.distributed.set_numa_affinitywith a no-op on TPU and routesverl.utils.torch_functional.logprobs_from_logitsto vectorizedlogprobs_from_logits_naivefor TPU tensors.torchrunMulti-Controller PJRT Environment Setup (PlatformTPU):configure_torchrun_tpu_env()inplatform_tpu.py(invoked fromPlatformTPU.__init__) so standalonetorchrun -m verl.trainer.sft_trainerautomatically populatesPJRT_DEVICE,TORCH_TPU_SLICEBUILDER_ADDRESSES,TPU_PROCESS_PORT,TPU_VISIBLE_CHIPS, and topology bounds fromLOCAL_RANK/RANK/WORLD_SIZE.Test Plan
pytest tests/test_plugin_registration.py -v