Lightning-AI / Lightning-AI/litgpt

OOM with bf16-true, Quantization, for long context length.

Open
#477 18 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug help wanted quantization
Dominant language
Python
Stars
13.7k
Forks
1.5k
Avg merge
15h 37m
Merged PRs (30d)
1

Description

Hello.

I tried to install everything mentioned from git cloning to installing all requirements, except flash attentions.

I have an A100 40GB machine
CUDA 11.0

Now downloaded the llama-2-7B checkpoints and prepared.

also prepared alpaca dataset. with llama-2-7B using
```
python scripts/prepare_alpaca.py
```

Now i changes the finetune.lora.py. Inside get_batch.
```
max_len = 4000 # max(len(s) for s in input_ids) if fabric.device.type != "xla" else longest_seq_length
```

Using the Below command runs successfully on single GPU. with 4000 context length
```
python finetune/lora.py --precision 'bf16-true'
```

Using Below command with quantization is giving OOM.
```
python finetune/lora.py --precision 'bf16-true' --quantize 'bnb.nf4-dq'
```

This is suspicious. I think if just "bf16-true" is running fine, then "bf16-true" along with quantization should also work even with less memory.

Can someone suggest, what went wrong. What am i missing?

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, especially get_batch, and reproduce both commands after preparing the Alpaca data with scripts/prepare_alpaca.py. Compare the memory behavior of bf16-true with and without bnb.nf4-dq; done means identifying and documenting the cause of the quantized run's OOM or establishing a specific change needed to avoid it.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.