Skip to content

[Performance] Rollout collection _preprocess_rows_from_config avoid deepcopy - #2816

Merged
bxyu-nvidia merged 6 commits into
mainfrom
bxyu/rollout-collection-copy
Aug 27, 2026
Merged

bxyu-nvidia merged 6 commits into
mainfrom
bxyu/rollout-collection-copy

Conversation

@bxyu-nvidia

Copy link
Copy Markdown
Contributor

What does this PR do?

On 170k input samples, this reduces the processing time from 8min -> 1min

Checklist

  • I have read the contributing guidelines.
  • The change is focused; unrelated "drive-by" edits are tracked as separate issues/PRs.
  • Tests added or updated and pass locally, or N/A for docs-only / non-code changes (so CI unit/server checks pass when applicable).
  • Pre-commit checks pass locally (pre-commit run --all-files) (so CI lint/format/copyright pass).
  • All commits have DCO sign-off (git commit -s) (so the DCO check passes).

Signed-off-by: Brian Yu <bxyu@nvidia.com>
Signed-off-by: Brian Yu <bxyu@nvidia.com>
Signed-off-by: Brian Yu <bxyu@nvidia.com>
@copy-pr-bot

copy-pr-bot Bot commented Aug 27, 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.

Signed-off-by: Brian Yu <bxyu@nvidia.com>
Signed-off-by: Brian Yu <bxyu@nvidia.com>
@bxyu-nvidia

Copy link
Copy Markdown
Contributor Author

/ok to test 5366e98

@bxyu-nvidia
bxyu-nvidia merged commit 19dec43 into main Aug 27, 2026
36 checks passed
@bxyu-nvidia
bxyu-nvidia deleted the bxyu/rollout-collection-copy branch August 27, 2026 04:03
jkyi-nvidia added a commit that referenced this pull request Aug 28, 2026
Measured at full scale on the whole manifest:

              --no-expand      EXPAND=1
  rows          726,121       5,808,968
  size            34 GB         291.5 GB
  wall            682 s          2,087 s

Gym expands num_repeats itself at collection time while honouring the task
index we stamp, and that expansion is what PR #2816 took from 8 min to 1 min,
so pre-expanding buys little and costs 8x the disk.

The reason it matters beyond disk is prefix caching. A task's repeats have
identical prompts. Unexpanded they all land in one shard and repeats 2-8 hit
the vLLM prefix cache; expanded, they are consecutive lines, so round-robin
dealing scatters them across 8 jobs and every repeat is a cold prefill. This
only bites once sharded -- a single unsharded job caches expanded repeats fine.

run_sharded.sh now watches rather than waits: a shard whose job dies with work
outstanding is resubmitted against the same directory, where --resume picks up
what it already collected. MAX_ROUNDS (4) bounds that so a shard failing for a
permanent reason cannot loop. Completeness is judged per task for unexpanded
inputs and per (task, rollout) for expanded ones -- verified both ways: 36
outstanding for an untouched unexpanded shard, 0 once collected, 288 for the
expanded equivalent.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Signed-off-by: Junkeun Yi <jkyi@nvidia.com>
muskank7 pushed a commit to muskank7/Gym that referenced this pull request Sep 30, 2026
…NeMo#3672)

## Expected

With `num_repeats_add_seed=True`, each repeated rollout should receive
its own seed even when the input already includes
`responses_create_params.metadata`. Existing metadata and caller-owned
input should be preserved.

## Actual

The copy optimization in NVIDIA-NeMo#2816 copies the response parameters but shares
their nested metadata. Updating the next repeat’s seed overwrites
earlier repeats: three repeats receive `[2, 2, 2]` instead of `[0, 1,
2]`, and in-memory input is mutated.

## Fix

Copy the metadata dictionary before assigning each rollout’s seed. Keep
shallow copying for the rest of the task.

Validation: The regression fails before the fix and passes after; 240
adjacent tests, full core/sandbox checks (95.16% coverage), and all-file
pre-commit pass. Model rollouts: N/A for this input-materialization
change.

<!-- gym-verified-bug-hunter:rollout-repeated-seed-metadata-aliasing -->

Signed-off-by: yaoyu-33 <54727607+yaoyu-33@users.noreply.github.com>

This branch was previously deployed

1 inactive deployment
public — 5366e989 Deployed Aug 27, 2026 by copy-pr-bot[bot] via release / finalize / notify #2076
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.

1 participant