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.10+
  • PyTorch 2.4+
    • Note: While we aim to provide wide backwards compatibility, we recommend using the latest version of PyTorch for the best experience.

Accelerator support:

Note: this table reflects the status of the current development branch. For the latest stable release, see the document in the 0.49.2 tag.

Legend:

🚧 = Planned | 〰️ = Partially Supported | ✅ = Supported | ❌ = Not Supported

Platform Accelerator Hardware Requirements LLM.int8() QLoRA 4-bit 8-bit Optimizers
🐧 Linux, glibc >= 2.24
x86-64 ◻️ CPU Minimum: AVX2
Optimized: AVX512F, AVX512BF16
🟩 NVIDIA GPU
cuda
SM60+ minimum
SM75+ recommended
🟥 AMD GPU
cuda
CDNA: gfx908, gfx90a, gfx942, gfx950
RDNA: gfx103X, gfx110X, gfx115X, gfx120X
🟦 Intel GPU
xpu
Data Center GPU Max Series
Arc A-Series (Alchemist)
Arc B-Series (Battlemage)
🟪 Intel Gaudi
hpu
Gaudi2, Gaudi3 〰️
aarch64 ◻️ CPU ✅ *
🟩 NVIDIA GPU
cuda
SM75+
🪟 Windows 11 / Windows Server 2022+
x86-64 ◻️ CPU AVX2
🟩 NVIDIA GPU
cuda
SM60+ minimum
SM75+ recommended
🟥 AMD GPU
cuda
RDNA: gfx103X, gfx110X, gfx115X, gfx120X
🟦 Intel GPU
xpu
Arc A-Series (Alchemist)
Arc B-Series (Battlemage)
arm64 ◻️ CPU
🍎 macOS 14+
arm64 ◻️ CPU Apple M1+ ✅ *
⬜ Metal
mps
Apple M1+ ✅ * 🚧
* While supported, these marked features may lack in performance optimizations.

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

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.50.0-py3-none-win_arm64.whl (128.5 kB view details)

Uploaded Python 3Windows ARM64

bitsandbytes-0.50.0-py3-none-win_amd64.whl (38.0 MB view details)

Uploaded Python 3Windows x86-64

bitsandbytes-0.50.0-py3-none-manylinux_2_24_x86_64.whl (40.9 MB view details)

Uploaded Python 3manylinux: glibc 2.24+ x86-64

bitsandbytes-0.50.0-py3-none-manylinux_2_24_aarch64.whl (23.8 MB view details)

Uploaded Python 3manylinux: glibc 2.24+ ARM64

bitsandbytes-0.50.0-py3-none-macosx_14_0_arm64.whl (123.2 kB view details)

Uploaded Python 3macOS 14.0+ ARM64

File details

Details for the file bitsandbytes-0.50.0-py3-none-win_arm64.whl.

File metadata

  • Download URL: bitsandbytes-0.50.0-py3-none-win_arm64.whl
  • Upload date:
  • Size: 128.5 kB
  • Tags: Python 3, Windows ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for bitsandbytes-0.50.0-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 9c6f63f7f35c4425661256daca56664d2e4f05a5d230a9a148cb14df207bcca2
MD5 7a7354dd3d142d3122fc4353454f5ea3
BLAKE2b-256 b5e93cbda2ff7574753a493fd2bc27c1dc64cb51d97534ad2136f64e68d34344

See more details on using hashes here.

Provenance

The following attestation bundles were made for bitsandbytes-0.50.0-py3-none-win_arm64.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.50.0-py3-none-win_amd64.whl.

File metadata

  • Download URL: bitsandbytes-0.50.0-py3-none-win_amd64.whl
  • Upload date:
  • Size: 38.0 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for bitsandbytes-0.50.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 7f9ebf51d76a00341711cdd557af97555274b5aad3444975ff9927866a18bc11
MD5 c158e4e4ec195487904c6100a3d1ed6e
BLAKE2b-256 78407b2253f94ec8c6235606aa393f315d941d02c44f141b7bccae14202b3fea

See more details on using hashes here.

Provenance

The following attestation bundles were made for bitsandbytes-0.50.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.50.0-py3-none-manylinux_2_24_x86_64.whl.

File metadata

File hashes

Hashes for bitsandbytes-0.50.0-py3-none-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 173d137610468bec9cddbaa2e049254e97792657ab984e3e737bec1772c1668c
MD5 8e4e194ce67b100e0f820e723f3ece96
BLAKE2b-256 22089501f4fc830448a6862bd5313df94a7dd1ae678f4f81087b96569d4a6f8b

See more details on using hashes here.

Provenance

The following attestation bundles were made for bitsandbytes-0.50.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.50.0-py3-none-manylinux_2_24_aarch64.whl.

File metadata

File hashes

Hashes for bitsandbytes-0.50.0-py3-none-manylinux_2_24_aarch64.whl
Algorithm Hash digest
SHA256 824d931d8e77d7db09bb26d940268d36920e0757e2a2f49cce8766e309e13048
MD5 b42cc2c473e80044a13a8f0c060d007d
BLAKE2b-256 d23afe0f0c7186436038319f15156386e844abc2ae1e54b8cda3f53b81a96cb9

See more details on using hashes here.

Provenance

The following attestation bundles were made for bitsandbytes-0.50.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.

File details

Details for the file bitsandbytes-0.50.0-py3-none-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for bitsandbytes-0.50.0-py3-none-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 c6f482df4dc18c7c150246577025de40dd0935031ea10a1e4122599a525b39bb
MD5 127aa6dc69dbc47ede7378ef6976bbd1
BLAKE2b-256 8b6cb3c2a6b05e0fb06c6258b675436b2b090192450d7f283826e6323471e270

See more details on using hashes here.

Provenance

The following attestation bundles were made for bitsandbytes-0.50.0-py3-none-macosx_14_0_arm64.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