Lightning-AI / Lightning-AI/lightning-thunder
Thunder seems to use way more memory when `litgpt.Config.parallel_residual=True`
@IvanYashchuk is already working on this.
Since Sep 25, 2024.
- Dominant language
- Python
- Stars
- 1.5k
- Forks
- 121
- PR merge metrics
- No merged PRs in 30d
Description
## 🐛 Bug
When input sequences get longer, Thunder seems to tend to use more memory than eager and torch.compile.
Let's take litgpt's `stablecode-completion-alpha-3b` as an example whose sequence length (`Config.block_size`) is 16384.
With the following table, Thunder's memory consumption can be more prone to sequence length
sequence length | Thunder | Torch Compile | Diff
-- | -- | -- | --
16384 | 77.02 | 71.73 | 5.29
12288 | 61.9 | 57.94 | 3.96
8192 | 46.85 | 44.2 | 2.65
4096 | 31.78 | 30.46 | 1.32
2048 | 24.28 | 23.63 | 0.65
### To Reproduce
Apply a diff like this and run commands like
```
python thunder/benchmarks/benchmark_litgpt.py --model_name stablecode-completion-alpha-3b --warmup_iters 0 --max_iters 3 --compile eager --dump_memory_snapshot false --block_size 2048
```
```diff
@@ -227,6 +269,7 @@ class Benchmark_litGPT:
fsdp_bucket_params: float | None = None,
checkpoint_activations: bool = False,
n_layers: int | None = None,
+ block_size: int | None = None,
profiler_start: int = 15,
profiler_stop: int = 15,
skip_data_sync: bool = False,
@@ -360,6 +403,8 @@ class Benchmark_litGPT:
if n_layers is not None:
self.config.n_layer = n_layers
+ if block_size is not None:
+ self.config.block_size = block_size
# Initialize the model
t0 = time.perf_counter()
```
#### Code sample
### Expected behavior
### Environment
pjnl-20240919
Contributor guide
No contributing guide indexed for this repository
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.
Assessment
This issue has not been assessed yet.