Scripts2026年5月21日·1 分钟阅读

AutoGPTQ — Easy-to-Use GPTQ Quantization for Large Language Models

AutoGPTQ is a Python library that simplifies GPTQ-based weight quantization for large language models. It reduces model sizes by 4x with minimal accuracy loss, making it possible to run large models on consumer GPUs for inference.

Agent 就绪

这个资产可以被 Agent 直接读取和安装

TokRepo 同时提供通用 CLI 命令、安装契约、metadata JSON、按适配器生成的安装计划和原始内容链接,方便 Agent 判断适配度、风险和下一步动作。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
AutoGPTQ Overview
通用 CLI 安装命令
npx tokrepo install 80f47f36-54af-11f1-9bc6-00163e2b0d79

Introduction

AutoGPTQ implements the GPTQ post-training quantization algorithm with a developer-friendly API. It compresses pretrained language model weights from 16-bit to 4-bit or 3-bit integers using a one-shot calibration process, enabling models that previously required data center GPUs to run on consumer hardware.

What AutoGPTQ Does

  • Quantizes pretrained LLM weights to 4-bit or 3-bit using the GPTQ algorithm
  • Provides simple Python APIs for both quantization and inference
  • Supports loading and running models quantized by the community from Hugging Face Hub
  • Integrates with Hugging Face transformers, PEFT, and optimum for seamless workflows
  • Uses optimized CUDA kernels for fast inference on quantized models

Architecture Overview

AutoGPTQ performs layer-by-layer quantization using a small calibration dataset. For each transformer layer, it computes the Hessian matrix of weight activations, then solves for optimal quantized weights that minimize reconstruction error. The quantized weights are stored in a custom format with group-wise scaling factors. At inference time, dedicated CUDA kernels dequantize weights on the fly during matrix multiplication, maintaining throughput while using a fraction of the memory.

Self-Hosting & Configuration

  • Install via pip with CUDA support for GPU-accelerated quantization and inference
  • Prepare a small calibration dataset (128-256 samples) representative of your use case
  • Configure quantization parameters: bits (3 or 4), group_size, and description act order
  • Save quantized models in a format compatible with Hugging Face Hub for sharing
  • Load quantized models directly in transformers using the GPTQ backend

Key Features

  • One-shot quantization requires only a small calibration set, no retraining needed
  • 4-bit models use roughly 4x less VRAM than their 16-bit counterparts
  • Marlin kernel integration provides fast int4 x fp16 matrix multiplication
  • Direct compatibility with Hugging Face transformers for loading quantized models
  • Group-wise quantization with configurable group sizes for accuracy-size tradeoffs

Comparison with Similar Tools

  • QLoRA — quantizes for training with LoRA adapters; AutoGPTQ quantizes for efficient inference
  • AWQ — activation-aware weight quantization; AutoGPTQ uses Hessian-based error minimization
  • GGUF/llama.cpp — CPU-focused quantized inference; AutoGPTQ targets CUDA GPUs with optimized kernels
  • GPTQModel — actively maintained fork of AutoGPTQ with additional model support and bug fixes

FAQ

Q: How much accuracy is lost with 4-bit quantization? A: GPTQ typically preserves over 99% of the original model quality on standard benchmarks when using 4-bit quantization with 128-group size.

Q: How long does quantization take? A: Quantizing a 7B model takes approximately 10-20 minutes on a modern GPU. Larger models scale roughly linearly with parameter count.

Q: Can I fine-tune a GPTQ-quantized model? A: Yes, GPTQ-quantized models work with QLoRA and PEFT for parameter-efficient fine-tuning on top of the compressed base weights.

Q: Is AutoGPTQ still maintained? A: The original repository is in maintenance mode. GPTQModel is the recommended actively developed successor for new projects.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产