bitsandbytes 通过 k 位量化技术,为 PyTorch 提供了可访问的大型语言模型支持。我们提供了三大核心功能,可显著降低推理和训练过程中的内存消耗:
该库通过 bitsandbytes.nn.Linear8bitLt 和 bitsandbytes.nn.Linear4bit 提供了 8 位和 4 位操作的量化原语,并通过 bitsandbytes.optim 模块提供了 8 位优化器。
bitsandbytes 对所有平台有以下最低要求:
注意:此表反映了当前开发分支的状态。有关最新稳定版本的信息,请参阅 0.49.2 标签中的文档。
🚧 = 开发中,
〰️ = 部分支持,
✅ = 支持,
🐢 = 支持慢速实现,
❌ = 不支持
| 平台 | 加速器 | 硬件要求 | LLM.int8() | QLoRA 4-bit | 8-bit Optimizers |
|---|---|---|---|---|---|
| 🐧 Linux, glibc >= 2.24 | |||||
| x86-64 | ◻️ CPU | 最低要求:AVX2 优化要求:AVX512F, AVX512BF16 |
✅ | ✅ | ❌ |
🟩 NVIDIA GPU cuda |
最低要求:SM60+ 推荐:SM75+ |
✅ | ✅ | ✅ | |
🟥 AMD GPU cuda |
CDNA: gfx90a, gfx942, gfx950 RDNA: gfx1100, gfx1101, gfx1150, gfx1151, gfx1200, gfx1201 |
✅ | ✅ | ✅ | |
🟦 Intel GPU xpu |
数据中心 GPU Max 系列 Arc A 系列(炼金术士) Arc B 系列(战法师) |
✅ | ✅ | 〰️ | |
🟪 Intel Gaudi hpu |
Gaudi2, Gaudi3 | ✅ | 〰️ | ❌ | |
| aarch64 | ◻️ CPU | ✅ | ✅ | ❌ | |
🟩 NVIDIA GPU cuda |
SM75+ | ✅ | ✅ | ✅ | |
| 🪟 Windows 11 / Windows Server 2022+ | |||||
| x86-64 | ◻️ CPU | AVX2 | ✅ | ✅ | ❌ |
🟩 NVIDIA GPU cuda |
最低要求:SM60+ 推荐:SM75+ |
✅ | ✅ | ✅ | |
🟦 Intel GPU xpu |
Arc A 系列(炼金术士) Arc B 系列(战法师) |
✅ | ✅ | 〰️ | |
| 🍎 macOS 14+ | |||||
| arm64 | ◻️ CPU | Apple M1+ | ✅ | ✅ | ❌ |
⬜ Metal mps |
Apple M1+ | 🐢 | 🐢 | ❌ | |
bitsandbytes 的持续维护和开发得益于我们赞助商的慷慨支持。他们的贡献帮助我们能够不断改进项目,并向社区提供有价值的更新。
bitsandbytes 采用 MIT 许可证。
如果您觉得这个库有用,请考虑引用我们的工作:
@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}
}
@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}
}
@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}
}