Lightning-AI / Lightning-AI/litgpt
Add back support for longest sequence first
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 13.7k
- Forks
- 1.5k
- Avg merge
- 15h 37m
- Merged PRs (30d)
- 1
Description
> @awaelchli Semi related to this PR. I just noticed that we don't have the code to run the longest sample at the beginning of training anymore: https://github.com/Lightning-AI/litgpt/blob/globals/finetune/lora.py#L268-L270
> Should we add it back? It's useful to OOM as soon as possible. If not, let's drop the `longest_seq_ix` variable entirely
> I'm fine returning the longest element first if that's possible to implement in the SFTDataset. I would also move the responsibility of selecting the longest sample to the datamodule/dataset so that this logic doesn't have to be in the script, and we expose a simple method/attribute for the longest_seq_length. This way, we can precompute it during the loading of the dataset and don't have to iterate through the whole dataset again.
From https://github.com/Lightning-AI/litgpt/pull/1179#discussion_r1538392383
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with finetune/lora.py around lines 268-270 and trace the SFTDataset and datamodule references discussed in the issue. Determine where the longest sample selection belongs, then verify that the longest sequence is processed first and that the exposed length avoids a second full-dataset scan.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- machine-learning
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100