Repository navigation
Conversation
…blish barrier A rollout checkpoint saved every running rollout at the weight-publish barrier: the trainer waited in its broadcast and inference idled until the slowest env worker pool replica had snapshotted and held its rollouts. The training arrays were then written while the sink lock was held, which stalled collection. The barrier now only cuts the open work and pins the training arrays it references on the sample servers, then returns. With the sink still locked the orchestrator forks the writer of the open work. Each rollout in flight at the cut then takes its memory checkpoint, held only while its own is taken, and a rollout that is booting or in setup is tried again. The next publish barrier closes the save before inference gets the new weights: a worker starts no memory checkpoint after it confirmed the close and drops any that started later, so every token a restore point holds was sampled with the checkpointed step's weights or older. The arrays are written from their pins and unpinned, the restore points go to rollouts/restores.pkl, and progress.pt completes the checkpoint last. A checkpoint that a pause or checkpoint request asks for keeps the old order: every running rollout is snapshotted and held, then the open work is cut, then the rollouts are released. The checkpoint stats and log report the coverage of the restore points: the rollouts in flight at the cut, the restore points taken, the ones missed by why (finished first, deadline, not ready, no reply, unsaveable) and the time the save was open. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Wiz Scan Summary
To detect these findings earlier in the dev lifecycle, try the Wiz Code extension for VS Code, JetBrains, or Visual Studio. |
hallerite
marked this pull request as ready for review
November 29, 2026 11:17
…store files The barrier clears the step's rollouts directory and carries the restore files of resumed episodes not dispatched yet before the arrays are written, which created it before. Linking into a missing directory failed, so each of those episodes lost its restore point and started over after the next checkpoint. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The client sends each request from its own task, so a close can reach a worker before the save it closes. The worker ignored that close and the save then ran open, able to take memory checkpoints after the next policy arrived. A worker now remembers the recent closes of saves it has not received, and such a save opens closed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A rollout store credited a blob by truncating and rewriting its file, the inode a checkpoint pin and an earlier checkpoint link. A group scored after the cut then overwrote the bytes the checkpoint was to write. The store now writes the credited blob to a new file and renames it over the old name, under a lock that its deletes and moves to a trained step also take, so a freed blob stays freed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit e8323be. Configure here.
mikasenghaas
reviewed
Dec 1, 2026
| The orchestrator then saves step N when the trainer publishes the weights of N, before inference applies them. The checkpoint holds the pipeline of that moment, so a resumed run ships the batches that the first run would have shipped. | ||
| The orchestrator then cuts step N when the trainer publishes the weights of N, before inference applies them. The checkpoint holds the pipeline of that moment, so a resumed run ships the batches that the first run would have shipped. | ||
|
|
||
| The cut takes well under a second, and then training and inference go on: |
Member
There was a problem hiding this comment.
would not put stuff like "action x takes y amount of time" in the docs
|
|
||
| 1. At the publish barrier of N, the orchestrator records the open work at one instant. It pins the training arrays that the open work references on the env workers that keep them, so neither the trainer nor the orchestrator frees them before they are written. | ||
| 2. While training goes on, the arrays are written to the checkpoint and then unpinned. Each rollout that was running at the cut takes its memory checkpoint. It stops only while its own snapshot is taken. | ||
| 3. The publish barrier of N + 1 closes the save. No memory checkpoint starts after that, so every token that a restore point holds was sampled with the weights of N or older. A resumed run serves the weights of N. |
Member
There was a problem hiding this comment.
so we stop checkpointing here instead of blocking? imo we should be blocking, should prioritize getting the ckpt complete
Comment on lines
+88
to
+90
| SAVES_IN_FLIGHT = 250 | ||
| """Memory checkpoints a listed save takes at once. The ones waiting for their turn start | ||
| none after the save closes.""" |
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.

Summary
With
ckpt.rollouts, a rollout checkpoint used to save every running rollout at the weight-publish barrier. All of that happened at the barrier: every env worker snapshotted its rollouts and held them, the orchestrator cut the open work, and then released them. The trainer waited in its broadcast, and inference was idle, until the slowest env worker pool replica answered.On a production run with about 10k rollouts in flight:
This PR leaves only the cut on the barrier. The restore points are taken afterwards, while training and inference go on.
How it works
dispatch_id.request_ids of the in-flight runs it holds. A worker saves each listed rollout withRollout.save(hold=True)and releases it right after, so a rollout stops only while its own memory checkpoint is taken. A recent periodic checkpoint saves a snapshot.close_saveto every replica still saving. It waits for their confirmation, bounded at 10 s, before inference receives v{N+1}.Checkpoint.time.start).RolloutStorehardlinks the files underpinned/<name>/instead./persistwithpin), then unpinned. The checkpoint contents are unchanged.rollouts/restores.pkl(dispatch_id →RestoreRef), thenprogress.ptlast. A resume picks the newest complete checkpoint, as before. Checkpoints written before this change load unchanged.Requested checkpoints keep today's order. A checkpoint that a pause or checkpoint request asks for still snapshots and holds every running rollout, then cuts, then releases, while the trainer waits. A stopped run saves everything it saves today. The arrays are pinned there too, so the hook no longer waits for the cut batch's arrays to be written.
Coverage is observable
The checkpoint log gets a coverage line, and
ckpt/rollouts/*gets these metrics:listedrestoredmissed/finishedmissed/deadlinemissed/not_readymissed/no_replymissed/unsaveabletime/barriertime/windowA high
missed/deadlinecount means the save does not fit into one step.Semantics to know
ckpt.interval = 1and a hung replica, the wait can reachrollouts_save_timeout+ 600 s, which is today's worst case.PayloadServer.replacenow drops the blob's last persisted file. Without this, a sample credited after an earlier checkpoint persisted it would be linked stale into the next checkpoint.Risks and follow-ups
dispatcher.inflight, a rollout checkpoint's cut does not list them. Their groups then never complete after a resume. The same holds with today's barrier save.episode_restore_pointfits into_try_save: hold the episode's rollouts, save them, release them.weight_versions). Engines that report no labels cannot use this.Validation
Unit tests (CPU):
tests/unit/orchestrator/test_rollout_ckpt.py:tests/unit/env/test_env_worker_save.py:tests/unit/orchestrator/test_env_replicas.py: runs are routed to their replica; a replica that answered needs no close; an unconfirmed replica's restore points are dropped and land inlate_restores.tests/unit/transports/test_payload.py:RolloutStorepins survive deletes and the cleanup of trained steps.End to end: a local reverse-text run (subprocess runtime, so every in-flight rollout restarts on resume), with
ckpt.interval = 4andckpt.rollouts, before and after this change. See the barrier times below.Setup:
Rollout.savestands in for one.A resume from the async checkpoint of step 8 (
--resume.step 8) restored the 7 in-queue episodes the checkpoint saved, re-ran its 15 in-flight rollouts, and went on to step 12.Live checkpoint and resume
Ran Qwen3-0.6B with vLLM and Prime memory snapshots on two Nebius H200s (Slurm job
17295). The test controlled when two real captures started using their observed engine weight labels. Step 2 published five restore references, all with token versions at or below v2. The first probe's saved prefix included 12 v2 tokens. The other probe captured 7 v3 tokens after the save window closed and was excluded from the checkpoint.A fresh trainer loaded step 2. The first probe's restored token IDs and version spans matched the saved prefix exactly, and its first new response came from v2. The second probe started over with a new trace ID and sampled from v2. The fork reached step 4.
All 58 focused checkpoint, env worker, replica, and payload tests passed. A separate-process check also verified that scoring cannot resurrect a sample discarded by an env worker.
Checkpoint interval
With restore points off the barrier, a rollout checkpoint no longer stalls the trainer, so
ckpt.intervalcan come down (for example from 50 to 20-25 steps) to bound the steps a crash replays. Pair it with the trainer'sasync_saveand watch the newckpt/rollouts/missed/*metrics for snapshot load.🤖 Generated with Claude Code
Note
High Risk
Changes core rollout checkpoint timing, distributed save/close protocol across env replicas, and training-array pinning—errors can lose restore points or stall barriers under slow replicas.
Overview
Rollout checkpoints no longer block the weight publish barrier on every env snapshot. At step N, the barrier only records open work, pins referenced training arrays, and forks the open-work writer; the hook returns while training and inference continue. In-flight rollouts are snapshotted afterward via per-replica listed saves (
save_id,request_ids,close_save), each rollout held only for its own capture, with retries for booting/setup rollouts and a cap of 250 concurrent saves per worker.The next publish barrier (v{N+1}) closes the save window (10s confirm budget) so no restore point can include tokens from newer weights; checkpoints finish with
restores.pklplusprogress.ptafter arrays are persisted and unpinned.Training array persistence adds env-worker pin/unpin (
/pin,/unpin, optional pin on/persist) so blobs survive trainer/sink deletes until the checkpoint is written, without holding the sink lock for large persists. RolloutStore uses file locks and pin directories; credited blobs no longer clobber earlier linked checkpoint files.Pause/checkpoint-requested steps still use the old hold-all-then-cut path while the trainer waits. Docs/config text and
ckpt/rollouts/*coverage metrics describe the new cut/deadline semantics and missed-restore categories.Reviewed by Cursor Bugbot for commit 27edee8. Bugbot is set up for automated code reviews on this repo. Configure here.