Streaming variational inference: out-of-core DataLoader for minibatch ADVI#698
Draft
YichengYang-Ethan wants to merge 1 commit into
Draft
Streaming variational inference: out-of-core DataLoader for minibatch ADVI#698YichengYang-Ethan wants to merge 1 commit into
YichengYang-Ethan wants to merge 1 commit into
Conversation
Ports the streaming data layer (IterableDataset, parquet_source, DataLoader, shuffle_buffer) from pymc-devs/pymc#8325. Self-contained numpy/pyarrow data layer with no pymc-internal coupling; public names mirror torch.utils.data. Tests moved alongside.
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.
Adds a streaming data layer for minibatch variational inference on data that doesn't fit in memory. Ported from pymc-devs/pymc#8325 — moving it here per the discussion on that PR (@ricardoV94's call to start in extras).
pm.Minibatchindexes an in-memory array, so peak memory is O(N). This streams minibatches from an out-of-core source into apm.Dataplaceholder instead, so peak memory is set by the batch, the source chunk, and the optional shuffle buffer — independent of N.The API mirrors
torch.utils.data:IterableDataset— a re-iterable, out-of-core source of rows (e.g.parquet_sourceover a directory of shards).DataLoader— fixed-size, optionally shuffled minibatches; sized, withlen(loader) == Nfortotal_size.shuffle_buffer— a bounded shuffle over the stream.The unbiased-gradient rescaling reuses the existing
create_minibatch_rv(the sameN / batch_sizeaspm.Minibatch), viatotal_size=len(loader).Notes:
pymc_extras/variational/streaming.py— happy to move it.pyarrowis an optional dependency, imported lazily only for the Parquet source.tests/variational/. End-to-end example: Example: out-of-core minibatch variational inference with DataLoader and Trainer pymc-examples#888.