Skip to content

feat: Raiden weight sync for GRPO RL training (VllmSamplerAdapter, RaidenSynchronizer, WeightSyncCoordinator) - #1960

Closed
khatwanimohit wants to merge 1 commit into
mainfrom
mohit/raiden-maxtext-rlvllm
Closed

feat: Raiden weight sync for GRPO RL training (VllmSamplerAdapter, RaidenSynchronizer, WeightSyncCoordinator)#1960
khatwanimohit wants to merge 1 commit into
mainfrom
mohit/raiden-maxtext-rlvllm

Conversation

@khatwanimohit

Copy link
Copy Markdown
Collaborator

Summary

Adds Raiden weight-sync support to the GRPO RL example under tunix/experimental/examples/math_gsm8k_dist/ — a VllmSamplerAdapter/RaidenSynchronizer/WeightSyncCoordinator protocol stack so a trainer and a separate rollout/sampler process can exchange policy weights over Raiden (a native TPU-to-TPU weight transfer library) mid-GRPO-run, plus k8s_launcher.sh for running it on GKE.

Companion PRs (same feature, other two repos):

  • maxtext: MaxTextTrainingEngine + Raiden weight-sync hooks (link filled in below)
  • tpu-inference: RLVllmSampler + in-process Raiden binding (link filled in below)

Test plan

  • Unit tests: pytest tests/experimental/rollout/vllm_sampler_adapter_test.py tests/experimental/orchestrator/weight_sync_coordinator_test.py (79 passed, 1 pre-existing unrelated failure)
  • Live 2-slice v5p-8 GKE end-to-end run: MaxTextTrainingEngine trainer + tpu-inference RLVllmSampler rollout, launched via k8s_launcher.sh, 2 GRPO steps completed with real Raiden weight-sync rounds, checksum-verified between trainer (source) and rollout (destination)

🤖 Generated with Claude Code

…idenSynchronizer, WeightSyncCoordinator)

Adds a full weight-sync protocol stack so a trainer and a separate
rollout/sampler process can exchange policy weights over Raiden (a native
TPU-to-TPU weight transfer library) mid-GRPO-run, plus a distributed
orchestrator/trainer/rollout example wiring it end to end and a
k8s_launcher.sh for running it on GKE.

Key pieces:
- tunix/experimental/rollout/vllm_sampler_adapter.py (new): VllmSamplerAdapter,
  the WeightSyncDestination protocol implementer wrapping tpu-inference's
  RLVllmSampler -- bind_weight_sync/get_weight_sync_metadata/pre_weight_sync/
  weight_sync/post_weight_sync/abort_weight_sync, with a WorkerRoundTracker
  for idempotent phase admission across retried RPCs.
- tunix/experimental/worker/raiden_synchronizer.py: RaidenSynchronizer, the
  shared (trainer- and rollout-side) binding of one process's weights to the
  Raiden transport -- flattens an nnx.State to (names, arrays), filters to
  what the native layer can actually bind (RNG-key and non-TPU-resident
  leaves are undefined behavior to bind, observed as SIGSEGV/RuntimeError),
  and exposes d2h/h2d/checksums/metrics.
- tunix/experimental/orchestrator/weight_sync_coordinator.py,
  weight_sync.py, raiden_handler.py: the round protocol (bind -> manifest
  preflight -> quiesce/pre -> transfer -> post/commit, with rollback on any
  phase failure) and the transport-neutral WorkUnitId/TensorMetadata/
  WorkUnitMetadata types RaidenHandler validates registrations against.
- tunix/experimental/examples/math_gsm8k_dist/: a 3-process (orchestrator +
  trainer + rollout) distributed GRPO example over GSM8K, with
  run_trainer_node.py supporting both Tunix's own PeftTrainer and (via
  --trainer_backend=maxtext) MaxText's MaxTextTrainingEngine, and
  run_rollout_node.py loading either tpu-inference's own JAX model
  reimplementation or (via --maxtext_model_name) MaxText's native model
  through maxtext_vllm_adapter, so trainer and rollout can share one param
  tree for Raiden's exact name-matching sync.
- k8s_launcher.sh: deploys the three processes as GKE JobSets, each pulling
  its own repo's feature branch and installing it at pod startup.
- Dockerfile.maxtext, requirements/maxtext_requirements.txt,
  scripts/install_tunix_vllm_requirement.sh, pyproject.toml: build/install
  plumbing for the MaxText + Raiden + tpu-inference dependency stack.

Verified live end-to-end: a 2-step GRPO run on a real 2-slice v5p-8 GKE
cluster (MaxTextTrainingEngine trainer + tpu-inference RLVllmSampler
rollout, via maxtext_vllm_adapter's native MaxText model) completed both
steps with real Raiden weight-sync rounds, checksum-verified between source
(trainer) and destination (rollout).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@google-cla

google-cla Bot commented Aug 22, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants