Learn
Local & edge AI

GGUF vs. Safetensors vs. AWQ: Model Formats Explained

The short answer

GGUF is a single-file container with built-in ggml quantisation, built for CPUs and mixed CPU/GPU inference. Safetensors is a pickle-free tensor container with no quantisation of its own. AWQ is a 4-bit quantisation method for GPUs whose output is stored in safetensors. They are not interchangeable alternatives: two are file formats and one is an algorithm.

On this page

Three labels for three different things

The comparison is usually framed as a choice, which is the first mistake. GGUF is a container format with its own quantisation types, designed for the ggml runtime. Safetensors is a tensor serialisation format with no quantisation scheme at all: it stores whatever dtype it is given. AWQ is a quantisation algorithm, and its output happens to be a directory of safetensors plus a configuration file. You can have an AWQ model inside safetensors. You cannot have a GGUF that is not expressed in a ggml type, although F16 and BF16 count as types.

The axes that matter in practice are narrower than the marketing suggests: does it run on a CPU, does producing it require calibration data, does it support continuous batching, can it be fine-tuned further, and how many bits per weight does it really cost once scales and metadata are included. Almost every deployment question reduces to those five.

Safetensors: a file format, not a model format

A safetensors file begins with an eight-byte little-endian integer giving the length of a JSON header. The header maps each tensor name to its dtype, shape and a byte range in the following buffer, with an optional __metadata__ object. The tensor data follows as one flat blob. Loading is a memory map and a pointer walk, which is why it is fast and why it can be shared between processes without copying. There is no pickle, so loading a file cannot execute code, and the format is implemented for PyTorch, JAX, TensorFlow and Rust.

What it is not is a deployable model. A safetensors file carries weights only; the directory also needs config.json, which describes the architecture, layer count, head counts and RoPE settings; the tokenizer files; generation_config.json; and code that knows how to instantiate that architecture. Quantisation is orthogonal. A BF16 checkpoint is just BF16 tensors. An FP8 checkpoint is FP8 tensors plus scales. A GPTQ or AWQ checkpoint is INT4 tensors plus scales, zeros and a quantization_config block that tells the runtime which kernel to use.

GGUF: container plus ggml quantisation

A GGUF file starts with the magic bytes GGUF, a version, a tensor count and a key-value count, followed by metadata pairs, tensor descriptors, padding to a 32-byte alignment and the tensor data. The metadata is the interesting part: architecture name, hyperparameters, tokenizer model and vocabulary, the chat template, licence and provenance. Everything is little-endian and self-describing, so a runtime can load a model without any external config files. That self-containment is why GGUF survives being copied to a machine with no Python and no network.

The quantisation types are block formats. Q4_0 stores 32 weights in 18 bytes: a 16-bit scale plus 32 four-bit values, which is 4.5 bits per weight. Q4_K uses a 256-weight super-block of 144 bytes with a hierarchy of scales and minimums, also 4.5 bits per weight but far more accurate. Q5_K is 176 bytes per 256 weights, or 5.5 bits; Q6_K is 210 bytes, or 6.56 bits; Q8_0 is 34 bytes per 32 weights, or 8.5 bits. The IQ types replace the scale with a codebook and use an importance matrix to decide which weights deserve precision. The S, M and L suffixes select how many tensors get promoted to a higher type: Q4_K_M keeps most tensors at Q4_K and promotes some attention and feed-forward tensors to Q6_K, averaging around 4.8 bits per weight.

AWQ: activation-aware 4-bit for GPUs

AWQ starts from an observation about activations rather than weights. A small fraction of weight channels consistently carry much larger activation magnitudes, and quantising those channels to four bits destroys more accuracy than quantising the rest. The method scales those salient channels up before quantisation and folds the inverse scale into the following layer, so the error is pushed onto channels that matter less. The result is W4A16: four-bit weights, sixteen-bit activations, typically group size 128 with a zero point.

Producing an AWQ checkpoint needs a calibration set of a few hundred samples to collect activation statistics, but no backpropagation, so it takes minutes to about an hour on a single GPU rather than the many hours GPTQ can require. The output is a normal Hugging Face directory with quantization_config.json and a version field that selects GEMM or GEMV kernels. Speed depends entirely on the kernel: with Marlin on Ampere or newer the dequantisation is fused into the matrix multiply and throughput is close to BF16; without a fused kernel the runtime dequantises to FP16 first and can be slower than not quantising at all.

The memory arithmetic

For a 7B model the numbers are: 14 GB in BF16 safetensors, 7 GB in FP8, about 4.2 GB for AWQ with its scales, 4.4 GB for GGUF Q4_K_M including tokenizer and metadata, 5.1 GB for Q5_K_M, 5.9 GB for Q6_K and 7.6 GB for Q8_0. For a 70B model the same sequence reads 140 GB, 70 GB, roughly 40 GB, 42.5 GB, 49 GB, 58 GB and 75 GB. The apparent parity at four bits is not a coincidence: both formats spend about half a bit per weight on scales, and both leave embeddings and the output projection at higher precision in most recipes.

The difference is what else is in the directory. A GGUF is the whole deployment: weights, tokenizer and template in one file whose size is the number you budget. An AWQ directory is weights plus configs plus a separate tokenizer, and the runtime that loads it has its own overhead. When someone says a model is 4 GB, ask which of those they mean, because a 4 GB AWQ checkpoint plus a Python runtime plus CUDA context is a 6 GB process.

  • 7B BF16: 14 GB, needs a 24 GB card with room for cache.
  • 7B FP8: 7 GB, Hopper/Ada tensor cores, near-lossless on most tasks.
  • 7B AWQ 4-bit: ~4.2 GB, CUDA only, needs a fused kernel to be fast.
  • 7B GGUF Q4_K_M: 4.4 GB, runs on CPU, Metal, CUDA, ROCm and Vulkan.
  • 7B GGUF Q8_0: 7.6 GB, effectively lossless, rarely worth the space on a small card.

What runs where

GGUF is the only one of the three with a credible CPU path, and the only one that can split a model across GPU and CPU by layer. That makes it the format for laptops, Macs, ARM boards, air-gapped boxes and any machine where the GPU has less memory than the model needs. A 70B Q4_K_M on 64 GB of DDR5 will run at roughly one to two tokens per second, which is slow but real, and no AWQ checkpoint can do that at all.

AWQ is CUDA-only in practice: vLLM, TGI, SGLang and AutoAWQ all assume an NVIDIA GPU, and Marlin kernels need compute capability 8.0 or newer, so Ampere, Ada and Hopper, with Turing falling back to a slower path. Safetensors is the most portable in principle and the least portable in deployment, because a BF16 checkpoint needs enough VRAM to hold the whole model plus cache, or tensor parallelism across several GPUs. It is also the only format you can fine-tune directly, which is why training pipelines never start from GGUF.

Throughput and batching

At batch size one, all three are limited by memory bandwidth and land within a few percent of each other if their bits per weight are similar. The divergence appears at concurrency. vLLM with AWQ or GPTQ gives continuous batching, paged KV cache and prefix caching, so aggregate throughput climbs steeply with the number of simultaneous requests. llama.cpp's server has slots and batching, but its scheduler is aimed at single-user or small-team use, and aggregate throughput flattens sooner.

BF16 safetensors on vLLM is the fastest configuration per GPU when the model fits, because there is no dequantisation overhead and tensor cores run at their native rate. AWQ wins when four bits let you fit a larger model, a longer context or more concurrent sequences into the same card. Prefill is compute-bound and favours BF16; decode is bandwidth-bound and favours four bits. A serving stack that mixes both, with a quantised model and a large paged cache, is usually the right compromise.

Quality differences are smaller than the noise around them

At four bits, the gap between a well-made AWQ checkpoint and a well-made Q4_K_M is smaller than the gap between either and BF16, and both are smaller than the gap introduced by a bad calibration set or a badly chosen importance matrix. The failure modes differ in character. AWQ can degrade rare tokens and long code identifiers, because those channels are exactly the low-magnitude ones it protects least. K-quants degrade gracefully but lose more at two and three bits, where the block structure cannot represent the distribution. IQ types can be excellent at very low bit rates and mediocre with a poor imatrix.

Quantisation error also compounds with context. Weights stay fixed but attention reads a longer cache, and small per-head errors accumulate over thousands of tokens, so a model that is fine at 4K can degrade at 32K. That is a property of the cache, not the weight format, which is why KV cache quantisation is a separate decision with its own quality curve.

Converting between them

The canonical path from a Hugging Face checkpoint to GGUF is two steps: convert_hf_to_gguf.py on the source directory to produce an F16 or BF16 GGUF, then llama-quantize to the target type. The converter needs the tokenizer files and, for some architectures, an explicit --outtype. Converting to AWQ means loading the model with AutoAWQ, pointing it at a calibration dataset and writing the quantised directory; converting to GPTQ means gptqmodel with the same kind of calibration set. Every conversion should be checked against the source with a fixed prompt set and a perplexity run, because a silent tokenizer mismatch produces a model that looks fine and answers slightly wrong.

  • python convert_hf_to_gguf.py ./model --outfile model-f16.gguf --outtype f16
  • llama-quantize model-f16.gguf model-q4_k_m.gguf Q4_K_M
  • AutoAWQ: quant_config with w_bit 4, q_group_size 128, zero_point true, version GEMM for models above 7B.
  • gptqmodel --model ./model --bits 4 --group_size 128 --calibration-data pileval
  • After any conversion: llama-perplexity on a held-out file and a fixed 20-prompt check.

Load time, disk and memory mapping

A 4.4 GB GGUF does not take 4.4 GB of RAM to start, because llama.cpp memory-maps the file and lets the page cache decide what stays resident. Startup is nearly instant and the first request is slow while pages fault in from disk; after a few prompts the hot set is cached and decode settles. The --no-mmap flag forces an explicit read into anonymous memory, which makes startup slow but predictable and is the right choice when the model lives on a network filesystem or a slow SD card.

Safetensors is also mmap-friendly, but a GPU runtime usually copies or pins the tensors into VRAM at load, so startup time scales with model size. AWQ is the least lazy of the three: the weights must be materialised on the GPU before the first request, and there is no paging path if they do not fit. Disk choice affects cold start far more than steady-state decode, which is why an NVMe drive is worth more than a faster CPU for an interactive local setup.

Choosing for a real deployment

  • Laptop, Mac, ARM board or any CPU-only box: GGUF, Q4_K_M for 7-8B, Q5_K_M when memory allows.
  • One 24 GB GPU serving a small team: AWQ or GPTQ 4-bit under vLLM, with FP16 KV cache and an 8K to 16K limit.
  • Two or more 80 GB GPUs and quality-critical work: BF16 or FP8 safetensors with tensor parallelism.
  • Fine-tuning or continued pre-training: safetensors, full stop. You cannot train a GGUF in any practical sense.
  • Edge device with fixed memory and no GPU: GGUF at Q4 or Q5, with the smallest context that still works.
  • Multi-LoRA serving: a BF16 or AWQ base under vLLM, with adapters loaded per request.
  • Air-gapped deployment: GGUF, because one file plus one binary is a complete dependency closure.

Gotchas worth knowing before you commit

  • Safetensors is not a quantisation format. A safetensors directory can be 14 GB of BF16 or 4 GB of AWQ, and the label alone tells you nothing.
  • Many AWQ repositories ship without a chat template, so the model answers in the wrong turn structure until you supply one.
  • GGUF stores the template in metadata; a missing or wrong template looks like a quality problem and is not.
  • Tensor parallelism requires shard sizes that divide cleanly by the GPU count, and attention head counts that divide too.
  • AWQ group size must match what the kernel expects; a mismatched config falls back to a slow path or fails at load.
  • Context length in config.json may be smaller than what rope scaling allows, and the GGUF metadata may disagree with both.
  • A quantised model cannot be merged with a LoRA the way a BF16 model can; export the adapter and apply it at runtime instead.
  • Q4_K_M is a recipe, not a bit width: two files with the same label can differ in which tensors were promoted.
Page feedback

Was this helpful?

A quick signal helps improve these notes.

Report a mistake Straight to the lab inbox

Put it to work

See the models, datasets and gateway this lab runs.