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

Per Stream Batching #407

Merged
merged 15 commits into from
Sep 7, 2023
Merged

Per Stream Batching #407

merged 15 commits into from
Sep 7, 2023

Conversation

snarayan21
Copy link
Collaborator

@snarayan21 snarayan21 commented Aug 31, 2023

Description of changes:

Enables batching where each batch consists of samples from just one stream! Users can access this functionality by setting batching_method to per_stream.

How it works:

  • make partition per stream
  • shuffle each partition
  • reshape to get global batches per stream, in order of traversal
  • discard batches with any padding at all
  • construct new overall batch ordering by selecting from stream batches
  • pad new batches if necessary
  • reshape/transpose back to get final partition

This is a useful feature requested mainly by advanced vision users. For example, each stream can be images of a different aspect ratio and resolution. Using per_stream batching means that pytorch now does not throw errors when trying to train with data of different dimensions now, as long as data of the same dimension is in its own stream.

Ran multi-GPU tests with toy datasets to make sure that samples in the same batch were only from a single stream. Ran regression tests over 200 batches using different text datasets to ensure that elastic determinism and resumption still work when using per_stream batching. These ran without issue and the results are here: https://wandb.ai/mosaic-ml/batching_methods/reports/new-batching-methods-testing--Vmlldzo1MzIxNjI1

Issue #, if available:

https://mosaicml.atlassian.net/browse/STR-124

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.

@snarayan21 snarayan21 changed the title Uniform batch Uniform global batch Aug 31, 2023
@snarayan21 snarayan21 changed the title Uniform global batch Per Stream Batching Sep 6, 2023
Copy link
Collaborator

@karan6181 karan6181 left a comment

Choose a reason for hiding this comment

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

Overall looks good to me. Can you also update the description with what all integration testing that you have run to validate this PR ?

streaming/base/dataset.py Outdated Show resolved Hide resolved
streaming/base/dataset.py Outdated Show resolved Hide resolved
streaming/base/dataset.py Outdated Show resolved Hide resolved
tests/test_streaming.py Outdated Show resolved Hide resolved
tests/test_streaming.py Show resolved Hide resolved
tests/test_streaming.py Outdated Show resolved Hide resolved
streaming/base/dataset.py Outdated Show resolved Hide resolved
streaming/base/dataset.py Outdated Show resolved Hide resolved
tests/test_streaming.py Show resolved Hide resolved
tests/test_streaming.py Outdated Show resolved Hide resolved
@snarayan21 snarayan21 merged commit 9eeccae into mosaicml:main Sep 7, 2023
5 checks passed
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.

2 participants