---
title: "Overview of natively supported quantization schemes in 🤗 Transformers"
description: "bitsandbytes and GPTQ (via auto-gptq), the two quantization schemes built into Transformers, trade off differently. bitsandbytes needs no calibration data, works on any model with nn.Linear layers across modalities, and lets LoRA adapters merge without degradation."
url: "https://swe.quest/articles/overview-of-natively-supported-quantization-schemes-in-transformers-c1bfbebb9330add3"
canonical: "https://huggingface.co/blog/overview-quantization-transformers"
source: "Hugging Face"
published: "2023-09-12"
difficulty: "medium"
kind: "Research"
reading_minutes: 9
tags: ["inference","model-training","llms","performance"]
---

# Overview of natively supported quantization schemes in 🤗 Transformers

A post on [Hugging Face](https://swe.quest/sources/hugging-face.md), published 2023-09-12, 9 min read, Research. Original: [https://huggingface.co/blog/overview-quantization-transformers](https://huggingface.co/blog/overview-quantization-transformers)

## Summary

bitsandbytes and GPTQ (via auto-gptq), the two quantization schemes built into Transformers, trade off differently. bitsandbytes needs no calibration data, works on any model with nn.Linear layers across modalities, and lets LoRA adapters merge without degradation. GPTQ supports serialization at any bit width, AMD GPUs and much faster text generation, up to 2x at batch size 4 with KV caching on Llama-2-7B. Benchmarks show bitsandbytes is faster for adapter fine-tuning and both lose little accuracy on Open LLM Leaderboard tasks, especially at 13B. The suggested workflow is to fine-tune adapters on a bitsandbytes base, merge them, then quantize the merged model with GPTQ for deployment.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Inference & serving](https://swe.quest/tags/inference.md) (AI & ML)
- [Model training](https://swe.quest/tags/model-training.md) (AI & ML)
- [LLMs](https://swe.quest/tags/llms.md) (AI & ML)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)

## Prerequisites

- LLM inference basics ([easy posts on Inference & serving](https://swe.quest/tags/inference.md?difficulty=easy))
- model quantization concepts ([easy posts on Inference & serving](https://swe.quest/tags/inference.md?difficulty=easy))
- LoRA/PEFT fine-tuning ([easy posts on Model training](https://swe.quest/tags/model-training.md?difficulty=easy))

## Keywords

bitsandbytes, GPTQ, AutoGPTQ, Hugging Face Transformers, Llama 2, QLoRA, ExLlama, PEFT

## Related posts

- [Making LLMs lighter with AutoGPTQ and transformers](https://swe.quest/articles/making-llms-lighter-with-autogptq-and-transformers-6a1ce27ee3288303.md): Hugging Face · 2023-08-23 · Medium · 10 min read · Inference & serving, LLMs, Performance engineering, Hardware
  AutoGPTQ is now integrated into Hugging Face Transformers (via Optimum), letting users quantize and run LLMs at 8, 4, 3 or 2 bits with the GPTQ post-training method.
- [Making LLMs even more accessible with bitsandbytes, 4-bit quantization and QLoRA](https://swe.quest/articles/making-llms-even-more-accessible-with-bitsandbytes-4-bit-quantization-and-qlora-7bc797d3e83b0ec6.md): Hugging Face · 2023-05-24 · Medium · 14 min read · Inference & serving, Model training, LLMs, Python
  bitsandbytes now integrates 4-bit quantization into Hugging Face transformers, letting most accelerate-loadable models (text, vision, multimodal) run in 4-bit and be fine-tuned via QLoRA, which backpropagates through a frozen 4-bit base model into LoRA adapters.
- [Transformers now runs llama.cpp quants](https://swe.quest/articles/transformers-now-runs-llama-cpp-quants-cff2353854049dc6.md): Hugging Face · 2026-09-22 · Medium · 11 min read · Inference & serving, LLMs, Python, Performance engineering
  Hugging Face transformers can now load GGUF (llama.cpp) quantized checkpoints via \`from\_pretrained(..., gguf\_file=...)\` and serve them through \`transformers serve\` with an OpenAI-compatible API.
- [Fine-tuning LLMs to 1.58bit: extreme quantization made easy](https://swe.quest/articles/fine-tuning-llms-to-1-58bit-extreme-quantization-made-easy-1f532a3df4c4d82f.md): Hugging Face · 2024-09-18 · Hard · 28 min read · Inference & serving, Model training, LLMs
  Existing LLMs can be fine-tuned into BitNet's 1.58-bit ternary format (-1, 0, 1) instead of pre-training from scratch, and a Llama3 8B fine-tuned this way on 100B tokens outperforms Llama 1 7B on MMLU.
- [Quanto: a PyTorch quantization backend for Optimum](https://swe.quest/articles/quanto-a-pytorch-quantization-backend-for-optimum-8330ba5aea428b63.md): Hugging Face · 2024-03-18 · Medium · 5 min read · Inference & serving, Python, Machine learning, Open source
  Quanto is a PyTorch quantization backend for Optimum that works in eager mode on any device (CPU, CUDA, MPS), supports int2/int4/int8/float8 weights and int8/float8 activations, and accelerates int8-int8, fp16-int4, bf16-int8 and bf16-int4 matmuls on CUDA.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
