You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
train_test_split pairs chunks with the wrong region_of_interest for shuffled subsampled datasets (and fails for subsample > 1)聽#946
litdata.train_test_split rebuilds the chunk list by filtering index.json with set(dataset.subsampled_files). That list follows the index.json order and has duplicates removed, while dataset.region_of_interest keeps the order of subsampled_files. The two lists are then paired by position.
With StreamingDataset(..., subsample=<1, shuffle=True), subsampled_files is in shuffled order, so chunks get another chunk's ROI. The resulting splits silently include items that are not in the input dataset and miss items that are.
With subsample > 1, chunks appear more than once in subsampled_files, the set collapses them, and the two lists have different lengths: ValueError: Lists must be of the same size. from shuffle_lists_together (or, with shuffle=False, the assert len(chunks) == len(roi_list) in subsample_filenames_and_roi).
not in input: [65, 66, 67, 68, 69]
missing : [95, 96, 97, 98, 99]
...
File ".../litdata/utilities/subsample.py", line 23, in shuffle_lists_together
raise ValueError("Lists must be of the same size.")
ValueError: Lists must be of the same size.
Expected behavior
The splits together contain exactly the items of the input dataset, for any subsample / shuffle setting of the input.
Additional context
A possible fix is to build the chunk list from subsampled_files directly, through a filename -> chunk dict (so the lookup stays O(n) as in #647), keeping its order and repetitions. Behaviour for non-shuffled inputs is unchanged. I have a small patch with a regression test and can open a PR if that approach is OK.
Environment: litdata main @ c6f075c, Python 3.12, macOS, CPU only.
Disclosure: found, reproduced and the draft fix tested locally with the help of an AI coding agent (Claude Code); reviewed before filing.
Two separate problems from the same filter-by-filename step:
the chunks come back in index.json order while region_of_interest is in the dataset's subsampled order, so a shuffled dataset pairs each chunk with the wrong region of interest;
the set(...) collapses the repeated filenames that subsample > 1 produces, which makes the two lists different lengths and trips the sanity check in shuffle_lists_together().
Fixed by looking each chunk up in subsampled_files order and keeping duplicates.
Activity
Yi-111-a commentedon Oct 18, 2026
Opened #949.
Two separate problems from the same filter-by-filename step:
index.jsonorder whileregion_of_interestis in the dataset's subsampled order, so a shuffled dataset pairs each chunk with the wrong region of interest;set(...)collapses the repeated filenames thatsubsample > 1produces, which makes the two lists different lengths and trips the sanity check inshuffle_lists_together().Fixed by looking each chunk up in
subsampled_filesorder and keeping duplicates.