Repository navigation
Conversation
Validate the pinned dataset contract and restore worker RNG and callback state through TorchData, with checkpoint integration tests and trainer guidance. Co-Authored-By: Codex <noreply@anthropic.com> AI-Model: gpt-6 Co-Authored-By: Codex <noreply@ai-tool.com> AI-Contributed/Feature: 228/228 AI-Contributed/UT: 247/247
JingsongLi
reviewed
Oct 17, 2026
Keep callback state opaque to TorchData worker dictionary flattening, so dictionary subclasses retain their metadata after loader restoration. Add a spawn-worker regression for per-episode defaultdict counters. Co-Authored-By: Codex <noreply@anthropic.com> AI-Model: gpt-6 Co-Authored-By: Codex <noreply@ai-tool.com> AI-Contributed/Feature: 5/5 AI-Contributed/UT: 45/45
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.
Purpose
Allow
ContiguousWindowDatasettraining to resume through TorchData'sStatefulDataLoader, including shuffled, prefetched batches and random transforms. Saving only the model and a sampler cursor can resume from the wrong batch because workers have already prefetched later samples.CWD now implements
state_dict()/load_state_dict()to validate the pinned table/snapshot, actual context and anchor index, and window configuration, and to restore Python/NumPy/Torch CPU RNGs and stateful transform/adapter callbacks. Callback states are wrapped as opaque tuple leaves so TorchData's dictionary flattening preserves dictionary subclasses and their metadata. The immutable index identity is cached after its first checkpoint. Reader caches and decoder handles are rebuilt.This reuses TorchData's loader and samplers. TorchData is added only to the torch test dependency group. The documentation shows saving model/optimizer/loader/RNG state at a completed optimizer step, including the iterator-before-generator restoration order needed for the next epoch's shuffle.
The initial contract requires the same retained snapshot, preprocessing, loader configuration, framework versions and worker/rank topology. Cross-rank checkpoint coordination and model execution determinism remain the trainer's responsibility.
Tests
StatefulDistributedSamplerprogress.defaultdict(int)counter; the original code fails withKeyErroron the first unseen episode.git diff --checkpass. Local integration environment: Python 3.13, Torch 2.10.0, TorchData 0.11.0.