Repository navigation
feat(checkpoint): trace batch age - #5049
Open
macandro96 wants to merge 2 commits into
Open
macandro96 wants to merge 2 commits into
macandro96 wants to merge 2 commits into
Conversation
Batch age is the token-weighted number of policy updates between generating a token and training on it. With token capture and the rollout trace on: - the reassembler returns each finalized group's tokens by the weight version each trained call began on; - the controller writes them in a group_published event, and step_trained also records the policy version the step updated. batch_age_by_step in rollout_checkpointing/trace.py computes each step's batch age, and `python -m nemo_rl.algorithms.rollout_checkpointing.trace <file>` prints it. A call that runs across a refit counts under the version it began on, so it counts as slightly older than it is. Source: +80 / -1. Tests: +67 (2 new tests, and the 20-turn capture pipeline test checks the token counts). Docs: +12 / -1. Unit: 2111 passed (default lane), 121 passed (Gym lane). ruff and pyrefly clean. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Anish Mahishi <amahishi@nvidia.com>
Token capture stamps each model call with the weight version it began on, but vLLM keeps running calls across a refit, so a call's later tokens come from the new weights. Batch age counted them under the call's start version. With the rollout trace and token capture on: - each refit, while generation is paused, writes a refit_cut event: for every running captured call, how many tokens it has generated on the weights being replaced. The vLLM worker links each engine request to its captured call through a context variable set when capture begins the call, and reads the token count from vLLM's output-processor request state, which has no public API; an engine without that state, or another backend, reports nothing; - the reassembler returns each trained call's ID, start version and tokens, and group_published sums them by version but lists on their own the calls a refit paused; - tokens_by_version splits those calls at their refits, and batch_age_by_step uses the split. Nothing Gym stores or a checkpoint saves changes. Source: +196 / -41. Tests: +280 / -56 (vLLM wrapper tests and refit-split tests). Docs: +10 / -5. Unit: 2116 passed (default lane), 121 passed (Gym lane); the vLLM wrapper tests pass in vLLM 0.29's venv. ruff and pyrefly clean. On a GPU Gym run, a call a refit paused before its first token was counted under the new weights. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Anish Mahishi <amahishi@nvidia.com>
macandro96
force-pushed
the
amahishi/rollout-trace-batch-age
branch
from
November 6, 2026 20:20
c2bf309 to
09627ac
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Adds batch age to the rollout trace: the token-weighted number of policy updates between generating a token and training on it, per training step.
Stacked on #5048 (the rollout event log).
How it works
group_publishedevent that sums tokens by version.step_trainedalso records the policy version the step updated.refit_cutevent.group_publishedlists those calls individually so the analysis can split them; all other calls arrive summed by version.batch_age_by_stepinrollout_checkpointing/trace.pycomputes each step's batch age;python -m nemo_rl.algorithms.rollout_checkpointing.trace <log_dir>/rollout_trace.jsonlprints it.The two commits separate the per-version count (exact except for calls that span a refit) from the exact refit split.
Notes for review
external_req_id,detokenizer.num_output_tokens(), as in vLLM 0.29). An engine without that state reports nothing, and those calls count under the version they began on. Other backends inherit a default that reports nothing.vllm_worker_async.py, the generation interface andvllm_generation.py, which feat(checkpoint): recover active vLLM generation prefixes #4506 also changes; whichever lands second needs a small rebase there.Testing
{v1: 60, v0: 30}), where counting by start version gives{v0: 90}.🤖 Generated with Claude Code