Skip to content

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
copybara-service[bot] merged 1 commit into
mainfrom
test_1026179343
Nov 21, 2026

Conversation

@copybara-service

@copybara-service copybara-service Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

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.

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.

…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
copybara-service Bot merged commit 1ba25bc into main Nov 21, 2026
5 checks passed
@copybara-service
copybara-service Bot deleted the test_1026179343 branch November 21, 2026 21:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant