feat(checkpoint): add generation-prefix recovery - #4319
Open
macandro96 wants to merge 5 commits into
Open
macandro96 wants to merge 5 commits into
macandro96 wants to merge 5 commits into
Conversation
Signed-off-by: Anish Mahishi <amahishi@nvidia.com>
Signed-off-by: Anish Mahishi <amahishi@nvidia.com>
Signed-off-by: Anish Mahishi <amahishi@nvidia.com>
Signed-off-by: Anish Mahishi <amahishi@nvidia.com>
❌ Submodule Fast-Forward Check FailedCheck based on commit: c31dc5c (PR #4319 from ❌ Submodules that need attention:Gym: ❌ Commits have DIVERGED from a common ancestor Please ensure all submodule commits are fast-forwards of the amahishi/gym-turn-recovery-orchestration branch before merging. |
macandro96
added this pull request to stack #4267
September 29, 2026 04:25
macandro96
marked this pull request as ready for review
September 29, 2026 04:28
Signed-off-by: Anish Mahishi <amahishi@nvidia.com>
5 tasks
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
This PR adds generation-prefix recovery on top of the turn-level Gym recovery contract in #4266.
When a periodic rollout snapshot occurs while vLLM is still decoding, the active output prefix is staged in TransferQueue (TQ) and referenced from Gym's durable model lineage. After a restart, a replacement model call reconstructs that prefix from TQ and generates only the remaining suffix instead of restarting the entire model call.
This does not checkpoint the vLLM KV cache. Recovery reconstructs the model input from durable token IDs.
Checkpoint flow
flowchart TD A[Periodic rollout snapshot requested] --> B[Single Controller closes rollout admission] B --> C[Fence terminal token-capture writes<br/>vLLM continues decoding] C --> D[Gym prepares active agents and model calls] D --> E[Each vLLM worker freezes/swaps<br/>the current capture buffer] E --> F[Stage active token prefixes in TQ] F --> G[Return token-free TQ coordinates<br/>to the Gym model ledger] G --> H[Gym commits agent/resource state<br/>and model lineage] H --> I[Single Controller validates<br/>Gym references against TQ] I --> J[Save TQ + controller recovery state] J --> K[Atomically publish rollout snapshot] K --> L[Resume Gym and release generation fence]Recovery flow
flowchart TD A[Select latest compatible rollout snapshot] --> B[Restore TQ and controller state] B --> C[Restore Gym participants and lineage] C --> D[Redispatch unfinished rollout attempt] D --> E[Gym attaches saved prefix coordinates<br/>to the replacement model call] E --> F[vLLM fetches and validates<br/>the saved token chunks from TQ] F --> G[Rebuild engine input from the prefix] G --> H[Generate only the remaining suffix] H --> I[Stage one canonical terminal call<br/>and continue normal finalization]Implementation
rollout_checkpointing.gym.mode: prefix_recovery.generation_chunk_flush_tokens; the checkpoint cut flushes any remaining unstaged tokens.Scope and non-goals
Stack
Coverage added
Validation
ruff checkpassed on touched Python files.ruff format --checkpassed on the final stacked tree.