Repository navigation
Conversation
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
2a5b1cd to
fe34649
Compare
fe34649 to
2bf9f2b
Compare
macandro96
left a comment
There was a problem hiding this comment.
Thanks for this. Retiring each ledger right after the manifest read, and leaving abandoned rows alone while row re-dispatch can still recover them, fits how the recovery ledger mints fresh rollout IDs on retry. The claims in the description about who reads a ledger and when all hold on main, and the Gym-side contract (route, auth, status classes, fence filenames) matches the pinned Gym.
Two inline items: a shutdown() regression that turns four existing default-lane unit tests red, and a missing test for the cancellation path the except BaseException handler exists for.
Generated by Claude Code
a3f3ee0 to
1b10ba4
Compare
|
Auto-sync is disabled for ready for review pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
|
/ok to test 1b10ba4 |
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
The batching and terminal-dispatch cleanup are well separated, but one receipt-delivery ordering issue needs correction.
The earlier shutdown and cancellation items are addressed in the current source: the queue fields are initialized before spinup, and the cancellation regression checks that cancellation propagates and only the unreturned row is retired.
Inspected all six changed files and traced the local receipt, retry, recovery, and shutdown paths. Tests and linters were not executed.
Blocked inspection: the remaining upstream-verification task cannot be completed in this invocation. Both mounted Gym submodule directories are empty; direct reads also confirmed that the endpoint and client implementation files are absent. With read-only tools and no network access, I cannot independently verify Gym's retire endpoint or reserved control-pool implementation. This task remains pending rather than being marked complete.
Note: formal approval is not available for this request, so this review is posted as a comment only.
Review generated by codex. This was a full review. Request a full review with /review reset=true.
|
/ok to test 30cb571 |
With token capture on, the policy model server writes one capture ledger per rollout attempt and never removes it, because Gym cannot tell when NeMo RL has finished with a rollout. A long run therefore fills the capture directory with one ledger per attempt. Each NemoGym actor now queues a rollout for retirement once its manifest has been read, and AsyncNemoGymRolloutImpl queues the rows of a failed, timed-out, or cancelled dispatch that never returned a result, on the actor that ran them. The actor sends the queue to Gym's retire route in batches over the reserved control connection pool. A rollout leaves the queue only once Gym confirms it; transport errors, timeouts, 409, and 5xx responses are retried with exponential backoff. Signed-off-by: Ananth Subramaniam <[email protected]>
The logger nests each run under an exp_NNN directory inside logger.log_dir, so the ledger check now searches LOG_DIR recursively for the gym_token_capture lineage files. Signed-off-by: Ananth Subramaniam <[email protected]>
shutdown() reads the retire queue, but _spinup created it, so shutting down an actor that never spun up raised AttributeError and masked the error that stopped spinup. The queue is now declared in __init__ next to the other defaults an unspun actor needs. Also cover a cancelled dispatch: a staleness abort cancels it with CancelledError, which is not an Exception, and its unreturned rows must still be retired. Signed-off-by: Ananth Subramaniam <[email protected]>
The actor queued a rollout for retirement as soon as it read the manifest, before the controller had received the result. If receiving that result failed with a retryable error, the row was re-dispatched under the same rollout ID, and once the retire flushed Gym discarded the new run's capture, so the row came back masked instead of recovered. AsyncNemoGymRolloutImpl._run_rollouts now retires every row of the prompt group once, after its row re-dispatch loop is over, whether the dispatch succeeded, failed, or was cancelled. From then on nothing reads those manifests: a returned row's receipt carries its manifest, and a retry of the group runs under fresh rollout IDs. This is one Ray call per prompt group instead of one per row. Signed-off-by: Ananth Subramaniam <[email protected]>
30cb571 to
acbf7ef
Compare
|
/ok to test acbf7ef |
What does this PR do ?
Retires each token-capture ledger once NeMo RL has finished with its rollout, so the policy model server's capture directory no longer grows by one ledger file per rollout attempt for the whole run.
Issues
No tracking issue. This is the NeMo RL side of NVIDIA-NeMo/Gym#3938 and NVIDIA-NeMo/Gym#3939, which add the retire and delete operations that NeMo RL now calls.
Why the ledgers need retiring
With
token_capture.enabled=true, Gym's policy model server records a capture ledger for every rollout attempt undertoken_capture.capture_dir, which defaults to<logger.log_dir>/gym_token_captureon shared storage. NeMo RL reads a ledger once, when it fetches the rollout's manifest inNemoGym._postprocess_receipt_mode, and never reads it again: the receipt carries the manifest from then on, and a restore retries every unsealed attempt under a fresh rollout ID. Gym cannot tell when that moment has passed, so before this change nothing removed the ledger and the directory kept one file per attempt for the whole run.Retiring a rollout deletes its ledger and leaves an empty fence file in its place. If a model call for the rollout finishes later, for example from an abandoned agent that is still running, Gym discards its row instead of starting a new ledger.
What changed
mainincludes feat(token-capture): retire and delete external-staging capture ledgers Gym#3938 and feat(token-capture): retire and delete complete-record captures Gym#3939.AsyncNemoGymRolloutImpl._run_rolloutsqueues every row of a prompt group for retirement once its row re-dispatch loop is over, whether the dispatch succeeded, failed, timed out, or was cancelled. Until then a row can be re-sent under the same rollout ID, for example when receiving its result fails with a retryable Ray error, and retiring that ID earlier would make Gym discard the re-sent row's capture. Afterwards nothing reads those manifests again: a returned row's receipt carries its manifest, and a retry of the group runs under fresh rollout IDs. The retire goes to the actor that ran the rows, whose model server holds their ledgers, as one Ray call per prompt group.RayError, so it never delays a cancellation or replaces the exception that ended the dispatch. Rows without a_ng_rollout_id(token capture off) are never sent.NemoGym.retire_rollout_ledgersonly adds IDs to a per-actor queue. A background task sends the queue toPOST /training-token-capture/control/rollouts/retireonce 256 rollouts are queued or after one second, whichever comes first, with up to Gym'sMAX_LEDGER_BATCHIDs per request. Requests go over Gym's reserved control connection pool, so cleanup does not compete with model calls for connections.NemoGym.shutdownlogs how many queued ledgers were never retired and cancels the flush task.tests/functional/grpo_async_gym_single_controller.shwith++token_capture.enabled=truenow fails if the run leaves no retired fences, or leaves at least as many live ledgers as retired ones. Only rollouts in flight at shutdown should keep a live ledger.Not covered here
RolloutRecoveryLedger.prepare_for_restartabandons interrupted attempts from the previous launch. Their ledgers are still on disk when the capture directory is shared, and this change does not retire them.delete.capture_dirmoves to node-local disk. Moving it is a separate change.<rollout_id>.tokens.lockfile per rollout in the lineage directory, whichdeletecannot safely remove. fix(token-capture): use striped lock files that are never deleted Gym#3937 replaces them with a fixed set of shared lock files.local_filemanifest transport. Whichever PR lands second needs to make sure the retire still happens on that path.Before your PR is "Ready for review"
Pre checks:
grpo_async_gym_single_controller.sh ++token_capture.enabled=truepass innvcr.io/nvidian/nemo-rl:nightly. After that run, the lineage directory holds retired fences for every finished rollout and live ledgers only for the one prompt group still in flight at shutdown.