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.
| Part | What it holds |
|---|---|
| Header | Magic number, version, tensor count, metadata count |
| Metadata | Typed key-value pairs: architecture, context length, tokenizer and more |
| Tensor info | Name, dimensions, ggml type and data offset per tensor |
| Tensor data | Weights 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.
| Type (Llama 3.1 8B) | Bits per weight | File size | Typical use |
|---|---|---|---|
| F16 | 16.00 | 14.96 GiB | Reference quality, source for quantizing |
| Q8_0 | 8.50 | 7.95 GiB | Highest common quant, about half of F16 |
| Q6_K | 6.56 | 6.14 GiB | High quality with more savings |
| Q5_K_M | 5.70 | 5.33 GiB | Balanced quality and size |
| Q4_K_M | 4.89 | 4.58 GiB | Common default for local and single-GPU use |
| IQ4_XS | 4.46 | 4.17 GiB | Smaller 4-bit with an importance matrix |
| Q3_K_M | 4.00 | 3.74 GiB | Tight 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.
| Model and type | Weights | Plus context (f16 cache) | Fits on |
|---|---|---|---|
| Llama 3.1 8B Q4_K_M | 4.58 GiB | +4 GiB at 32K | 24 GB card with room to spare |
| Llama 3.1 8B Q8_0 | 7.95 GiB | +4 GiB at 32K | 24 GB card |
| Llama 3.3 70B Q4_K_M | 43.1 GB | +2.5 GiB at 8K | 48 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.
| Setup (illustrative) | Assumed price per hour | Assumed output tokens/s | Cost per million tokens |
|---|---|---|---|
| 8B Q4_K_M on a 24 GB card | $0.50 | 300 | $0.46 |
| 8B BF16 on an 80 GB card | $2.00 | 900 | $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
| GPU | Memory | Data center | Value |
|---|---|---|---|
| RTX 4090 | 24 GB | $0.46 | $0.40 |
| L40S | 48 GB | $1.26 | $0.54 |
| A100 | 80 GB | $1.56 | $0.98 |
| H100 | 80 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
- ggml documentation: GGUF specification
- Hugging Face Hub documentation: GGUF
- llama.cpp llama-quantize README
- NVIDIA GeForce RTX 4090 specifications
- NVIDIA L40S specifications
- NVIDIA H100 specifications
- llama.cpp server README
- llama.cpp llama-bench README
- vLLM documentation: GGUF
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.
Need this GPU? Rent it from NeuraMesh: choose a GPU and plan, get a confirmed quotation, and pay only when you approve. See pricing.
