Lightning-AI / Lightning-AI/litgpt

Add back support for longest sequence first

Open
#1,195 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement fine-tuning
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

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 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.