---
title: "Quanto: a PyTorch quantization backend for Optimum"
description: "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."
url: "https://swe.quest/articles/quanto-a-pytorch-quantization-backend-for-optimum-8330ba5aea428b63"
canonical: "https://huggingface.co/blog/quanto-introduction"
source: "Hugging Face"
published: "2024-03-18"
difficulty: "medium"
kind: "Announcement"
reading_minutes: 5
tags: ["inference","python","machine-learning","open-source"]
---

# Quanto: a PyTorch quantization backend for Optimum

A post on [Hugging Face](https://swe.quest/sources/hugging-face.md), published 2024-03-18, 5 min read, Announcement. Original: [https://huggingface.co/blog/quanto-introduction](https://huggingface.co/blog/quanto-introduction)

## Summary

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. The workflow runs from dynamic quantization through optional activation calibration and quantization-aware training to freezing integer weights, then serializing with safetensors plus a quantization map for reloading via requantize. It integrates with transformers through QuantoConfig, works across modalities such as Whisper, and is torch.compile-friendly when activations are left unquantized.

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)
- [Python](https://swe.quest/tags/python.md) (Languages)
- [Machine learning](https://swe.quest/tags/machine-learning.md) (AI & ML)
- [Open source](https://swe.quest/tags/open-source.md) (Engineering practices)

## Prerequisites

- PyTorch basics
- model quantization concepts ([easy posts on Inference & serving](https://swe.quest/tags/inference.md?difficulty=easy))
- Hugging Face transformers

## Keywords

Quanto, Optimum, PyTorch, transformers, Safetensors, float8, Llama 3.1

## Related posts

- [Introducing Optimum: The Optimization Toolkit for Transformers at Scale](https://swe.quest/articles/introducing-optimum-the-optimization-toolkit-for-transformers-at-scale-a074b17981960e1a.md): Hugging Face · 2021-09-14 · Easy · 4 min read · Inference & serving, Machine learning, Open source, Hardware
  Optimum is a new open source Hugging Face library that targets production performance for Transformer models by wrapping hardware-specific acceleration tooling built with hardware partners.
- [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.
- [Accelerated Inference with Optimum and Transformers Pipelines](https://swe.quest/articles/accelerated-inference-with-optimum-and-transformers-pipelines-9ff6245f88a35ca0.md): Hugging Face · 2022-05-10 · Medium · 12 min read · Inference & serving, Python, Performance engineering, Machine learning
  Optimum 1.2 adds inference support via ONNX Runtime with ORTModelForXxx classes that drop into Hugging Face Transformers pipelines in place of AutoModelForXxx.
- [Optimize and deploy with Optimum-Intel and OpenVINO GenAI](https://swe.quest/articles/optimize-and-deploy-with-optimum-intel-and-openvino-genai-bbd6caef1a74949e.md): Hugging Face · 2024-09-20 · Medium · 6 min read · Inference & serving, LLMs, C & C++, Python
  Hugging Face Transformers LLMs can be exported to OpenVINO IR with Optimum-Intel, quantized with NNCF, and deployed through the lightweight OpenVINO GenAI LLMPipeline from Python or C++.
- [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.

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)
