Transformers documentation

EETQ

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).
Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

EETQ

Thư viện Easy & Efficient Quantization for Transformers (EETQ) hỗ trợ lượng tử hóa chỉ trọng số int8 theo kênh cho GPU NVIDIA. Nó sử dụng các kernel GEMM và GEMV hiệu năng cao từ FasterTransformer và TensorRT-LLM. Lớp attention được tối ưu hóa bằng FlashAttention2. Không yêu cầu bộ dữ liệu hiệu chuẩn và mô hình không cần được lượng tử hóa trước. Sự suy giảm độ chính xác là không đáng kể nhờ vào lượng tử hóa theo kênh.

EETQ hỗ trợ thêm việc tinh chỉnh với PEFT.

Cài đặt EETQ từ trang phát hành hoặc mã nguồn. EETQ yêu cầu CUDA 11.4 trở lên.

trang phát hành
mã nguồn
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

Thực hiện lượng hóa mô hình ngay khi chạy bằng cách định nghĩa kiểu dữ liệu lượng hóa trong 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
)

Lưu mô hình đã lượng tử hóa bằng save_pretrained() để có thể tái sử dụng bằng from_pretrained().

quant_path = "/path/to/save/quantized/model"
model.save_pretrained(quant_path)
model = AutoModelForCausalLM.from_pretrained(quant_path, device_map="auto")
Update on GitHub