New Tool Radar

AI Concepts

How to Choose a Quantization Format by Whether the Model Will Run on CPU or GPU

Check the hardware table for your target device first, pick a format that runs there, and only then compare quality and speed.

Schematic with three steps: Check the hardware table for your device; Check the memory budget on that device; Test the format on the target device.

A quantized format is only useful if it runs on the hardware you have. Bitsandbytes, for example, is supported on NVIDIA GPUs for CUDA versions 11.8 to 13.0, Intel XPU, Intel Gaudi, and CPU, with different minimum hardware per feature: LLM.int8() needs NVIDIA Turing or newer, while NF4 and FP4 need Pascal or newer. GPTQ in Transformers runs on CUDA, XPU and CPU. The format choice starts with the hardware table, not with the benchmark.

What you need

  • The device the model will run on: CPU model, or GPU model and CUDA version
  • The quantization formats you are considering
  • The memory available on that device

Step 1: Check the hardware table for your device

Look up each candidate format in the hardware compatibility table for your exact device. A format that needs CUDA will not run on a CPU-only machine, and a format that needs Turing will not run on an older card.

Step 2: Check the memory budget on that device

Work out the quantized model size on the target device and compare it with the available memory. A format that fits on a GPU may still be too large for a CPU machine with less RAM.

Step 3: Test the format on the target device

Load the quantized model on the actual target hardware and run a short generation. A format that loads but runs slowly on CPU may still be the wrong choice for an interactive use.

Worked example: synthetic format choice for 3 devices

The table below is a synthetic example. It shows the expected result of matching formats to hardware; no model was loaded.

Device Format Runs?
NVIDIA GPU, CUDA 12 bitsandbytes 4-bit Yes
CPU-only server bitsandbytes 4-bit Yes, slower
Old GPU, pre-Turing LLM.int8() No – needs Turing
CPU-only server GPTQ 4-bit Yes, via CPU backend

Expected result (UNTESTED). the 4-bit formats run on the modern GPU and on CPU, but LLM.int8() does not run on the pre-Turing card. This check was not run live; the table shows the expected result for the synthetic example.

Limits

  • Hardware support changes with library versions, so check the table for the version you installed.
  • CPU inference is much slower than GPU inference for the same model, even when it loads.
  • Some methods can only be loaded from a pre-quantized checkpoint, so you quantize with the method own library first.
  • GGUF checkpoints are a single file and suit CPU runtimes, but most GGUF models are dequantized to full precision as they load in Transformers.

Sources

See all