Buckets:

mishig's picture
|
download
raw
2.09 kB

EETQ

Easy and Efficient Quantization for Transformers (EETQ) quantizes weights to int8 with one scale per output channel, and runs the matmul with int8 weights and 16-bit activations. Use it for 8-bit weight-only quantization on NVIDIA GPUs without calibration data.

下表总结了 EETQ 在 Transformers 中的支持情况。

配置 EetqConfig
quant_method eetq
工作流 加载时量化
位 8
硬件 CUDA
保存 ✅
微调 ✅
自动编译 ❌

安装 EETQ 内核

Transformers 会从 Hub 上的 kernels-community/quantization-eetq 仓库下载 EETQ 内核,因此您无需自行构建 EETQ。请安装 kernels 和 Accelerate 库。

pip install -U "transformers[kernels]" accelerate

使用 EETQ 量化模型

创建一个 EetqConfig 并将其传递给 from_pretrained()。weights 用于设置权重的数据类型,且仅接受 "int8",这也是默认值。

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",
)

使用 dtype=torch.float16 加载模型以获得最佳效率。EETQ 以 fp16 格式存储其缩放因子。

局限性

  • EETQ 需要 CUDA GPU。在没有 CUDA GPU 的情况下加载会引发 RuntimeError。
  • EETQ 无法卸载到 CPU 或磁盘。包含 "cpu" 或 "disk" 的 device_map 会引发 ValueError。

资源

Xet Storage Details

Size:
2.09 kB
·
Xet hash:
ec2f155f8086348debc54fba3adb8d5f030aa60ad23cfe966bbe09b7e6276488

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