deepspeedai / deepspeedai/DeepSpeed
[BUG] load_checkpoint should load directly to gpu
@ShijieZZZZ is already working on this.
Since May 15, 2023.
- Dominant language
- Python
- Stars
- 43.1k
- Forks
- 5k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 112
Description
Describe the bug
Currently HF Transformers integration users can finetune a model and save the checkpoint with given resources. However resuming from that same checkpoint requires much more CPU peak memory - which can be huge for large models, which prevents users from resuming their finetuning. (The current workaround is to add a huge swap file)
To Reproduce
I reproduced it as part of this bug report: https://github.com/huggingface/transformers/issues/17258
The full reproduction steps are here: https://github.com/huggingface/transformers/issues/17258#issuecomment-1133492187
I also verified that torch.load doesn't load everything in CPU memory when map_location="cpu" https://github.com/huggingface/transformers/issues/17258#issuecomment-1133522602
and I tracked the issue down to deepspeed loading those potentially huge zero checkpoints (70GB for gpt-j-6) into cpu memory first:
Expected behavior
save_checkpoint and load_checkpoint should require approximately the same amount of memory and should be lean and not need any CPU memory other than the size of the largest param or optim state since torch.load copies params via cpu.
With upcoming models like 176B the current implementation just won't work as it would require several TBs of CPU memory to load a zero checkpoint.
@tjruwase, @jeffra
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.
Assessment
This issue has not been assessed yet.