Repository navigation
fix(gym): hold the tokenizer in NemoGym instead of passing it per rollout - #3668
Conversation
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
76ee498 to
e8499e9
Compare
saumishr
left a comment
There was a problem hiding this comment.
Two findings, both low severity: the new _tokenizer attribute is declared in _spinup() rather than in __init__ (a latent order dependency, and not what the PR description says the code does), and the new distillation assertion does not check which object gets installed.
|
/ok to test 4b8b485 |
b1cd26c to
1c6f073
Compare
|
Force-pushed 1c6f073 — two changes, plus a history rewrite to keep internal identifiers out of the record. Scrubbed the internal references. The Fixed the The earlier |
|
/ok to test 1c6f073 |
1c6f073 to
e483970
Compare
|
Rebased onto current main ( One conflict, in The patch is otherwise unchanged: same 11 files and same +106/-23 as before the rebase, with only hunk offsets moving. I re-ran the audit that the last round's CI failure came from, against the new base: #3590 adds no new
|
|
/ok to test e483970 |
…lout run_rollouts took the tokenizer as an argument and the rollout pump calls it once per prompt, so Ray deserialized a 7.45 MB tokenizer on the actor's task-execution thread for every prompt. That thread holds the GIL, so it blocked the actor's event loop and no rollout could issue its first HTTP request until its own copy finished loading. Measured: 286 ms to serialize, 1052 ms to deserialize. A SingleController recipe admitting ~1000 prompts per step spends ~18 minutes deserializing one admission burst. Runs on that shape completed zero rollouts in 30 minutes, with no connection error of any kind in a Gym build that logs them. Reproduced on one CPU node with 1024 concurrent calls against one actor: 153 of 1024 prompts finished in 300 s passing the tokenizer per call, versus all 1024 in 16 s installing it once. Passing an ObjectRef instead does not help; Ray caches the object buffer and not the deserialized value, so the actor still pays per task. Install it through the spinup paths so no call site can forget: the shared spinup_nemo_gym_actor helper takes it as a keyword argument, and distillation, which builds its actor inline, sets it alongside its own _spinup call. On the SingleController path it threads through _spinup_gym, since the kwargs that used to sit at the partial now live inside that function. The nemo_gym test fixture is the third such site and installs it the same way, so every path that hands out an actor hands out one that can actually run rollouts. The attribute is declared in __init__, not at the tail of _spinup where the value is first needed. __init__ already declares every other _spinup-populated field -- rh, rch, head_server_config, node_ip, head_server_port -- because Ray recreates a restarted actor through __init__ only and this actor runs with max_restarts=-1. Declaring it in _spinup would also let a re-run of _spinup wipe an installed tokenizer and then report "set_tokenizer must be called before run_rollouts", an error naming a call that had in fact been made. run_rollouts fails loudly rather than silently if it is somehow reached without one; postprocessing with no tokenizer is worse than a named error. Test fakes that stood in for the actor method lose the argument with it. The SingleController setup test asserts the tokenizer reaches spinup, which is the property that keeps it off the per-call path. The guard test constructs through __init__ rather than object.__new__, so the None it checks comes from the declaration itself rather than from an assignment by hand. The distillation test asserts that the spinup wait still comes first and that the install follows it with the right tokenizer: that call site is the only guard on its path, and checking the call count alone would pass just as well if the two swapped places or if a processor were forwarded instead. Signed-off-by: Saurabh Mishra <[email protected]>
e483970 to
aca1415
Compare
|
/ok to test aca1415 |
NemoGym.__init__ is also constructed without the nemo_gym extra -- main's test_run_rollouts_requires_an_installed_tokenizer (added in #3668) does exactly that -- so the unconditional 'import nemo_gym.telemetry' added for early span-group registration raised ModuleNotFoundError in the no-extra unit shard. Guard it: the early import only avoids a cosmetic lens warning (_spinup re-imports via nemo_gym.cli and lens re-resolves on registration), while a genuine missing dependency inside nemo_gym.telemetry still propagates. Signed-off-by: Raj Singh <[email protected]>
NemoGym.__init__ is also constructed without the nemo_gym extra -- main's test_run_rollouts_requires_an_installed_tokenizer (added in #3668) does exactly that -- so the unconditional 'import nemo_gym.telemetry' added for early span-group registration raised ModuleNotFoundError in the no-extra unit shard. Guard it: the early import only avoids a cosmetic lens warning (_spinup re-imports via nemo_gym.cli and lens re-resolves on registration), while a genuine missing dependency inside nemo_gym.telemetry still propagates. Signed-off-by: Raj Singh <[email protected]>
NemoGym.__init__ is also constructed without the nemo_gym extra -- main's test_run_rollouts_requires_an_installed_tokenizer (added in #3668) does exactly that -- so the unconditional 'import nemo_gym.telemetry' added for early span-group registration raised ModuleNotFoundError in the no-extra unit shard. Guard it: the early import only avoids a cosmetic lens warning (_spinup re-imports via nemo_gym.cli and lens re-resolves on registration), while a genuine missing dependency inside nemo_gym.telemetry still propagates. Signed-off-by: Raj Singh <[email protected]>
Overview
run_rollouts took the tokenizer as an argument and the rollout pump calls it once per prompt, so Ray deserialized a 7.45 MB tokenizer on the actor's task-execution thread for every prompt. That thread holds the GIL, so it blocked the actor's event loop and no rollout could issue its first HTTP request until its own copy finished loading.
Measured: 286 ms to serialize, 1052 ms to deserialize. A SingleController recipe admitting ~1000 prompts per step spends ~18 minutes deserializing one admission burst.
Reproduced on one CPU node with 1024 concurrent calls against one actor: 153 of 1024 prompts finished in 300 s passing the tokenizer per call, versus all 1024 in 16 s installing it once. Passing an ObjectRef instead does not help; Ray caches the object buffer and not the deserialized value, so the actor still pays per task.
Install it through the spinup paths so no call site can forget: the shared spinup_nemo_gym_actor helper takes it as a keyword argument, and distillation, which builds its actor inline, sets it alongside its own _spinup call. On the SingleController path it threads through _spinup_gym, since the kwargs that used to sit at the partial now live inside that function.
run_rollouts fails loudly rather than silently if it is somehow reached without one -- postprocessing with no tokenizer is worse than a named error, and the attribute is initialized in init so the check reads as state rather than as an absent attribute.
Test fakes that stood in for the actor method lose the argument with it, and the SingleController setup test now asserts the tokenizer reaches spinup, which is the property that keeps it off the per-call path.
What does this PR do ?
Add a one line overview of what this PR aims to accomplish.
Issues
List issues that this PR closes (syntax):
Usage
# Add a code snippet demonstrating how to use thisBefore your PR is "Ready for review"
Pre checks:
Additional Information