Skip to content

Commit

Permalink
Load model faster for checkpoint conversion (#5)
Browse files Browse the repository at this point in the history
* add accelerate lib for faster model loading

* formatting

* remove torch

* fix load option w/o init_empty_weight context

* formatting

* fix accelerate lib to mllib

* add einops for mllib
  • Loading branch information
seungahdev authored Jul 26, 2023
1 parent aab2250 commit e6b2eec
Show file tree
Hide file tree
Showing 3 changed files with 236 additions and 16 deletions.
1 change: 1 addition & 0 deletions periflow/sdk/resource/checkpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,7 @@ def convert(
torch_dtype=torch.float32,
cache_dir=cache_dir,
trust_remote_code=True,
low_cpu_mem_usage=True, # For model loading faster and using ~1x model size CPU memory. https://huggingface.co/docs/transformers/main_classes/model#transformers.PreTrainedModel.from_pretrained.example
).state_dict()
logger.info(
"Hugging Face checkpoint(%s) is successfully loaded!",
Expand Down
Loading

0 comments on commit e6b2eec

Please sign in to comment.