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

Cold shard eviction #219

Merged
merged 128 commits into from
May 25, 2023
Merged

Cold shard eviction #219

merged 128 commits into from
May 25, 2023

Conversation

knighton
Copy link
Contributor

@knighton knighton commented Apr 8, 2023

Description of changes:

Cold shard eviction. Keep filesystem usage under some limit. Do this by dropping least recently accessed shards as needed when downloading new shards. This is a general solution that works with random access.

  • Redesign shard states: MISSING, DOWNLOADING, PRESENT (evicting happens under the lock)
  • Initialize shard_states by walking and normalizing stream local dirs
  • Implement shard eviction
  • Redesign StreamingDataset keep-related args to add cache_limit, drop keep_raw
  • Bookkeeping for shard access times and tracking disk usage
  • Automatically evict shards based on disk usage limit

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.

This is beacuse we use it in StreamingDataset init for coordinating ranks.
Also add a reference to its contained builtin SharedMemory's buf so it can be used as a drop-in
replacement.
- use cache_limit argument
- cache_usage int64 in shared memory
- shard access times in shared memory
- shard get_raw/zip/full/persistent_size
- StreamingDataset._evict_shard
- StreamingDataset._evict_coldest_shard
- rewrite StreamingDataset._download_shard
- Stream.safe_keep_zip (with local vs remote check)
Copy link
Contributor

@dakinggg dakinggg left a comment

Choose a reason for hiding this comment

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

For testing, would be good to have

  1. unit test for simple shard eviction (low cache limit)
  2. mosaicgpt run with shard eviction to make sure it still runs, has good throughput, loss looks fine.

streaming/base/dataset.py Show resolved Hide resolved
streaming/base/dataset.py Outdated Show resolved Hide resolved
streaming/base/dataset.py Outdated Show resolved Hide resolved
streaming/base/format/base/reader.py Outdated Show resolved Hide resolved
streaming/base/format/base/reader.py Outdated Show resolved Hide resolved
streaming/base/format/base/reader.py Show resolved Hide resolved
streaming/base/stream.py Outdated Show resolved Hide resolved
streaming/base/stream.py Show resolved Hide resolved
streaming/base/shared/__init__.py Outdated Show resolved Hide resolved
@karan6181 karan6181 merged commit b05072e into main May 25, 2023
@karan6181 karan6181 deleted the james/evict branch May 25, 2023 03:18
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