Skip to content

Start all interleaved iterators on the first next() of InterleaveDatasetIterator. - #1483

Open
copybara-service[bot] wants to merge 1 commit into
mainfrom
test_1027222911
Open

copybara-service[bot] wants to merge 1 commit into
mainfrom
test_1027222911

Conversation

@copybara-service

@copybara-service copybara-service Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Start all interleaved iterators on the first next() of InterleaveDatasetIterator.

get_state() and set_state() before the first next() create the iterators
in use without starting them, e.g. when a ThreadPrefetchIterDataset (or
grain.experimental.device_put) on top reads the state before it starts, or
when restoring a checkpoint. Each of them was then only started when the
interleave first read from it. With mp_prefetch (one iterator per worker
process), every worker therefore only started after the previous one delivered
its first element, i.e. the workers started one after another instead of in
parallel.

The first next() now calls start_prefetch(), which starts all iterators in
use, as TunableInterleaveDatasetIterator already does.


📚 Documentation preview 📚: https://google-grain--1483.org.readthedocs.build/

…atasetIterator`.

`get_state()` and `set_state()` before the first `next()` create the iterators
in use without starting them, e.g. when a `ThreadPrefetchIterDataset` (or
`grain.experimental.device_put`) on top reads the state before it starts, or
when restoring a checkpoint. Each of them was then only started when the
interleave first read from it. With `mp_prefetch` (one iterator per worker
process), every worker therefore only started after the previous one delivered
its first element, i.e. the workers started one after another instead of in
parallel.

The first `next()` now calls `start_prefetch()`, which starts all iterators in
use, as `TunableInterleaveDatasetIterator` already does.

PiperOrigin-RevId: 1027222911

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants