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

Use registry when creating Stream in StreamingDataset #858

Merged
merged 13 commits into from
Jan 7, 2025

Conversation

es94129
Copy link
Collaborator

@es94129 es94129 commented Jan 2, 2025

Description of changes:

Add registry support to allow custom implementations of components like Stream, (in the future) batching methods and shuffling algorithms, similar to LLM foundry's registry.

Changes made in this PR:

  • Copy the registry_utils.py file and corresponding tests from LLM foundry
  • Set up a streams_registry that contains the Stream class
  • Enable StreamingDataset to use the stream instance constructed from streams_registry

Existing Stream and StreamingDataset functionality remains unchanged, with added support for custom Stream implementations. See test_registry.py and LLM foundry's README of registry for more usage examples. Minimal example:

from streaming.base.registry_utils import construct_from_registry
from streaming.base.stream import streams_registry

streams_registry.register('stream', func=MyStream)

kwargs = {
    'remote': remote,
    'local': local,
    **kwargs,
}

stream = construct_from_registry(
    'stream',
    streams_registry,
    partial_function=False,
    kwargs=kwargs,
)

assert local == stream.local

Issue #, if available:

N/A

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). -- added under the section "Using Streams"

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. -- covered by existing tests

@es94129 es94129 marked this pull request as draft January 2, 2025 21:40
@es94129 es94129 marked this pull request as ready for review January 2, 2025 23:46
@es94129 es94129 requested a review from dakinggg January 3, 2025 00:22
@es94129
Copy link
Collaborator Author

es94129 commented Jan 3, 2025

Hoping to request a review from @XiaohanZhangCMU too, but Github wouldn't let me do that

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.

code and tests all lgtm, thanks for adding this! Could you please add a few sentences about registries in the streaming docs, likely in this section: https://docs.mosaicml.com/projects/streaming/en/stable/dataset_configuration/mixing_data_sources.html#using-streams

Can be very similar to what you have in the PR description. And a link to LLM Foundry's READMEs on registry usage would be useful too.

Thanks!

tests/test_stream.py Show resolved Hide resolved
CONTRIBUTING.md Show resolved Hide resolved
@es94129 es94129 requested a review from snarayan21 January 3, 2025 23:49
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.

thanks for adding tests and updating the docs! Just minor changes.

docs/source/dataset_configuration/mixing_data_sources.md Outdated Show resolved Hide resolved
tests/test_stream.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@XiaohanZhangCMU XiaohanZhangCMU left a comment

Choose a reason for hiding this comment

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

Overall looking good! Left a few minor comments.

streaming/base/registry_utils.py Outdated Show resolved Hide resolved
streaming/base/registry_utils.py Outdated Show resolved Hide resolved
tests/test_stream.py Show resolved Hide resolved
streaming/base/dataset.py Outdated Show resolved Hide resolved
streaming/base/dataset.py Outdated 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.

minor nit, other than that LGTM

streaming/base/dataset.py Outdated Show resolved Hide resolved
tests/test_stream.py Show resolved Hide resolved
Co-authored-by: Saaketh Narayan <[email protected]>
@es94129 es94129 merged commit 0b2227f into main Jan 7, 2025
7 checks passed
@es94129 es94129 deleted the es94129/registry-stream branch January 7, 2025 19:44
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