Repository navigation
Conversation
…ain_test_split train_test_split collected the chunks of a subsampled dataset by filtering the index.json chunk list by filename, which returns them in index order rather than in the dataset's own subsampled order. Every chunk was then paired with the wrong region_of_interest entry whenever the dataset was shuffled, and a subsample above 1 raised "Lists must be of the same size." because the set also collapsed repeated filenames. Look the chunks up by filename in subsampled_files order instead, keeping duplicates, so chunk i always carries region_of_interest i.
Yi-111-a
requested review from
bhimrazy,
deependujha,
dhedey,
pwgardipee and
tchaton
as code owners
October 18, 2026 02:42
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #949 +/- ##
=====================================
Coverage 82% 82%
=====================================
Files 72 72
Lines 16445 16449 +4
=====================================
+ Hits 13505 13510 +5
+ Misses 2940 2939 -1 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for the change preserving correspondence between subsampled chunks and their regions of interest.
No open issues 🎉
What changed in this PR
This PR addresses #946 by preserving the correspondence between subsampled chunks and their regions of interest in train_test_split.
Changes:
- Looks up chunks in dataset order, retaining repeated filenames for
subsample > 1. - Reports missing chunk filenames with a direct error.
- Adds regression tests for shuffled subsamples and repeated chunks.
| File | Description |
|---|---|
tests/utilities/test_train_test_split.py |
Adds checks for item preservation with shuffled subsamples and split lengths with repeated chunks. |
src/litdata/utilities/train_test_split.py |
Preserves chunk order and duplicates when matching regions of interest, and validates missing filenames. |
Review effort: Balanced
deependujha
approved these changes
Oct 28, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #946
Problem
train_test_split()buildssubsampled_chunksby filtering theindex.jsonchunk list by filename:That keeps the chunks in index.json order, but
subsampled_filesandregion_of_interestare built in lockstep bysubsample_streaming_dataset()and are in the dataset's own subsampled order. Sosubsampled_chunks[i]andregion_of_interest[i]describe different chunks whenever the dataset is shuffled (shuffle=True), andtrain_test_splitsilently returns items from the wrong chunk.The
set(...)has a second effect: whensubsample > 1the dataset samples chunks repeatedly, sosubsampled_filescontains duplicates. Collapsing them to a set makessubsampled_chunksshorter thanregion_of_interest, andshuffle_lists_together()then raisesValueError: Lists must be of the same size.Fix
Look the chunks up by filename, in
subsampled_filesorder, keeping duplicates:This is the same O(n) lookup the set was there for, but keeps the correspondence that
shuffle_lists_together()/subsample_filenames_and_roi()assert on. A missing chunk is now reported with its filename instead of failing later.Tests
tests/utilities/test_train_test_split.py:test_split_a_shuffled_subsampled_dataset— a shuffled, subsampled dataset splits into exactly the items it contains (fails before with mismatched items).test_split_a_repeated_subsampled_dataset—subsample=1.5repeats chunks and splits cleanly (fails before withLists must be of the same size.).Both new tests fail on
mainand pass with this change.tests/utilities/is otherwise unchanged (the twotest_encryption.pyfailures in my local run are only a missingcryptographywheel).