Skip to main content

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 (Chinese)

More details can be found at: https://zhuanlan.zhihu.com/p/792303768

Usage

niuload offers the following advanced features:

  1. 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.

  1. 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)
  1. 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.

  2. 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

  1. 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.

Metadata

Release files for niuload 0.2.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for niuload 0.2.4
File Size Uploaded Provenance Actions
niuload-0.2.4.tar.gz 8.1 kB Without provenance Details for niuload-0.2.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for niuload 0.2.4
File Interpreter ABI Platform Actions
niuload-0.2.4-py3-none-any.whl Python 3 none any Details for niuload-0.2.4-py3-none-any.whl

Total release size: 16.0 kB

Release files / niuload-0.2.4.tar.gz

Download URL niuload-0.2.4.tar.gz
Size 8.1 kB
Tags Source
SHA-256 checksum
How to use checksums
6e65db4fb59ed5650c90287b01985bce4615fec4b2a62578c79069113432700d
BLAKE2b-256 checksum
How to use checksums
64d09e50c9488efdd5e799171dcc810e645437cdb872da6fdbcc9378f641420c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.2

Release files / niuload-0.2.4-py3-none-any.whl

Download URL niuload-0.2.4-py3-none-any.whl
Size 7.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
64fa425e6c134281420f25159ec327c9c33a8e1b748b770a1f3061fbad74fba1
BLAKE2b-256 checksum
How to use checksums
57fb5de3bdf1932421478ff213fc7683c79d4187fa52005024aed69f41dc0a2d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.2

Security for niuload 0.2.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page