Repository navigation
Reset InterleaveDatasetIterator._started in set_state() so sub-iterators restart in parallel. - #1494
Open
copybara-service[bot] wants to merge 1 commit into
Open
copybara-service[bot] wants to merge 1 commit into
copybara-service[bot] wants to merge 1 commit into
Conversation
…erators restart in parallel. `InterleaveDatasetIterator.set_state()` creates replacement sub-iterators with `start_prefetch=False` and calls `set_state()` on reused sub-iterators (stopping their `ThreadPrefetchDatasetIterator` threads) while leaving `self._started = True`. If `start_prefetch()` or `next()` had already run before `set_state()` (such as checkpoint restoration on a prefetched iterator or epoch reset under `RepeatIterDataset`), the next `next()` skipped `self.start_prefetch()`, causing `mp_prefetch` workers to respawn serially one by one instead of in parallel. `InterleaveDatasetIterator.set_state()` now resets `self._started = False` so the next `next()` (or explicit `start_prefetch()`) starts all restored sub-iterators in parallel. `TunableInterleaveDatasetIterator.set_state()` likewise calls `_stop_prefetch()`, creates replacement iterators with `start_prefetch=False`, and skips executor creation in `_set_num_make_iter_threads()` while not started. PiperOrigin-RevId: 1031664058
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.
Reset
InterleaveDatasetIterator._startedinset_state()so sub-iterators restart in parallel.InterleaveDatasetIterator.set_state()creates replacement sub-iterators withstart_prefetch=Falseand callsset_state()on reused sub-iterators (stopping theirThreadPrefetchDatasetIteratorthreads) while leavingself._started = True. Ifstart_prefetch()ornext()had already run beforeset_state()(such as checkpoint restoration on a prefetched iterator or epoch reset underRepeatIterDataset), the nextnext()skippedself.start_prefetch(), causingmp_prefetchworkers to respawn serially one by one instead of in parallel.InterleaveDatasetIterator.set_state()now resetsself._started = Falseso the nextnext()(or explicitstart_prefetch()) starts all restored sub-iterators in parallel.TunableInterleaveDatasetIterator.set_state()likewise calls_stop_prefetch(), creates replacement iterators withstart_prefetch=False, and skips executor creation in_set_num_make_iter_threads()while not started.📚 Documentation preview 📚: https://google-grain--1494.org.readthedocs.build/