Repository navigation
Conversation
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #940 +/- ##
=====================================
Coverage 82% 82%
=====================================
Files 72 72
Lines 16445 16519 +74
=====================================
+ Hits 13505 13580 +75
+ Misses 2940 2939 -1 🚀 New features to boost your workflow:
|
|
Found two P2 correctness issues at
All 16 focused allocation/budget tests passed; neither case is covered. — GPT-6, on direct instruction; reviewed before posting |
40c2b03 to
1a2e1da
Compare
|
Hi @bhimrazy @tchaton @dhedey @pwgardipee @deependujha I have made the changes as per the suggestions. |
Co-Authored-By: GPT-6 <noreply@openai.com> Agent-Harness: codex
Co-Authored-By: GPT-6 <noreply@openai.com> Agent-Harness: codex
Before submitting
What does this PR do?
Fixes #790.
This PR adds an optional global cache budget to
CombinedStreamingDatasetso that a single total disk budget can be enforced across all childStreamingDatasets, instead of each dataset independently growing its cache (which easily leads to runaway disk usage when composing large mixtures, e.g. 50+ datasets).New API (purely additive, fully backward compatible)
cache_allocation"proportional"(default)"equal"Behavior details
max_cache_size=None(default) is a strict no-op: children keep their ownmax_cache_size(existing behavior untouched).max_cache_sizevalues._resolve_max_cache_sizemachinery (intbytes, human-readable sizes like"100GB", or free-disk fractions like0.90) and applied to each child'smax_cache_sizein__iter__before its cache/eviction thread is created — so the proven per-directory eviction inPrepareChunksThreadenforces the budget unchanged (no changes tocache.py/reader.py/dataset.py).__iter__on its dataset copy, budgets are correctly applied inside every worker process (covered by a dedicated test that records the budget each worker copy sees).StreamingDatasetchildren are skipped, so a child's budget is never set to a falsy0(which would silently disable eviction inPrepareChunksThread).StreamingDataset; if theMAX_CACHE_SIZEenvironment variable is set alongside a combined budget, a warning documents that the env var takes precedence.Example
With datasets of 8 and 24 items (no explicit weights), a
"10GB"budget distributes as2.5GB/7.5GB.PR review
Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in GitHub issues there's a high chance it will not be merged.
Testing
Followed the TDD workflow from
CONTRIBUTING.md(failing tests first, then implementation).tests/streaming/test_combined.py: no-op default, equal/proportional allocation (explicit weights + length-based default weights), child-budget override, invalidcache_allocationraisesValueError, end-to-end enforcement (cache._reader._max_cache_size), string/fraction parsing, per-DataLoader-worker enforcement (records budgets from worker copies, spawn-safe),MAX_CACHE_SIZEenv-var warning, epoch re-allocation stability, small-budget warning, and helper-level stub/Nonetests.pytest tests/streaming/test_combined.py tests/streaming/test_cache_eviction.py tests/streaming/test_dataloader.py→ 88 passed, 2 skippedpytest tests --ignore=tests/processing --ignore=tests/raw -n 2 --dist=loadgroup --timeout=120) → 741 passed, 4 skipped, 3 failed; all 3 failures are pre-existing parallel-load flakes in unrelated distributed tests (test_cache_for_image_dataset_distributed[2],test_dataset_reshuffling_every_epoch,test_parallel_dataset_partial_iteration_resume[False-False-None]) — all pass when run serially.ruff check/ruff format --check/mypy→ clean.spawnstart method (macOS/Windows CI path).Documentation
README.md: new "Global cache budget" subsection in the Combined streaming section (example + allocation-mode table + caveats).src/litdata/CHANGELOG.md:[unreleased] ### Addedentry.