You are viewing main version, which requires installation from source. If you'd like
regular pip install, checkout the latest stable version (v5.22.2).
EETQ
Easy & Efficient Quantization for Transformers (EETQ) 库支持针对 NVIDIA GPU 的 int8 仅权重逐通道量化。它使用了来自 FasterTransformer 和 TensorRT-LLM 的高性能 GEMM 和 GEMV 内核。注意力层通过 FlashAttention2 进行了优化。无需校准数据集,且模型无需预先量化。得益于逐通道量化,精度损失可以忽略不计。
EETQ 还支持使用 PEFT 进行微调。
从发布页面或源代码安装 EETQ。EETQ 需要 CUDA 11.4 或更高版本。
发布页面
源代码
pip install --no-cache-dir https://github.com/NetEase-FuXi/EETQ/releases/download/v1.0.0/EETQ-1.0.0+cu121+torch2.1.2-cp310-cp310-linux_x86_64.whl
git clone https://github.com/NetEase-FuXi/EETQ.git
cd EETQ/
git submodule update --init --recursive
pip install .通过在 EetqConfig 中定义量化数据类型,即可在运行时对模型进行量化。
from transformers import AutoModelForCausalLM, EetqConfig
quantization_config = EetqConfig("int8")
model = AutoModelForCausalLM.from_pretrained(
"meta-llama/Llama-3.1-8B",
dtype="auto",
device_map="auto",
quantization_config=quantization_config
)使用 save_pretrained() 保存量化后的模型,以便之后通过 from_pretrained() 再次加载使用。
quant_path = "/path/to/save/quantized/model"
model.save_pretrained(quant_path)
model = AutoModelForCausalLM.from_pretrained(quant_path, device_map="auto")