"vscode:/vscode.git/clone" did not exist on "70056d1e9c53dc85d00690cd20fab22f26fbbc46"
README.md 7.61 KB
Newer Older
1
2
3
<p align="center"><img src="https://avatars.githubusercontent.com/u/175231607?s=200&v=4" alt=""></p>
<h1 align="center">bitsandbytes</h1>
<p align="center">
Matthew Douglas's avatar
Matthew Douglas committed
4
5
6
7
8
    <a href="https://github.com/bitsandbytes-foundation/bitsandbytes/main/LICENSE"><img alt="License" src="https://img.shields.io/github/license/bitsandbytes-foundation/bitsandbytes.svg?color=blue"></a>
    <a href="https://pepy.tech/project/bitsandbytes"><img alt="Downloads" src="https://static.pepy.tech/badge/bitsandbytes/month"></a>
    <a href="https://github.com/bitsandbytes-foundation/bitsandbytes/actions/workflows/tests.yml"><img alt="Nightly Unit Tests" src="https://img.shields.io/github/actions/workflow/status/bitsandbytes-foundation/bitsandbytes/tests.yml?logo=github&label=Nightly%20Tests"></a>
    <a href="https://github.com/bitsandbytes-foundation/bitsandbytes/releases"><img alt="GitHub Release" src="https://img.shields.io/github/v/release/bitsandbytes-foundation/bitsandbytes"></a>
    <a href="https://pypi.org/project/bitsandbytes/"><img alt="PyPI - Python Version" src="https://img.shields.io/pypi/pyversions/bitsandbytes"></a>
9
</p>
Tim Dettmers's avatar
Tim Dettmers committed
10

11
`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:
Titus's avatar
Titus committed
12

13
14
15
* 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.
16

Titus's avatar
Titus committed
17
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.
18

19
20
## System Requirements
bitsandbytes has the following minimum requirements for all platforms:
21

22
* Python 3.9+
23
* [PyTorch](https://pytorch.org/get-started/locally/) 2.3+
24
  * _Note: While we aim to provide wide backwards compatibility, we recommend using the latest version of PyTorch for the best experience._
25

26
#### Accelerator support:
27

Matthew Douglas's avatar
Matthew Douglas committed
28
<small>Note: this table reflects the status of the current development branch. For the latest stable release, see the
Matthew Douglas's avatar
Matthew Douglas committed
29
[document in the 0.48.0 tag](https://github.com/bitsandbytes-foundation/bitsandbytes/blob/0.48.0/README.md#accelerator-support).
Matthew Douglas's avatar
Matthew Douglas committed
30
31
32
33
34
35
36
37
</small>

##### Legend:
🚧 = In Development,
〰️ = Partially Supported,
✅ = Supported,
❌ = Not Supported

38
39
40
41
42
43
<table>
  <thead>
    <tr>
      <th>Platform</th>
      <th>Accelerator</th>
      <th>Hardware Requirements</th>
Matthew Douglas's avatar
Matthew Douglas committed
44
45
46
      <th>LLM.int8()</th>
      <th>QLoRA 4-bit</th>
      <th>8-bit Optimizers</th>
47
48
49
50
    </tr>
  </thead>
  <tbody>
    <tr>
Matthew Douglas's avatar
Matthew Douglas committed
51
      <td colspan="6">🐧 <strong>Linux, glibc >= 2.24</strong></td>
52
53
54
55
    </tr>
    <tr>
      <td align="right">x86-64</td>
      <td>◻️ CPU</td>
Matthew Douglas's avatar
Matthew Douglas committed
56
      <td>AVX2</td>
Matthew Douglas's avatar
Matthew Douglas committed
57
58
      <td></td>
      <td></td>
Matthew Douglas's avatar
Matthew Douglas committed
59
      <td></td>
60
61
62
    </tr>
    <tr>
      <td></td>
Matthew Douglas's avatar
Matthew Douglas committed
63
      <td>🟩 NVIDIA GPU <br><code>cuda</code></td>
64
      <td>SM60+ minimum<br>SM75+ recommended</td>
Matthew Douglas's avatar
Matthew Douglas committed
65
66
67
      <td></td>
      <td></td>
      <td></td>
68
69
70
    </tr>
    <tr>
      <td></td>
Matthew Douglas's avatar
Matthew Douglas committed
71
72
73
      <td>🟥 AMD GPU <br><code>cuda</code></td>
      <td>
        CDNA: gfx90a, gfx942<br>
Matthew Douglas's avatar
Matthew Douglas committed
74
        RDNA: gfx1100
Matthew Douglas's avatar
Matthew Douglas committed
75
      </td>
Matthew Douglas's avatar
Matthew Douglas committed
76
77
78
      <td>🚧</td>
      <td>🚧</td>
      <td>🚧</td>
79
80
81
    </tr>
    <tr>
      <td></td>
Matthew Douglas's avatar
Matthew Douglas committed
82
      <td>🟦 Intel GPU <br><code>xpu</code></td>
83
      <td>
Matthew Douglas's avatar
Matthew Douglas committed
84
85
        Data Center GPU Max Series<br>
        Arc A-Series (Alchemist)<br>
86
87
        Arc B-Series (Battlemage)
      </td>
88
89
      <td></td>
      <td></td>
90
      <td>〰️</td>
91
92
93
    </tr>
    <tr>
      <td></td>
Matthew Douglas's avatar
Matthew Douglas committed
94
      <td>🟪 Intel Gaudi <br><code>hpu</code></td>
Matthew Douglas's avatar
Matthew Douglas committed
95
      <td>Gaudi2, Gaudi3</td>
96
97
      <td></td>
      <td>〰️</td>
Matthew Douglas's avatar
Matthew Douglas committed
98
      <td></td>
99
100
101
102
103
    </tr>
    <tr>
      <td align="right">aarch64</td>
      <td>◻️ CPU</td>
      <td></td>
Matthew Douglas's avatar
Matthew Douglas committed
104
105
      <td></td>
      <td></td>
Matthew Douglas's avatar
Matthew Douglas committed
106
      <td></td>
107
108
109
    </tr>
    <tr>
      <td></td>
Matthew Douglas's avatar
Matthew Douglas committed
110
      <td>🟩 NVIDIA GPU <br><code>cuda</code></td>
Matthew Douglas's avatar
Matthew Douglas committed
111
      <td>SM75+</td>
Matthew Douglas's avatar
Matthew Douglas committed
112
113
114
      <td></td>
      <td></td>
      <td></td>
115
116
    </tr>
    <tr>
Matthew Douglas's avatar
Matthew Douglas committed
117
      <td colspan="6">🪟 <strong>Windows 11 / Windows Server 2019+</strong></td>
118
119
120
121
122
    </tr>
    <tr>
      <td align="right">x86-64</td>
      <td>◻️ CPU</td>
      <td>AVX2</td>
Matthew Douglas's avatar
Matthew Douglas committed
123
124
      <td></td>
      <td></td>
Matthew Douglas's avatar
Matthew Douglas committed
125
      <td></td>
126
127
128
    </tr>
    <tr>
      <td></td>
Matthew Douglas's avatar
Matthew Douglas committed
129
      <td>🟩 NVIDIA GPU <br><code>cuda</code></td>
130
      <td>SM60+ minimum<br>SM75+ recommended</td>
Matthew Douglas's avatar
Matthew Douglas committed
131
132
133
      <td></td>
      <td></td>
      <td></td>
134
135
136
    </tr>
    <tr>
      <td></td>
Matthew Douglas's avatar
Matthew Douglas committed
137
      <td>🟦 Intel GPU <br><code>xpu</code></td>
138
139
140
141
      <td>
        Arc A-Series (Alchemist) <br>
        Arc B-Series (Battlemage)
      </td>
142
143
      <td></td>
      <td></td>
144
      <td>〰️</td>
145
146
    </tr>
    <tr>
Matthew Douglas's avatar
Matthew Douglas committed
147
      <td colspan="6">🍎 <strong>macOS 14+</strong></td>
148
149
150
    </tr>
    <tr>
      <td align="right">arm64</td>
Matthew Douglas's avatar
Matthew Douglas committed
151
      <td>◻️ CPU</td>
152
      <td>Apple M1+</td>
Matthew Douglas's avatar
Matthew Douglas committed
153
154
155
      <td>🚧</td>
      <td>🚧</td>
      <td></td>
156
    </tr>
Matthew Douglas's avatar
Matthew Douglas committed
157
158
159
160
    <tr>
      <td></td>
      <td>⬜ Metal <br><code>mps</code></td>
      <td>Apple M1+</td>
Matthew Douglas's avatar
Matthew Douglas committed
161
162
163
      <td>🚧</td>
      <td>🚧</td>
      <td></td>
164
165
166
167
168
169
170
171
172
173
174
  </tbody>
</table>

## :book: Documentation
* [Official Documentation](https://huggingface.co/docs/bitsandbytes/main)
* 🤗 [Transformers](https://huggingface.co/docs/transformers/quantization/bitsandbytes)
* 🤗 [Diffusers](https://huggingface.co/docs/diffusers/quantization/bitsandbytes)
* 🤗 [PEFT](https://huggingface.co/docs/peft/developer_guides/quantization#quantize-a-model)

## :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.
Tim Dettmers's avatar
Tim Dettmers committed
175

Matthew Douglas's avatar
Matthew Douglas committed
176
177
178
<kbd><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></kbd>
&nbsp;
<kbd><a href="https://intel.com" target="_blank"><img width="100" src="https://avatars.githubusercontent.com/u/17888862?s=100&v=4" alt="Intel"></a></kbd>
179
180

## License
Titus's avatar
Titus committed
181
`bitsandbytes` is MIT licensed.
Tim Dettmers's avatar
Tim Dettmers committed
182
183

We thank Fabio Cannizzo for his work on [FastBinarySearch](https://github.com/fabiocannizzo/FastBinarySearch) which we use for CPU quantization.
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219

## How to cite us
If you found this library useful, please consider citing our work:

### QLoRA

```bibtex
@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()

```bibtex
@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

```bibtex
@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}
}
```