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.

以下の表は、TransformersにおけるEETQのサポート内容をまとめます。

設定EetqConfig
quant_methodeetq
ワークフロー読み込み時に量子化
ビット8
ハードウェアCUDA
保存✅
ファインチューニング✅
自動コンパイル❌

EETQカーネルをインストール

Transformers は Hub 上の kernels-community/quantization-eetq リポジトリから EETQ カーネルをダウンロードするため、EETQ のビルドは不要です。kernels と Accelerate ライブラリをインストールしてください。

pip install -U "transformers[kernels]" accelerate

EETQでモデルを量子化

EetqConfig を作成し、from_pretrained() に渡します。weights は重みの dtype を設定し、デフォルトである"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が必要です。GPUなしで読み込むとRuntimeErrorが発生します。
  • EETQはCPUやディスクへのオフロードに対応していません。"cpu"または"disk"を含むdevice_mapを指定すると、ValueErrorが発生します。

リソース

Update on GitHub