FP-Quant

FP-Quant

FP-Quant는 NVIDIA Blackwell 세대 GPU를 위해 설계된 양자화 알고리즘 계열입니다. MXFP4와 NVFP4 데이터 타입에서 LLM의 효율적인 사후 학습 양자화(PTQ)와 양자화 인지 학습(QAT)을 가능하게 하는 것이 목표입니다.

출처: 문서

본문

FP-Quant는 NVIDIA Blackwell 세대 GPU를 위해 설계된 양자화 알고리즘 계열입니다. 목표는 MXFP4와 NVFP4 데이터 타입에서 LLM의 효율적인 사후 학습 양자화(PTQ)와 양자화 인지 학습(QAT)을 가능하게 하는 것입니다.

이 통합은 Bridging the Gap Between Promise and Performance for Microscaling FP4 Quantization 사전 인쇄본과 함께 제공됩니다.

현재 QAT는 pseudoquantization=True일 때만 지원됩니다. 모델은 quantization_config=FPQuantConfig()로 즉시 양자화할 수 있습니다.

from transformers import AutoModelForCausalLM, AutoTokenizer, FPQuantConfig
import torch

model = AutoModelForCausalLM.from_pretrained(
    "qwen/Qwen3-8B",
    quantization_config=FPQuantConfig(),
    device_map="auto",
    dtype=torch.bfloat16,
)

또는 더 나은 품질을 위해 GPTQ로 전처리할 수 있습니다( FP Format Quantization Harness 참고).

FPQuantConfig(forward_dtype="mxfp4")로 MXFP4와 NVFP4 중에서 선택할 수 있습니다. NVFP4는 더 좋은 품질이지만 메모리를 조금 더 사용합니다.

커널을 실행하려면 Blackwell 세대 GPU가 필요합니다. FP-Quant의 런타임 지원은 QuTLASS 라이브러리와 가벼운 PyTorch 인터페이스 라이브러리 fp_quant를 통해 구현됩니다. 전자는 소스에서 설치하고 후자는 pip install fp_quant로 설치할 것을 권장합니다.

Blackwell 세대 GPU가 없는 사용자는 QuTLASS를 설치하지 않고 quantization_config=FPQuantConfig(pseudoquantization=True)로 이 방법을 사용할 수 있습니다. 이 경우 속도 향상은 없지만 양자화 효과를 완전히 에뮬레이션할 수 있습니다.

[!TIP] 공식 ISTA-DASLab 컬렉션에서 FP-Quant로 사전 양자화된 모델을 찾아볼 수 있습니다.

torch.compile

FP-Quant는 torch.compile과 완전히 호환됩니다.

import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, FPQuantConfig

model = AutoModelForCausalLM.from_pretrained(
    "qwen/Qwen3-8B",
    quantization_config=FPQuantConfig(),
    device_map="auto",
    dtype=torch.bfloat16,
)

model.forward = torch.compile(model.forward, mode="max-autotune", fullgraph=True)

Speedups

FP-Quant는 현재 매우 큰 배치 크기 처리에서 가장 좋은 성능을 냅니다.

속도 향상에 대해서는 QuTLASS README를 참고하세요.

더 알아보기 (Learn more)