Transformers documentation
EETQ
시작하기
기본 클래스
모델
Preprocessors
추론
Pipeline API
Generate API
최적화
모델과 대화하기
서빙
학습
하드웨어
양자화
생태계 통합
리소스
API
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).
EETQ
Easy & Efficient Quantization for Transformers (EETQ) 라이브러리는 NVIDIA GPU를 위한 int8 weight-only per-channel 양자화를 지원합니다. FasterTransformer와 TensorRT-LLM의 고성능 GEMM 및 GEMV 커널을 사용합니다. 어텐션 레이어는 FlashAttention2로 최적화되어 있습니다. 보정 데이터셋이 필요하지 않으며, 모델을 사전 양자화할 필요도 없습니다. per-channel 양자화 덕분에 정확도 저하는 무시할 수 있는 수준입니다.
EETQ는 PEFT를 통한 fine-tuning을 추가로 지원합니다.
EETQ는 릴리스 페이지 또는 소스 코드에서 설치할 수 있습니다. EETQ에는 CUDA 11.4 이상이 필요합니다.
릴리스 페이지
소스 코드
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
git clone https://github.com/NetEase-FuXi/EETQ.git
cd EETQ/
git submodule update --init --recursive
pip install .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
)양자화된 모델을 save_pretrained()로 저장하여 from_pretrained()로 다시 사용할 수 있도록 합니다.
quant_path = "/path/to/save/quantized/model"
model.save_pretrained(quant_path)
model = AutoModelForCausalLM.from_pretrained(quant_path, device_map="auto")