Buckets:

mishig's picture
|
download
raw
2.37 kB
# AQLM
语言模型的加性量化([AQLM](https://huggingface.co/papers/2401.06118))会对多个权重进行联合量化,并利用它们之间的相互依赖性。AQLM 将 8 到 16 个权重组成的组表示为多个向量码的总和。
AQLM 还支持使用 [PEFT](https://huggingface.co/docs/peft) 库通过 [LoRA](https://huggingface.co/docs/peft/package_reference/lora) 进行微调,并且与 [torch.compile](https://pytorch.org/tutorials/intermediate/torch_compile_tutorial.html) 完全兼容,可实现更快的推理和训练速度。
运行以下命令,安装支持 GPU 和 CPU 推理与训练的 AQLM 库(含内核支持)。
```bash
pip install aqlm[gpu,cpu]
```
使用 [from_pretrained()](/docs/transformers/main/zh/main_classes/model#transformers.PreTrainedModel.from_pretrained) 加载 AQLM 量化模型。
```python
from transformers import AutoTokenizer, AutoModelForCausalLM
quantized_model = AutoModelForCausalLM.from_pretrained(
"ISTA-DASLab/Mixtral-8x7b-AQLM-2Bit-1x16-hf",
dtype="auto",
device_map="auto"
)
```
## 配置
AQLM 量化配置主要因使用的码本数量以及码本的比特大小而异。下面展示了最流行的配置和受支持的推理内核。
| Kernel | 码本数量 | 码本大小,位数 | 符号 | 准确率 | 加速 | 快速 GPU 推理 | 快速 CPU 推理 |
|---|---------------------|---------------------|----------|-------------|-------------|--------------------|--------------------|
| Triton | K | N | KxN | - | 最高约 0.7 倍 | ✅ | ❌ |
| CUDA | 1 | 16 | 1x16 | 最佳 | 最高约 1.3 倍 | ✅ | ❌ |
| CUDA | 2 | 8 | 2x8 | 好的 | 最高约 3.0 倍 | ✅ | ❌ |
| Numba | K | 8 | Kx8 | 好的 | 最高约 4.0 倍 | ❌ | ✅ |
## 资源
运行 AQLM 演示[notebook](https://colab.research.google.com/drive/1-xZmBRXT5Fm3Ghn4Mwa2KRypORXb855X?usp=sharing),了解如何量化模型、将量化后的模型推送到 Hub 等更多示例。
如需查看示例演示笔记本,请访问 AQLM [仓库](https://github.com/Vahe1994/AQLM)。

Xet Storage Details

Size:
2.37 kB
·
Xet hash:
1103fb745b9b171c278b806698082244b4ac2fbca670160e0a39f965ffcbfbfc

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.