Repository navigation
fix(rollout): avoid retaining full routed-expert buffers in message slices - #4915
Conversation
|
/ok to test fa52126 |
fa52126 to
65cd797
Compare
There was a problem hiding this comment.
Review: LGTM on this PR's change, plus a suggested follow-up for the same bug elsewhere.
This PR: cloning the routed-expert slices in nemo_gym.py is correct. Each message now owns exactly its token span, and the new storage-size and pickle round-trip assertions cover it.
Same bug, other places (suggestion, low severity): the same view-retains-full-buffer pattern exists where rollout message logs are built. These sites are outside this PR's diff:
| File | Site |
|---|---|
nemo_rl/experience/rollouts.py |
_attach_routed_experts_to_message_log_prefix |
nemo_rl/experience/rollouts.py |
generate_responses and generate_responses_async (assistant slice) |
nemo_rl/experience/rollout_manager.py |
AsyncRolloutImpl._generate_response (assistant slice) |
Proposed change: one shared helper, slice_routed_experts(routed_experts, start, end) in nemo_rl/utils/routed_experts_codec.py (torch-only, already imported by nemo_gym.py), used at all 7 sites including the 2 in nemo_gym.py. It is a single .clone() of the slice, with one docstring explaining why.
Where it is: branch fix/clone-routed-experts-slices, commit 4b8bbf9, stacked on this PR's head (65cd797). Diff: 65cd797...4b8bbf9
Please cherry-pick it into this PR or merge it after this PR; I have not touched this PR's branch.
Signed-off-by: Renat Zayashnikov <[email protected]>
…rts helper
Slices of the per-sample routed_experts tensor were views sharing the full
buffer's storage, so serializing a message could carry the whole sample.
Add slice_routed_experts (clone of the slice) to routed_experts_codec and use
it at every message-slice site: nemo_gym postprocess, rollouts prefix attach,
generate_responses{,_async}, and the async rollout manager. Assert storage
ownership in the rollout manager test.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Signed-off-by: Zhiyu Li <[email protected]>
Signed-off-by: Renat Zayashnikov <[email protected]>
65cd797 to
2eed022
Compare
ZhiyuLi-Nvidia
left a comment
There was a problem hiding this comment.
Thank you @u-brixton for the fix, LGTM!
|
/ok to test 2eed022 |
Signed-off-by: Renat Zayashnikov <[email protected]>
Head branch was pushed to by a user without write access
|
/ok to test d619e95 |
Resolves the conflict in nemo_rl/utils/routed_experts_codec.py: this branch added routed_experts_envelope_dtype and NVIDIA-NeMo#4915 added slice_routed_experts at the same spot. Both are kept. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: jthomson04 <[email protected]>
Routed-expert slices stored in message logs can retain the full turn or padded generation batch, causing oversized backing storage during serialization.
Use a shared
slice_routed_expertshelper so each message owns only its token span in Gym postprocessing, synchronous/asynchronous generation, and the async rollout manager. Release the full decoded Gym turn before processing the next one.Validation at
2eed022f:The tests used the prepared runtime without model inference or training. No full training or full-suite run was performed for this PR.
Follow-up validation at
d619e951: scalar slice bounds are explicitly converted to Python integers. Pyrefly checks on the affected files, seven CPU codec tests, and scoped Ruff lint/formatting passed.