Repository navigation
With max_staleness > 0 the trainer already holds rollouts it may train on, but every step still waited for the whole weight sync round: rollout drain, transfer, install and publish. Only staging the trainer's weights needs the trainer to pause. - #3440
Merged
Merged
Conversation
copybara-service
Bot
requested review from
abheesht17,
hgao327,
jiangyangmu,
lc5211,
s-noghabi,
sizhit2,
tianshub and
wang2yn84
as code owners
November 20, 2026 21:49
copybara-service
Bot
force-pushed
the
test_1026179343
branch
2 times, most recently
from
November 21, 2026 21:31
5a639ab to
46641bc
Compare
…ain on, but every step still waited for the whole weight sync round: rollout drain, transfer, install and publish. Only staging the trainer's weights needs the trainer to pause. A sync round now signals once the source has staged its weights. `StandardRLProgram` waits for that signal, then trains the next step while the round finishes in the background. At most one round is in flight, and the next step end waits for it. On-policy runs (`max_staleness == 0`) still wait for the commit. This requires a transport that transfers only the staged copy (`WeightSyncHandler.transfers_from_staged_copy`, true by default). The Raiden handler does so when it skips D2H and no layer is planned as pre-tiled, which is its default. Otherwise the round is refused and the run fails: there is no fallback to holding the trainer. While a round is in flight the trainer is one version ahead of the rollouts. The dispatch window holds back one batch so that every batch is still within `max_staleness` when it is consumed, and the staleness window is judged against the trainer's version. `TrainerWorker` stays READY for the whole round, including after a failed release. Releasing the staging runs on a thread of its own, kept apart from staging and from closing the trainer by a lock: it no longer queues behind the trainer's `fwd_bwd`, which would hold the round open, and it does not run on the worker's event loop. It can therefore run while the trainer trains. It also no longer refreshes the trainer's OpenTelemetry busy anchor: the release can now land while the trainer waits for rollouts, and would erase that idle time. On-policy, the wait from staging to commit is therefore counted as trainer idle time. When the train stage exits for any reason, the in-flight round is cancelled and awaited, as a round was before. Visible changes: queued rollouts are checked against the trainer's version, so a run tuned to its staleness limit can start dropping groups. `StandardRLProgram.policy_version` lags the trainer by one while a round is in flight; `RLStepResult.policy_version` still reports the version the step produced. Routed-experts staging that a round evicts is reclaimed when that round commits, up to one step later than before. PiperOrigin-RevId: 1027266124
copybara-service
Bot
force-pushed
the
test_1026179343
branch
from
November 21, 2026 21:43
46641bc to
1ba25bc
Compare
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.
With
max_staleness > 0the trainer already holds rollouts it may train on, but every step still waited for the whole weight sync round: rollout drain, transfer, install and publish. Only staging the trainer's weights needs the trainer to pause.A sync round now signals once the source has staged its weights.
StandardRLProgramwaits for that signal, then trains the next step while the round finishes in the background. At most one round is in flight, and the next step end waits for it. On-policy runs (max_staleness == 0) still wait for the commit.This requires a transport that transfers only the staged copy (
WeightSyncHandler.transfers_from_staged_copy, true by default). The Raiden handler does so when it skips D2H and no layer is planned as pre-tiled, which is its default. Otherwise the round is refused and the run fails: there is no fallback to holding the trainer.While a round is in flight the trainer is one version ahead of the rollouts. The dispatch window holds back one batch so that every batch is still within
max_stalenesswhen it is consumed, and the staleness window is judged against the trainer's version.TrainerWorkerstays READY for the whole round, including after a failed release. Releasing the staging runs on a thread of its own, kept apart from staging and from closing the trainer by a lock: it no longer queues behind the trainer'sfwd_bwd, which would hold the round open, and it does not run on the worker's event loop. It can therefore run while the trainer trains. It also no longer refreshes the trainer's OpenTelemetry busy anchor: the release can now land while the trainer waits for rollouts, and would erase that idle time. On-policy, the wait from staging to commit is therefore counted as trainer idle time.When the train stage exits for any reason, the in-flight round is cancelled and awaited, as a round was before.
Visible changes: queued rollouts are checked against the trainer's version, so a run tuned to its staleness limit can start dropping groups.
StandardRLProgram.policy_versionlags the trainer by one while a round is in flight;RLStepResult.policy_versionstill reports the version the step produced. Routed-experts staging that a round evicts is reclaimed when that round commits, up to one step later than before.