Skip to content

perf(data-plane): cut sync TQ overhead and count the rollout actor metrics - #4580

Merged
yuki-97 merged 4 commits into
r0.8.0from
zhiyul/tq-rollout-timers
Oct 9, 2026
Merged

yuki-97 merged 4 commits into
r0.8.0from
zhiyul/tq-rollout-timers

Conversation

@ZhiyuLi-Nvidia

@ZhiyuLi-Nvidia ZhiyuLi-Nvidia commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

What

The GRPO sync data-plane path (data_plane.enabled=true, mooncake_cpu) was ~4.7 s/step slower than the no-data-plane baseline on the prorlv2 qwen2.5-math-1.5b nightly. The reported data_plane/*/wall_s (~0.5 s) didn't account for it. This PR fixes the two largest causes and closes the metrics gap that hid them.

  1. rollout_to_tq writes only columns someone reads. It stops writing turn_lengths/turn_roles/turn_contents and the non-tensor final_batch pass-through columns (extra_env_info, idx, stop_strings, task_name) to TQ. Mooncake stored each as its own msgpack object per field × row, and nothing on this path reads them back: workers fetch LP_SEED_FIELDS/DP_TRAIN_FIELDS, the driver reads content/input_ids, and validation gets turn_* via driver_carry. kv_first_write drops from ~1.2–1.7 s to ~0.4–0.6 s/step.
  2. Validation fork stall. The val StatefulDataLoader (num_workers: 1) re-forked its worker every pass after the driver had mounted its RDMA-pinned Mooncake segment (~68 GB), and the fork copied the pinned pages (~20 s per validation). The nine GRPO-sync mooncake_cpu recipes now set data.num_workers: 0, so data loads in-process and nothing forks from the pinned driver. This is config-only; there is no data-loader code change.
  3. Metrics include the rollout actor. SyncRolloutActor.get_data_plane_snapshot plus TQPolicy.add_data_plane_snapshot_source. The cluster view now counts kv_first_write, which was the step's largest write and was previously invisible (n_processes 9 → 10, put volume ~3 → ~18 MB/step).
  4. data_plane/README.md and the llm_message_utils / validate_sync docs updated to match.

(Per-phase timers were used during the investigation to locate (1) and (2); they are not part of this PR.)

Results

prorlv2-qwen2.5-math-1.5b-instruct-1n8g-fsdp2tp1.v2-tq_mooncake, 450 steps, CI container rl.71876279, steps 2–450:

run mean step (s) median step (s)
no data plane (...fsdp2tp1.v2) 16.76 14.95
data plane, before 21.48 17.34
data plane, this PR (on 878d98f2b, with timers) 17.91 16.10
data plane, this PR (final 4fe00c91d on r0.8.0) 17.76 16.31
  • Validation: ~23 s → ~1.7 s (median of 45 passes, final code).
  • Nightly metric checks pass on the final code: token_mult_prob_error median 1.005 (1.004 at step 450); hash mismatches 0.
  • Remaining ~1.1 s/step: the tensor put (~0.3 s), worker TQ round-trips for logprobs (~0.3 s), and Ray dispatch to the rollout actor (~0.2 s).

Not in this PR (follow-ups)

  • The driver still mounts a 64 GiB Mooncake segment it doesn't need to host. tq_mooncake_checkpoint.py already zeroes it, but only in checkpoint mode. Zeroing it unconditionally would make every driver fork cheap, which would also fix the train-loader epoch rollover.
  • A general fix so new mooncake recipes don't need num_workers: 0 (e.g. a forkserver worker context when the backend is mooncake_cpu), which would keep parallel data loading.
  • vlm_grpo-nemotron-omni-…-tq_mooncake now loads images in the driver. That should be small, but it hasn't been measured.
  • The single-controller loop logs data-plane metrics at driver scope only. It could reuse the same fan-out.
  • Unit tests for _record_actor_timing, collect_data_plane_snapshots with extra sources, and the reduced rollout_to_tq write set.

Test plan

  • 450-step nightly recipe (above): checks pass
  • 15–40-step A/B runs for each change (timers, skip columns, validation fork)
  • 20-step check of data.num_workers: 0 on the prorlv2 recipe: validation 6.9 s (first, warm-up) / 1.75 s, data_processing 0.03 s/step
  • ruff check / ruff format --check
  • CI unit tests

🤖 Generated with Claude Code

@copy-pr-bot

copy-pr-bot Bot commented Oct 8, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@github-actions github-actions Bot added Documentation Improvements or additions to documentation CI Relating to CI labels Oct 8, 2026
@ZhiyuLi-Nvidia
ZhiyuLi-Nvidia force-pushed the zhiyul/tq-rollout-timers branch from 35bcb09 to 6ff0f3e Compare October 8, 2026 00:37
@github-actions github-actions Bot removed the CI Relating to CI label Oct 8, 2026

@yuki-97 yuki-97 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.

Merge blockers — please target the r0.8.0 branch instead of main and add the cherry-pick-to-main label, since this is a fix PR for the v0.8 release.

Thanks for the fix: the sync data-plane slowdown is now cheaper (data.num_workers: 0 and fewer TQ columns written) and visible in the metrics, since the rollout actor's kv_first_write is counted in the cluster view.

Scope: grpo_sync.py, sync_rollout_actor.py, tq_policy.py, data_plane/README.md, and the nine *-tq_mooncake recipes.

Checked:

  • Dropped TQ columns — nothing reads them back: workers fetch DP_TRAIN_FIELDS, attach_message_log_view no-ops when the decomposed fields are absent, and validation takes turn_roles / turn_contents from driver_carry.
  • data.num_workers: 0 — it feeds both the train and val StatefulDataLoader, no persistent_workers / prefetch_factor is set that would reject 0, and the nine recipes are every *-tq_mooncake recipe except the single-controller one.
  • Snapshot fan-out — the extra-source refs are submitted before the worker fan-out blocks so the round trips overlap, and a failure is dropped like a worker's rather than failing the step.

Remaining comments are on the debug timers, docs and comments left stale by the dropped columns, how the rollout actor exposes its snapshot method, and whether the single controller mooncake_cpu recipe needs the same num_workers setting.

Comment thread nemo_rl/algorithms/grpo_sync.py Resolved
Comment thread nemo_rl/algorithms/grpo_sync.py Resolved
ZhiyuLi-Nvidia added a commit that referenced this pull request Oct 8, 2026
- Drop the debug timers (rollout_to_tq per-phase actor_timing/ plumbing,
  validate_sync and logprob sub-timers) so timing matches grpo.py and the
  single-controller path; restore the original validation loop.
- SyncRolloutActor.get_data_plane_snapshot: explicit method instead of
  borrowing TQWorkerMixin's.
- Fix docstrings/comments left stale by not writing turn_* to TQ
  (validate_sync, llm_message_utils MESSAGE_LOG_BULK_FIELDS).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Zhiyu Li <[email protected]>
@ZhiyuLi-Nvidia
ZhiyuLi-Nvidia changed the base branch from main to r0.8.0 October 8, 2026 19:17
@ZhiyuLi-Nvidia ZhiyuLi-Nvidia added the cherry-pick-to-main Opt in: cherry-pick this PR's commit from the release branch back into main label Oct 8, 2026
@ZhiyuLi-Nvidia ZhiyuLi-Nvidia changed the title perf(data-plane): cut GRPO sync TQ overhead and count the rollout actor in metrics perf(data-plane): cut sync TQ overhead and count the rollout actor metrics Oct 8, 2026
ZhiyuLi-Nvidia and others added 4 commits October 8, 2026 12:20
…or in metrics

- rollout_to_tq: stop writing columns nothing reads back to TQ (turn_*,
  non-tensor fb pass-through such as extra_env_info/idx/stop_strings/
  task_name). They were msgpack'd per field x row on every step;
  kv_first_write drops from ~1.2s to ~0.4-0.6s/step on prorlv2
  qwen2.5-math-1.5b. Validation still gets turn_* via driver_carry.
- Cluster data-plane metrics now include the rollout actor's client
  (SyncRolloutActor.get_data_plane_snapshot + TQPolicy
  .add_data_plane_snapshot_source), so kv_first_write is counted.
- Validation DataLoader: persistent workers primed in setup() before the
  data plane pins its RDMA segment on the driver; forking afterwards
  copied the pinned pages (~20s per validation).
- Per-phase timers for rollout_to_tq (incl. Ray dispatch/return legs),
  validate_sync, and policy/reference logprobs.
- data_plane/README.md: rollout actor is now in the cluster fan-out;
  validation example reads turn_* from driver_carry.

prorlv2-qwen2.5-math-1.5b-instruct-1n8g-fsdp2tp1.v2-tq_mooncake, 450 steps
(steps 2-450): mean/median step 21.48/17.34s -> 17.91/16.10s
(no data plane: 16.76/14.95s); validation ~23s -> ~1.8s; nightly
metric checks pass.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Zhiyu Li <[email protected]>
Set data.num_workers: 0 in the nine GRPO-sync mooncake_cpu recipes, and
drop the setup-order val-loader priming. mooncake_cpu RDMA-pins a large
segment on the driver, and forking a DataLoader worker after that copies
the pinned pages (~20s per validation, measured on the prorlv2 recipe).
No data-loader code change remains.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Zhiyu Li <[email protected]>
- Drop the debug timers (rollout_to_tq per-phase actor_timing/ plumbing,
  validate_sync and logprob sub-timers) so timing matches grpo.py and the
  single-controller path; restore the original validation loop.
- SyncRolloutActor.get_data_plane_snapshot: explicit method instead of
  borrowing TQWorkerMixin's.
- Fix docstrings/comments left stale by not writing turn_* to TQ
  (validate_sync, llm_message_utils MESSAGE_LOG_BULK_FIELDS).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Zhiyu Li <[email protected]>
@ZhiyuLi-Nvidia
ZhiyuLi-Nvidia force-pushed the zhiyul/tq-rollout-timers branch from 9eda780 to 4fe00c9 Compare October 8, 2026 19:20
@ZhiyuLi-Nvidia

Copy link
Copy Markdown
Contributor Author

@yuki-97 thanks for the review. Everything is addressed:

  • Merge blockers: retargeted to r0.8.0 (rebased onto it, 4 commits / 14 files) and added cherry-pick-to-main.
  • Debug timers: removed, along with the original validation loop restored.
  • Stale docs: validate_sync and llm_message_utils fixed.
  • Snapshot method: get_data_plane_snapshot is now an explicit method.
  • Single-controller recipe: answered in the thread; left out of this fix.

Head is now 4fe00c91d45d22c14c47f5459f311746a2150772.

@ZhiyuLi-Nvidia

Copy link
Copy Markdown
Contributor Author

/ok to test 4fe00c9

@ZhiyuLi-Nvidia ZhiyuLi-Nvidia added the CI:L1 Run doctests, unit tests, and functional tests label Oct 8, 2026
@ZhiyuLi-Nvidia

Copy link
Copy Markdown
Contributor Author

/ok to test 4fe00c9

@yuki-97
yuki-97 enabled auto-merge (squash) October 9, 2026 01:57
@yuki-97
yuki-97 merged commit 13d603f into r0.8.0 Oct 9, 2026
144 of 145 checks passed
@yuki-97
yuki-97 deleted the zhiyul/tq-rollout-timers branch October 9, 2026 03:20
@ZhiyuLi-Nvidia

Copy link
Copy Markdown
Contributor Author

The automatic cherry-pick to main failed on an import conflict in sync_rollout_actor.py. Manual cherry-pick: #4618.

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

Labels

cherry-pick-to-main Opt in: cherry-pick this PR's commit from the release branch back into main CI:L1 Run doctests, unit tests, and functional tests Documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants