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)는 가중치를 출력 채널당 하나의 스케일로 int8로 양자화하고, int8 가중치와 16-bit 활성화로 matmul을 실행합니다. 교정 데이터 없이 NVIDIA GPU에서 8-bit weight-only 양자화를 수행할 때 사용하세요.

아래 표는 Transformers에서 EETQ가 지원하는 내용을 요약합니다.

설정EetqConfig
quant_methodeetq
워크플로Quantize while loading
Bits8
하드웨어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가 필요합니다. CUDA GPU 없이 로드하면 RuntimeError가 발생합니다.
  • EETQ는 CPU 또는 디스크로 오프로드할 수 없습니다. "cpu" 또는 "disk"를 포함하는 device_map은 ValueError를 발생시킵니다.

리소스

Update on GitHub