Transformers documentation

EETQ

Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

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_methodeetq
سير العملQuantize while loading
بت8
الأجهزةCUDA
حفظ✅
ضبط✅
التجميع التلقائي❌

تثبيت نواة EETQ

تنزّل مكتبة Transformers نواة EETQ من مستودع kernels-community/quantization-eetq على Hub، لذا لا حاجة إليك لبناء 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. يؤدي التحميل دون وجوده إلى حدوث RuntimeError.
  • لا يمكن لـ EETQ تفريغ الأحمال إلى وحدة المعالجة المركزية (CPU) أو القرص. يؤدي استخدام device_map يتضمن "cpu" أو "disk" إلى رفع ValueError.

الموارد

Update on GitHub