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

Easy & Efficient Quantization for Transformers (EETQ) kütüphanesi, NVIDIA GPU'lar için int8 ağırlık-bazlı kanal başına kuantizasyonu destekler. FasterTransformer ve TensorRT-LLM'den yüksek performanslı GEMM ve GEMV çekirdeklerini kullanır. Dikkat katmanı FlashAttention2 ile optimize edilmiştir. Kalibrasyon veri seti gerekmez ve modelin önceden kuantize edilmesine ihtiyaç yoktur. Kanal başına kuantizasyon sayesinde doğruluk kaybı ihmal edilebilir düzeydedir.

EETQ ayrıca PEFT ile ince ayarı destekler.

EETQ'yi sürüm sayfasından veya kaynak kodundan yükleyin. EETQ için CUDA 11.4+ gereklidir.

sürüm sayfası
kaynak kod
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

EetqConfig içindeki kuantizasyon veri türünü tanımlayarak bir modeli anlık olarak kuantize edin.

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
)

Kantize edilmiş modeli from_pretrained() ile yeniden kullanılabilmesi için save_pretrained() ile kaydedin.

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