|
1 | | -# `bitsandbytes` |
| 1 | +<p align="center"><img src="https://avatars.githubusercontent.com/u/175231607?s=200&v=4" alt=""></p> |
| 2 | +<h1 align="center">bitsandbytes</h1> |
| 3 | +<p align="center"> |
| 4 | + <a href="https://github.com/bitsandbytes-foundation/bitsandbytes/main/LICENSE"> |
| 5 | + <img alt="License" src="https://img.shields.io/github/license/bitsandbytes-foundation/bitsandbytes.svg?color=blue"> |
| 6 | + </a> |
| 7 | + <a href="https://pepy.tech/project/bitsandbytes"> |
| 8 | + <img alt="Downloads" src="https://static.pepy.tech/badge/bitsandbytes/month"> |
| 9 | + </a> |
| 10 | + <a href="https://github.com/bitsandbytes-foundation/bitsandbytes/actions/workflows/tests.yml"> |
| 11 | + <img alt="Nightly Unit Tests" src="https://img.shields.io/github/actions/workflow/status/bitsandbytes-foundation/bitsandbytes/tests.yml?logo=github&label=Nightly%20Tests"> |
| 12 | + </a> |
| 13 | + <a href="https://github.com/bitsandbytes-foundation/bitsandbytes/releases"> |
| 14 | + <img alt="GitHub Release" src="https://img.shields.io/github/v/release/bitsandbytes-foundation/bitsandbytes"> |
| 15 | + </a> |
| 16 | + <a href="https://pypi.org/project/bitsandbytes/"> |
| 17 | + <img alt="PyPI - Python Version" src="https://img.shields.io/pypi/pyversions/bitsandbytes"> |
| 18 | + </a> |
| 19 | +</p> |
2 | 20 |
|
3 | | -[](https://pepy.tech/project/bitsandbytes) [](https://pepy.tech/project/bitsandbytes) [](https://pepy.tech/project/bitsandbytes) |
| 21 | +`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: |
4 | 22 |
|
5 | | -The `bitsandbytes` library is a lightweight Python wrapper around CUDA custom functions, in particular 8-bit optimizers, matrix multiplication (LLM.int8()), and 8 & 4-bit quantization functions. |
| 23 | +* 8-bit optimizers uses block-wise quantization to maintain 32-bit performance at a small fraction of the memory cost. |
| 24 | +* 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. |
| 25 | +* 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. |
6 | 26 |
|
7 | 27 | 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. |
8 | 28 |
|
9 | | -There are ongoing efforts to support further hardware backends, i.e. Intel CPU + GPU, AMD GPU, Apple Silicon, hopefully NPU. |
| 29 | +## System Requirements |
| 30 | +bitsandbytes has the following minimum requirements for all platforms: |
10 | 31 |
|
11 | | -**Please head to the official documentation page:** |
| 32 | +* Python 3.9+ |
| 33 | +* [PyTorch](https://pytorch.org/get-started/locally/) 2.2+ |
12 | 34 |
|
13 | | -**[https://huggingface.co/docs/bitsandbytes/main](https://huggingface.co/docs/bitsandbytes/main)** |
| 35 | +Platform specific requirements are detailed below: |
| 36 | +#### Linux x86-64 |
| 37 | +* glibc >= 2.24 |
14 | 38 |
|
15 | | -## License |
| 39 | +#### Windows x86-64 |
| 40 | +* Windows Server 2019+ or Windows 11+ |
| 41 | + |
| 42 | + |
| 43 | +## :book: Documentation |
| 44 | +* [Official Documentation](https://huggingface.co/docs/bitsandbytes/main) |
| 45 | +* 🤗 [Transformers](https://huggingface.co/docs/transformers/quantization/bitsandbytes) |
| 46 | +* 🤗 [Diffusers](https://huggingface.co/docs/diffusers/quantization/bitsandbytes) |
| 47 | +* 🤗 [PEFT](https://huggingface.co/docs/peft/developer_guides/quantization#quantize-a-model) |
| 48 | + |
| 49 | +## :heart: Sponsors |
| 50 | +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. |
16 | 51 |
|
| 52 | +<a href="https://hf.co" target="_blank"><img width="100" src="https://huggingface.co/datasets/huggingface/brand-assets/resolve/main/hf-logo.svg" alt="Hugging Face"></a> |
| 53 | + |
| 54 | +## License |
17 | 55 | `bitsandbytes` is MIT licensed. |
18 | 56 |
|
19 | 57 | We thank Fabio Cannizzo for his work on [FastBinarySearch](https://github.com/fabiocannizzo/FastBinarySearch) which we use for CPU quantization. |
| 58 | + |
| 59 | +## How to cite us |
| 60 | +If you found this library useful, please consider citing our work: |
| 61 | + |
| 62 | +### QLoRA |
| 63 | + |
| 64 | +```bibtex |
| 65 | +@article{dettmers2023qlora, |
| 66 | + title={Qlora: Efficient finetuning of quantized llms}, |
| 67 | + author={Dettmers, Tim and Pagnoni, Artidoro and Holtzman, Ari and Zettlemoyer, Luke}, |
| 68 | + journal={arXiv preprint arXiv:2305.14314}, |
| 69 | + year={2023} |
| 70 | +} |
| 71 | +``` |
| 72 | + |
| 73 | +### LLM.int8() |
| 74 | + |
| 75 | +```bibtex |
| 76 | +@article{dettmers2022llmint8, |
| 77 | + title={LLM.int8(): 8-bit Matrix Multiplication for Transformers at Scale}, |
| 78 | + author={Dettmers, Tim and Lewis, Mike and Belkada, Younes and Zettlemoyer, Luke}, |
| 79 | + journal={arXiv preprint arXiv:2208.07339}, |
| 80 | + year={2022} |
| 81 | +} |
| 82 | +``` |
| 83 | + |
| 84 | +### 8-bit Optimizers |
| 85 | + |
| 86 | +```bibtex |
| 87 | +@article{dettmers2022optimizers, |
| 88 | + title={8-bit Optimizers via Block-wise Quantization}, |
| 89 | + author={Dettmers, Tim and Lewis, Mike and Shleifer, Sam and Zettlemoyer, Luke}, |
| 90 | + journal={9th International Conference on Learning Representations, ICLR}, |
| 91 | + year={2022} |
| 92 | +} |
| 93 | +``` |
0 commit comments