Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve shard efficiency of sampling for fractional stream repeats. #391

Merged
merged 26 commits into from
Sep 9, 2023

Conversation

knighton
Copy link
Contributor

@knighton knighton commented Aug 21, 2023

Description of changes:

Adds a StreamingDataset argument sampling_granularity: int = 1, which determines how many samples are drawn from the same shard at a time when sampling a stream.

At 1, each sample is drawn independently for the partial repeat if any.

At 100, up to a hundred samples are pulled at a time from the same shard, limited by the number of un-picked samples left in the shard, for the partial repeat if any.

If shard usage efficiency is especially a concern, you would set sampling_granularity to the size of the biggest shard (500? 50000?) in order to fully exhaust one shard a time.

Issue #, if available:

Merge Checklist:

Put an x without space in the boxes that apply. If you are unsure about any checklist, please don't hesitate to ask. We are here to help! This is simply a reminder of what we are going to look for before merging your pull request.

General

  • I have read the contributor guidelines
  • This is a documentation change or typo fix. If so, skip the rest of this checklist.
  • I certify that the changes I am introducing will be backward compatible, and I have discussed concerns about this, if any, with the MosaicML team.
  • I have updated any necessary documentation, including README and API docs (if appropriate).

Tests

  • I ran pre-commit on my change. (check out the pre-commit section of prerequisites)
  • I have added tests that prove my fix is effective or that my feature works (if appropriate).
  • I ran the tests locally to make sure it pass. (check out testing)
  • I have added unit and/or integration tests as appropriate to ensure backward compatibility of the changes.

streaming/base/sampling.py Show resolved Hide resolved
streaming/base/sampling.py Show resolved Hide resolved
streaming/base/sampling.py Show resolved Hide resolved
streaming/base/sampling.py Show resolved Hide resolved
streaming/base/dataset.py Outdated Show resolved Hide resolved
streaming/base/sampling.py Show resolved Hide resolved
Copy link
Collaborator

@snarayan21 snarayan21 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just some clarification stuff like comments and duplicate variable names, other than that lgtm

scripts/samples/bench_and_plot.py Outdated Show resolved Hide resolved
streaming/base/sampling.py Outdated Show resolved Hide resolved
streaming/base/sampling.py Outdated Show resolved Hide resolved
@karan6181 karan6181 merged commit 75cc78f into main Sep 9, 2023
5 checks passed
@karan6181 karan6181 deleted the james/sparse-sampling branch September 9, 2023 15:02
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.

4 participants