Repository navigation
fix(looper): bound disk-backed output staging and verify replay reads - #3790
Merged
Merged
Conversation
Qubitium
force-pushed
the
fix/disk-backed-output-bounds-integrity
branch
from
November 12, 2026 02:49
ab657db to
a50e9cf
Compare
Collaborator
Author
|
Reviewed: out-of-order batches spill to disk, replay reads detect changed shards, and concurrent appends claim distinct indices. All 14 focused tests pass with and without the GIL; CI passes and the review thread is resolved. |
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.
Fix
Out-of-order replay batches previously stayed in RAM until a whole shard completed. Each incomplete batch now spills to an atomic safetensors file; only one complete shard is loaded during assembly. Replay reads recheck the shard digest, and concurrent
append()calls reserve distinct indices under the writer lock.flowchart TD A["DiskBackedLayerOutputWriter.put or append"] --> B["Reserve index under lock"] B --> C{"Shard complete?"} C -- "No" --> D["Atomically spill batch to disk"] C -- "Yes" --> E["Load and hash one shard"] E --> F{"Digest valid?"} F -- "No" --> X["Fail; do not commit"] F -- "Yes" --> G["Commit shard and progress"] H["DiskBackedLayerOutputSequence.__getitem__"] --> I["Load batch and rehash shard"] I --> J{"Digest valid?"} J -- "No" --> Y["Fail; do not return tensor"] J -- "Yes" --> K["Return batch"] classDef failure fill:#fdd,stroke:#c33 class X,Y failuregptqmodel/looper/input_cache.py:559_pendingheld each tensor in RAM_pendingholds spill path and digestgptqmodel/looper/input_cache.py:320gptqmodel/looper/input_cache.py:581put()Validation: 14 focused disk-backed tests passed on normal Python and again with
PYTHON_GIL=0; 2,000 out-of-order batches retained zero pending tensors in RAM. Reference:docs/looper-checkpoint-redesign.md.Fixes #3588.