Lightning-AI / Lightning-AI/litData

Add batch sampler for StreamDataloader to enable flexiable training strategy.

Open
#509 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Python
Stars
614
Forks
106
Avg merge
15h 8m
Merged PRs (30d)
22

Description

Hi, I just encounter a problem that associated with litdata. I reformat my dataset and dataloader with StreamDataset and StreamingDataLoader, but I found that the StreamingDataLoader can't accept the sampler function, which makes my original training strategy fails. I use bucket data training, which will put the images with same width/height ratio into the same batch, so I need to realize a special batch sampler to realize this. I need to deliever this sampler to the dataloader. But when I use StreamingDataLoader, I found it doesn't support this, so I can't realize the bucket training strategy, which will make my training sub-optimal. For example, I have prepare my data seqlen like [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], when I use a batch-size 4, I can guarantee that 0 1 2 3 and 4 5 6 7 and 8 9 10 11 and 12 13 14 15 will have the same bucket size, so in single GPU training, it runs fine. But when I switch to multi-gpu traning, the StreamingDataLoader will shuffle the seqlen, so I will get images that belong to different buckets, so it will raise error in the following collate function. Please add the sampler function for the StreamingDataLoader, or can you have any way to help me solve this problem?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing StreamingDataLoader's sampler and shuffle behavior, then reproduce the multi-GPU case with the provided sequence and batch size. Done means a sampler or equivalent mechanism preserves bucket boundaries across distributed batches so the collate function receives compatible samples.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data-engineering, machine-learning
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.