Inference terms

What is GGUF? The llama.cpp model format

GGUF is a binary file format for storing language models for inference with llama.cpp and other GGML-based runtimes. One file holds the weights, often quantized to types such as Q4_K_M or Q8_0, plus metadata like architecture, tokenizer and context length. It loads quickly through memory mapping and is the standard format for running quantized models locally or on a single GPU.

What GGUF is

The format comes from the ggml project, the tensor library behind llama.cpp. Its specification describes a binary format for storing models for inference with GGML and GGML-based executors. Models are usually trained in a framework such as PyTorch and then converted. It replaced the older GGML, GGMF and GGJT formats, which could not record a model's architecture or add hyperparameters without breaking old files.

Its design goals are single-file deployment, extensibility, mmap compatibility for fast loading, ease of use and full information: everything needed to load the model is in the file. Hugging Face describes the difference from tensor-only formats such as safetensors this way: the file encodes both the tensors and a standardized set of metadata.

Runtimes that read it include llama.cpp, LM Studio, GPT4All and Ollama, according to Hugging Face's documentation. The Hub can filter models by it and shows a viewer for each file's metadata and tensors.

References: ggml documentation: GGUF specification · Hugging Face Hub documentation: GGUF

Inside a GGUF file

A file has four parts. The header has a magic number, a format version (3 in the current spec), the tensor count and the metadata count. Typed key-value metadata follows, such as the architecture and context length. Then come tensor info entries, each with a name, shape, type and offset. Last comes the tensor data, aligned to a boundary set by general.alignment, 32 bytes by default.

The spec also sets a naming convention: base name, size label, fine-tune, version, encoding, type and shard, as in Mixtral-8x7B-v0.1-KQ2, which the spec reads as Mixtral with 8 experts and a 7B size label, version 0.1, in KQ2 encoding. Large models are split into shards named like 00001-of-00003. Reading the name tells you the model, its size and its quantization before you download it.

Inside a GGUF file
PartWhat it holds
HeaderMagic number, version, tensor count, metadata count
MetadataTyped key-value pairs: architecture, context length, tokenizer and more
Tensor infoName, dimensions, ggml type and data offset per tensor
Tensor dataWeights at aligned offsets (general.alignment, default 32)

References: ggml documentation: GGUF specification

Quantization types: Q4_K_M, Q8_0 and the rest

Each tensor carries its own type, so one file can mix precisions. Legacy types such as Q4_0 and Q8_0 use blocks of 32 weights with one scale. K-quants group blocks into super-blocks: Hugging Face lists Q4_K at 4.5 bits per weight, Q5_K at 5.5 and Q6_K at 6.5625. I-quants (IQ) use super-blocks of 256 weights and an importance matrix to reach lower bit rates.

The _S, _M and _L suffixes are small, medium and large mixes of these types across tensors. That is why Q4_K_M averages 4.89 bits per weight on Llama 3.1 8B in llama.cpp's own table, above the 4.5 of a plain Q4_K block. The table below lists llama.cpp's published sizes for that model.

Quantization types: Q4_K_M, Q8_0 and the rest
Type (Llama 3.1 8B)Bits per weightFile sizeTypical use
F1616.0014.96 GiBReference quality, source for quantizing
Q8_08.507.95 GiBHighest common quant, about half of F16
Q6_K6.566.14 GiBHigh quality with more savings
Q5_K_M5.705.33 GiBBalanced quality and size
Q4_K_M4.894.58 GiBCommon default for local and single-GPU use
IQ4_XS4.464.17 GiBSmaller 4-bit with an importance matrix
Q3_K_M4.003.74 GiBTight memory; check quality carefully

References: Hugging Face Hub documentation: GGUF · llama.cpp llama-quantize README

Worked example: size formula and GPU fit

File size ≈ parameters × bits per weight ÷ 8. For Llama 3.1 8B at Q4_K_M: 8.03 billion × 4.89 ÷ 8 ≈ 4.9 GB, which matches the 4.58 GiB llama.cpp reports. llama.cpp's memory table gives 43.1 GB for the 70B model at Q4_K_M.

Add the context. At an f16 cache, Llama 3.1 8B needs 128 KiB per token, so a 32K context adds 4 GiB: under 9 GiB in total, comfortable on a 24 GB RTX 4090. The 70B model at Q4_K_M plus an 8K context needs about 46 GB, which is tight on a 48 GB card such as the L40S and easy on an 80 GB H100. Our LLM VRAM budget guide covers the full method.

Worked example: size formula and GPU fit
Model and typeWeightsPlus context (f16 cache)Fits on
Llama 3.1 8B Q4_K_M4.58 GiB+4 GiB at 32K24 GB card with room to spare
Llama 3.1 8B Q8_07.95 GiB+4 GiB at 32K24 GB card
Llama 3.3 70B Q4_K_M43.1 GB+2.5 GiB at 8K48 GB card (tight) or 80 GB card

References: llama.cpp llama-quantize README · NVIDIA GeForce RTX 4090 specifications · NVIDIA L40S specifications · NVIDIA H100 specifications

Make and serve GGUF in llama.cpp, vLLM and SGLang

llama.cpp converts a Hugging Face checkpoint to an F16 or BF16 file, then llama-quantize writes the smaller type, taking an input file, an output file and a target type such as Q4_K_M. The README notes that quantization may cause some accuracy loss and that a suitable importance matrix, passed with --imatrix, can reduce it. Measure loss with perplexity or KL divergence on your own text.

To serve, pass the file to llama-server with -m, use -ngl to choose how many layers go on the GPU (auto by default, or all), -c for context size and -np for parallel slots. llama-bench reports prompt and generation speed for a given file.

vLLM can load these files; its example serves a Qwen3 0.6B Q4_K_M repository with --tokenizer pointing at the original model. But its docs call the support highly experimental and under-optimized and recommend the base model's tokenizer. For production on vLLM or SGLang, safetensors checkpoints with AWQ, GPTQ or FP8 are the more common path; see LLM quantization for inference.

References: llama.cpp llama-quantize README · llama.cpp server README · llama.cpp llama-bench README · vLLM documentation: GGUF

How GGUF changes cost per token

A smaller file can move a model to a cheaper GPU, which is often the biggest saving. The comparison below uses assumed hourly prices and assumed throughput, not measurements or quotes: a 24 GB card at an assumed $0.50 per hour running an 8B Q4_K_M model at an assumed 300 aggregate output tokens per second, against an 80 GB card at an assumed $2 per hour running the same model in BF16 at an assumed 900 tokens per second.

Cost per million output tokens comes to about $0.46 on the smaller card and $0.62 on the larger. The larger card would win if your traffic kept it full, so test both with your load. Current NeuraMesh rates are on GPU prices.

How GGUF changes cost per token
Setup (illustrative)Assumed price per hourAssumed output tokens/sCost per million tokens
8B Q4_K_M on a 24 GB card$0.50300$0.46
8B BF16 on an 80 GB card$2.00900$0.62

Common misconceptions

The format is not a model family or a quantization method; it is a container that can hold F16, BF16 or many quantized types. Q4 does not mean exactly 4 bits per weight; block scales and mixes push the average higher. Quantized files are not CPU-only: llama.cpp offloads layers to NVIDIA GPUs with -ngl. And the smallest file is not automatically the best choice, since 2- and 3-bit types can lose noticeable quality on smaller models.

References: Hugging Face Hub documentation: GGUF · llama.cpp server README

Related terms

The KV cache adds memory on top of the file size. Its cache type is set separately with -ctk and -ctv. Tokens per second rises as bits per weight fall, because decode reads fewer bytes. VRAM is the budget the file and cache must share.

References: llama.cpp server README

Checklist and next step

Read the file name for model, size and type. Estimate memory as parameters × bits per weight ÷ 8, plus context. Start with Q4_K_M or Q5_K_M, compare against Q8_0 on your own prompts, and use an importance matrix for low-bit types. Offload all layers to the GPU if they fit.

When you know the memory you need, NeuraMesh rents GPUs by the hour: choose a GPU, a plan, GPU count, hours and region on rent GPUs, and you receive a confirmed quotation, typically within one business day, with nothing charged until you approve.

NeuraMesh prices for these GPUs

NeuraMesh prices per GPU-hour in USD, excluding taxes, as of 2026-11-27. Live prices are on the rental pages.
GPUMemoryData centerValue
RTX 409024 GB$0.46$0.40
L40S48 GB$1.26$0.54
A10080 GB$1.56$0.98
H10080 GB$2.88$2.00

Every order is confirmed in a quotation before you pay. See all GPU prices.

Questions readers ask

What does GGUF stand for?

The specification does not expand the name. It describes the file as a binary format for GGML-based inference and the successor to the GGML, GGMF and GGJT formats.

Is Q4_K_M good enough?

For many chat and summarization uses it is a common default with a good size-to-quality balance. Check it against Q8_0 or the original weights on your own prompts, especially for small models and tasks like code or math.

Can I run a GGUF file on a GPU?

Yes. llama.cpp offloads layers to the GPU with -ngl, and with all layers offloaded the model runs entirely in VRAM. vLLM can also load these files, though its docs call that support highly experimental.

How do I convert a model to GGUF?

Use llama.cpp's conversion script to produce an F16 or BF16 file from a Hugging Face checkpoint, then run llama-quantize to the type you want. Hugging Face also hosts a conversion space that does both steps in the browser.

Is GGUF better than safetensors?

They serve different engines. This format bundles quantized weights and metadata for llama.cpp-style runtimes, while safetensors is the usual input for vLLM, SGLang and PyTorch. Pick the format your serving engine is built around.

Sources and editorial notes

Primary documentation reviewed November 24, 2026. Provider descriptions reflect published documentation. Recommendations are our analysis; worked figures are illustrative unless explicitly stated otherwise. No independent provider benchmark or uptime ranking is claimed.

Read the editorial policy.

Need this GPU? Rent it from NeuraMesh: choose a GPU and plan, get a confirmed quotation, and pay only when you approve. See pricing.