Skip to main content

k-bit optimizers and matrix multiplication routines.

Project description

bitsandbytes

License Downloads Nightly Unit Tests GitHub Release PyPI - Python Version

bitsandbytes enables accessible large language models via k-bit quantization for PyTorch. We provide three main features for dramatically reducing memory consumption for inference and training:

  • 8-bit optimizers uses block-wise quantization to maintain 32-bit performance at a small fraction of the memory cost.
  • LLM.int8() or 8-bit quantization enables large language model inference with only half the required memory and without any performance degradation. This method is based on vector-wise quantization to quantize most features to 8-bits and separately treating outliers with 16-bit matrix multiplication.
  • QLoRA or 4-bit quantization enables large language model training with several memory-saving techniques that don't compromise performance. This method quantizes a model to 4-bits and inserts a small set of trainable low-rank adaptation (LoRA) weights to allow training.

The library includes quantization primitives for 8-bit & 4-bit operations, through bitsandbytes.nn.Linear8bitLt and bitsandbytes.nn.Linear4bit and 8-bit optimizers through bitsandbytes.optim module.

System Requirements

bitsandbytes has the following minimum requirements for all platforms:

  • Python 3.9+
  • PyTorch 2.2+
    • Note: While we aim to provide wide backwards compatibility, we recommend using the latest version of PyTorch for the best experience.

Accelerator support:

Platform Accelerator Hardware Requirements Support Status
🐧 Linux, glibc >= 2.24
x86-64 ◻️ CPU AVX2 〰️ Partial Support
🟩 NVIDIA GPU
cuda
SM50+ minimum
SM75+ recommended
✅ Full Support
🟥 AMD GPU
cuda
CDNA: gfx90a, gfx942
RDNA: gfx1100, gfx1200
🚧 In Development
🟦 Intel GPU
xpu
Data Center GPU Max Series
Arc A-Series (Alchemist)
Arc B-Series (Battlemage)
🚧 In Development
🟪 Intel Gaudi
hpu
Gaudi1, Gaudi2, Gaudi3 🚧 In Development
aarch64 ◻️ CPU 〰️ Partial Support
🟩 NVIDIA GPU
cuda
SM75, SM80, SM90, SM100 ✅ Full Support
🪟 Windows 11 / Windows Server 2019+
x86-64 ◻️ CPU AVX2 〰️ Partial Support
🟩 NVIDIA GPU
cuda
SM50+ minimum
SM75+ recommended
✅ Full Support
🟦 Intel GPU
xpu
Arc A-Series (Alchemist)
Arc B-Series (Battlemage)
🚧 In Development
🍎 macOS 13.1+
arm64 ◻️ CPU Apple M1+ 🛣️ Future Roadmap
⬜ Metal
mps
Apple M1+ 🛣️ Future Roadmap

:book: Documentation

:heart: Sponsors

The continued maintenance and development of bitsandbytes is made possible thanks to the generous support of our sponsors. Their contributions help ensure that we can keep improving the project and delivering valuable updates to the community.

Hugging Face

License

bitsandbytes is MIT licensed.

We thank Fabio Cannizzo for his work on FastBinarySearch which we use for CPU quantization.

How to cite us

If you found this library useful, please consider citing our work:

QLoRA

@article{dettmers2023qlora,
  title={Qlora: Efficient finetuning of quantized llms},
  author={Dettmers, Tim and Pagnoni, Artidoro and Holtzman, Ari and Zettlemoyer, Luke},
  journal={arXiv preprint arXiv:2305.14314},
  year={2023}
}

LLM.int8()

@article{dettmers2022llmint8,
  title={LLM.int8(): 8-bit Matrix Multiplication for Transformers at Scale},
  author={Dettmers, Tim and Lewis, Mike and Belkada, Younes and Zettlemoyer, Luke},
  journal={arXiv preprint arXiv:2208.07339},
  year={2022}
}

8-bit Optimizers

@article{dettmers2022optimizers,
  title={8-bit Optimizers via Block-wise Quantization},
  author={Dettmers, Tim and Lewis, Mike and Shleifer, Sam and Zettlemoyer, Luke},
  journal={9th International Conference on Learning Representations, ICLR},
  year={2022}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

bitsandbytes-0.46.0-py3-none-win_amd64.whl (66.5 MB view details)

Uploaded Python 3Windows x86-64

bitsandbytes-0.46.0-py3-none-manylinux_2_24_x86_64.whl (67.0 MB view details)

Uploaded Python 3manylinux: glibc 2.24+ x86-64

bitsandbytes-0.46.0-py3-none-manylinux_2_24_aarch64.whl (25.5 MB view details)

Uploaded Python 3manylinux: glibc 2.24+ ARM64

File details

Details for the file bitsandbytes-0.46.0-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for bitsandbytes-0.46.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 121820a6df80ae3b7e361f7ef193279c3204c361a7e21eb43b5ffa7293403979
MD5 0c07f83c4ee92b1eab413755e273d641
BLAKE2b-256 f3062ef5f6b28d8fa442c670b5acc1eb09dd57d4edb00b435b35529c3f09936c

See more details on using hashes here.

Provenance

The following attestation bundles were made for bitsandbytes-0.46.0-py3-none-win_amd64.whl:

Publisher: python-package.yml on bitsandbytes-foundation/bitsandbytes

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bitsandbytes-0.46.0-py3-none-manylinux_2_24_x86_64.whl.

File metadata

File hashes

Hashes for bitsandbytes-0.46.0-py3-none-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 ef38883cfd26f36a0dfff1715f620f87cee3813431f33e10e9658205160cb89b
MD5 3ac78918dbe4b0efae586fff4a17f38e
BLAKE2b-256 7227ec6ee3408e09e01ab05db07af5a97dc76db7bc18824cf5f5dbc98e1e08a4

See more details on using hashes here.

Provenance

The following attestation bundles were made for bitsandbytes-0.46.0-py3-none-manylinux_2_24_x86_64.whl:

Publisher: python-package.yml on bitsandbytes-foundation/bitsandbytes

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bitsandbytes-0.46.0-py3-none-manylinux_2_24_aarch64.whl.

File metadata

File hashes

Hashes for bitsandbytes-0.46.0-py3-none-manylinux_2_24_aarch64.whl
Algorithm Hash digest
SHA256 010709b56c85b0355f47fefbb37fe9058e8b18b9bf275bd576c5bd95a0d14d0c
MD5 7c9584c555811bc77951aa492d0944f3
BLAKE2b-256 7039aa68b7bd28b091a96795be18810b2325ce9263ba8db087f6f196a663f03a

See more details on using hashes here.

Provenance

The following attestation bundles were made for bitsandbytes-0.46.0-py3-none-manylinux_2_24_aarch64.whl:

Publisher: python-package.yml on bitsandbytes-foundation/bitsandbytes

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page