Buckets:

mishig's picture
|
download
raw
2.45 kB
# EETQ
[Easy and Efficient Quantization for Transformers (EETQ)](https://github.com/NetEase-FuXi/EETQ) lượng tử hóa trọng số sang int8 với một hệ số tỷ lệ cho mỗi kênh đầu ra, và thực hiện phép nhân ma trận với trọng số int8 và kích hoạt 16-bit. Sử dụng phương pháp này cho lượng tử hóa chỉ trọng số 8-bit trên GPU NVIDIA mà không cần dữ liệu hiệu chuẩn.
Bảng dưới đây tóm tắt những gì EETQ hỗ trợ trong Transformers.
| | |
|---|---|
| Cấu hình | [EetqConfig](/docs/transformers/main/vi/main_classes/quantization#transformers.EetqConfig) |
| `quant_method` | `eetq` |
| Quy trình làm việc | Lượng tử hóa khi tải |
| Bits | 8 |
| Phần cứng | CUDA |
| Lưu | ✅ |
| Tinh chỉnh | ✅ |
| Tự động biên dịch | ❌ |
## Cài đặt các kernel EETQ
Transformers tải các kernel EETQ từ kho [kernels-community/quantization-eetq](https://huggingface.co/kernels-community/quantization-eetq) trên Hub, vì vậy bạn không cần phải build EETQ. Cài đặt các thư viện [kernels](https://huggingface.co/docs/kernels/index) và [Accelerate](https://huggingface.co/docs/accelerate/index).
```bash
pip install -U "transformers[kernels]" accelerate
```
## Lượng tử hóa một mô hình bằng EETQ
Tạo một [EetqConfig](/docs/transformers/main/vi/main_classes/quantization#transformers.EetqConfig) và truyền nó vào [from_pretrained()](/docs/transformers/main/vi/main_classes/model#transformers.PreTrainedModel.from_pretrained). `weights` đặt kiểu dữ liệu của trọng số và chỉ chấp nhận `"int8"`, đây là giá trị mặc định.
```py
import torch
from transformers import AutoModelForCausalLM, EetqConfig
quantization_config = EetqConfig("int8")
model = AutoModelForCausalLM.from_pretrained(
"Qwen/Qwen3-8B",
quantization_config=quantization_config,
dtype=torch.float16,
device_map="cuda",
)
```
Tải mô hình với `dtype=torch.float16` để đạt hiệu quả tốt nhất. EETQ lưu trữ các thang đo của nó ở fp16.
## Hạn chế
- EETQ cần một GPU CUDA. Việc tải mà không có GPU này sẽ gây ra `RuntimeError`.
- EETQ không thể offload sang CPU hoặc disk. Một `device_map` bao gồm `"cpu"` hoặc `"disk"` sẽ gây ra `ValueError`.
## Tài nguyên
- [EETQ](https://github.com/NetEase-FuXi/EETQ) kho lưu trữ

Xet Storage Details

Size:
2.45 kB
·
Xet hash:
02373364dda51b89280a532a4f782fd0ec88e198724e651813b8665b56e6020d

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