Transformers documentation

FBGEMM

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

FBGEMM

FBGEMM (Facebook GEneral Matrix Multiplication)는 작은 배치 크기에 최적화된 저정밀도 행렬 곱셈 라이브러리로, 행 단위 양자화 및 아웃라이어 인식 양자화와 같은 정확도 손실 최소화 기법을 지원합니다. FBGEMM을 사용하면 모델의 가중치를 8-bits/channel로, 활성화 값을 8-bits/token으로 양자화할 수 있습니다(또는 fp8 또는 w8a8이라고도 함).

H100과 같은 compute capability 9+를 지원하는 GPU가 필요합니다.

최신 버전을 사용하려면 아래 명령어로 FBGEMM_GPU 패키지를 설치하세요.

pip install --upgrade accelerate fbgemm-gpu torch

설치 문제를 겪고 있다면 nightly release 설치를 시도해 보세요.

FbgemmFp8Config를 생성하여 from_pretrained()에 전달하면 모델을 fp8로 양자화할 수 있습니다.

from transformers import FbgemmFp8Config, AutoModelForCausalLM

quantization_config = FbgemmFp8Config()
quantized_model = AutoModelForCausalLM.from_pretrained(
    "meta-llama/Meta-Llama-3-8B",
    dtype="auto",
    device_map="auto",
    quantization_config=quantization_config
)

save_pretrained()와 from_pretrained()를 사용하면 양자화된 모델을 저장하고 로드할 수 있습니다.

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

리소스

FBGEMM에 대한 자세한 내용은 최고 수준의 서버 측 추론을 위한 FBGEMM 오픈소싱 블로그 포스트를 참고하세요.

Update on GitHub