A module for balanced loading of large language models
Project description
niuload
niuload is a Python module for balanced loading large language models across multiple GPUs(pipeline parallel). This package can be used during training and inference.
report
More details can be found at: https://zhuanlan.zhihu.com/p/792303768
Usages
niuload offers the following advanced features:
- Customizable load distribution across each GPU. If not specified, the model will be evenly distributed across all GPUs by default.
from niuload import balanced_load
model = balanced_load("openai-community/gpt2", ratio=["0.5,1,1"], num_devices=4)
This example allows you to split the model across four GPUs, with GPU 0 only having half the load compared to the others.
- Specify which GPUs to use for model splitting.
from niuload import balanced_load
model = balanced_load("openai-community/gpt2", device_idx=[1,2,5,7], num_devices=4)
-
Support for training. Models automatically split by Hugging Face's
device_map='auto'do not always support training due to a current bug in accelerate. Specifically, when model.device is not on device 0, certain models can encounter errors. We currently force embeddings to be on GPU 0 to avoid this issue. -
Support for splitting models that are not supported by Hugging Face, but this requires some additional adaptation. We are working on reorganizing the code structure soon and welcome community contributions to the project.
Benchmark
For reproducing our results in report, you can checkout scripts under /benchmark.
FQA
-
Q: Why do I see the model being loaded twice?
A: To better analyze the model's parameter structure, we first load the model onto a meta device. This process is very fast because the initialized tensors are random and meaningless. After obtaining the device_map, we then actually load the model.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file niuload-0.2.2.tar.gz.
File metadata
- Download URL: niuload-0.2.2.tar.gz
- Upload date:
- Size: 8.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2e94b5148f6d7c20e8d058d87edd97aad930c08b4345882e7f4e48d0d384b4ef
|
|
| MD5 |
49c672314403c999c1c7fd6b00194c62
|
|
| BLAKE2b-256 |
be06671d721c516fd551a9a960810b0b46cf466fb250af73566b168aa28ec34d
|
File details
Details for the file niuload-0.2.2-py3-none-any.whl.
File metadata
- Download URL: niuload-0.2.2-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1e1047a9486b798d85fd4048b646e39764d91d27b07ea1b8c33b5ab1d44c5d84
|
|
| MD5 |
5db1bd33834d62471c32e21dc76d1a65
|
|
| BLAKE2b-256 |
43ddac12467a068eb7b7d44f4805e92ae3cccc5057b2beb4629d5df26f48950a
|