Skip to content

feat(policy): bound physical-row dispatch and chunk packed wire broadcasts - #5518

Open
jinglinglingling wants to merge 2 commits into
NVIDIA-NeMo:mainfrom
jinglinglingling:linglinj/pr-a-dispatch-and-broadcast
Open

jinglinglingling wants to merge 2 commits into
NVIDIA-NeMo:mainfrom
jinglinglingling:linglinj/pr-a-dispatch-and-broadcast

Conversation

@jinglinglingling

@jinglinglingling jinglinglingling commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor
  • I, the PR author, have personally reviewed every line of this PR.

What and why

Split out from #4581 per review feedback so the general policy/data-plane memory-bounding changes can be reviewed and verified independently.

  1. Bounded physical-row dispatch (nemo_rl/models/policy/tq_policy.py, nemo_rl/models/policy/__init__.py)
    • Adds optional max_physical_rows_per_dispatch and max_physical_rows_per_logprob_dispatch to PolicyConfig to split large multi-turn/multimodal physical-row batches across multiple train_microbatches_from_meta / logprob worker calls instead of materializing every row's media payloads on every worker simultaneously.
    • Validates the configured row limit against DP and microbatch alignment (_dispatch_row_alignment): requires divisibility by dp_world when sequence packing or dynamic batching is enabled, and by dp_world * micro_batch_size (or dp_world * logprob_batch_size for logprobs) under static batching, raising a clear ValueError otherwise instead of silently producing uneven or invalid shards.
  2. Bounded-chunk packed wire tensor broadcast (nemo_rl/data_plane/worker_mixin.py)
    • Broadcasts packed wire tensors from replica leaders in bounded byte chunks instead of allocating one monolithic contiguous copy of the entire packed payload on all ranks at once.
  3. Unit tests (tests/unit/models/policy/test_split_api_wrappers.py, tests/unit/data_plane/test_leader_broadcast.py)
    • Exercises the real shard_meta_for_dp for static batching, sequence packing, and logprob dispatch, plus explicit misalignment rejection tests (e.g., DP=8, 40 rows, limit=30 and static DP=4, mbs=2, limit=12), and verifies chunked wire broadcast behavior.

Issues

Split from #4581.

Convergence / perf / functionality proof

  • Verified in rl.nightly container:
    • pytest tests/unit/models/policy/test_split_api_wrappers.py tests/unit/data_plane/test_leader_broadcast.py: 43 passed, 8 skipped (2-GPU NCCL tests on single-GPU node).
    • ruff check and ruff format --check pass on all modified files.
  • When unset (default None), dispatch behavior is unchanged.

Needs upstream changes

None.

@copy-pr-bot

copy-pr-bot Bot commented Dec 2, 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 the CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) label Dec 2, 2026
@svcnvidia-nemo-ci svcnvidia-nemo-ci added complexity:medium Moderate change. Set by Autobot PR classify (skills/pr-classify) convergence-risk:low Unlikely to change training results. Set by Autobot PR classify (skills/pr-classify) proof:functionality Needs proof that it works. Set by Autobot PR classify (skills/pr-classify) proof:perf Needs performance proof. Set by Autobot PR classify (skills/pr-classify) labels Dec 2, 2026
@jinglinglingling
jinglinglingling force-pushed the linglinj/pr-a-dispatch-and-broadcast branch from 8a47876 to eb51595 Compare December 3, 2026 01:11
Partition SC train and logprob metadata before sharding, respecting DP and static microbatch alignment. Accumulate the partitions into the caller's existing train step and wait for each fanout before materializing more rows.

Signed-off-by: Linglin Jing <[email protected]>
Stage CPU packed data through a reusable collective-device buffer, and rebuild CUDA payloads on each follower's own device. Exercise chunk boundaries on the int16 byte wire for Gloo and NCCL.

Signed-off-by: Linglin Jing <[email protected]>
@jinglinglingling
jinglinglingling force-pushed the linglinj/pr-a-dispatch-and-broadcast branch from eb51595 to a649c98 Compare December 4, 2026 01:43
@jinglinglingling

Copy link
Copy Markdown
Contributor Author

/ok to test a649c98

This branch has not been deployed

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

Labels

CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) complexity:medium Moderate change. Set by Autobot PR classify (skills/pr-classify) convergence-risk:low Unlikely to change training results. Set by Autobot PR classify (skills/pr-classify) proof:functionality Needs proof that it works. Set by Autobot PR classify (skills/pr-classify) proof:perf Needs performance proof. Set by Autobot PR classify (skills/pr-classify)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants