Dev tools
GGUF vs Safetensors vs MLX: Model Formats Explained
GGUF vs safetensors vs MLX: which AI model file format to use for Ollama, LM Studio, vLLM, ComfyUI or a Mac, how quantised files are named, and converting.
The difference in GGUF vs safetensors is what each file is for. Safetensors is the standard, safe way to store a model's raw weights, used by Hugging Face Transformers, vLLM, Diffusers and ComfyUI; a model is usually published first in safetensors, often split across several files with separate config and tokenizer files. GGUF is a single-file format from the llama.cpp project that packs the weights (usually quantised), tokenizer and settings together for local apps like Ollama and LM Studio. MLX isn't a separate file type so much as Apple's framework for Macs, whose models are stored as safetensors files in a layout MLX reads directly. Pick the format your software expects: GGUF for llama.cpp-based local tools, safetensors for Python and GPU serving, MLX on Apple Silicon.
This guide explains each format, compares GGUF vs safetensors vs MLX, covers safetensors vs pickle, GGUF vs safetensors in ComfyUI, MLX vs GGUF on a Mac, GGUF vs AWQ vs GPTQ, how to read model file names, and how to convert between formats.
GGUF vs Safetensors vs MLX at a Glance
| Safetensors | GGUF | MLX | |
|---|---|---|---|
| Made by | Hugging Face | llama.cpp / ggml project | Apple (framework) |
| What's in the file | Tensors plus a small metadata header | Tensors, tokenizer, chat template and model settings in one file | Safetensors weights plus a config file |
| Single file? | Often split into several shards | Yes (large models can be split into parts) | A folder of files |
| Quantisation | Possible (GPTQ, AWQ, FP8, bitsandbytes), less flexible | Built in: many levels from 2-bit to 8-bit | 4-bit, 8-bit and others via MLX |
| Runs on | Anything with PyTorch or a compatible runtime | CPU and most GPUs via llama.cpp | Apple Silicon Macs only |
| Main tools | Transformers, vLLM, SGLang, Diffusers, ComfyUI | llama.cpp, Ollama, LM Studio, Jan, other local apps | MLX-LM, LM Studio on Mac |
| Best for | Training, fine-tuning, GPU serving, image models | Easy local inference, CPU and mixed hardware | Fast local inference on Macs |
What Is Safetensors?
Safetensors is a file format created by Hugging Face to store model weights safely and quickly. A .safetensors file has a small JSON header describing each tensor (name, shape, data type) followed by the raw numbers. Hugging Face's description is that it uses a restricted loading process that prevents code execution.
Key properties:
- Safe: loading a safetensors file can't run hidden code (see below).
- Fast: weights can be memory-mapped and loaded lazily, so big models open quickly and you can load just part of a model.
- Language-neutral: readers exist for Python, Rust, JavaScript and more.
- The default on Hugging Face: most new models are published as safetensors, often sharded into files like
model-00001-of-00004.safetensors, withconfig.json, tokenizer files and a chat template alongside.
A safetensors model is usually full precision (16-bit) unless its name says otherwise, so it's large: about 2 bytes per parameter, or roughly 16 GB for an 8B model.
Safetensors vs Pickle
Safetensors vs pickle is about security. Older PyTorch model files (.bin, .pt, .pth, .ckpt) were saved with Python's pickle module, which can store any Python object, including code that runs when the file is loaded. As Hugging Face's format guide puts it, anything can be pickled, including malicious code. A tampered model file could run commands on your computer the moment you open it.
Safetensors stores only data, so loading one can't execute code. That's why:
- Hugging Face and most tools now prefer safetensors.
- Recent PyTorch versions default
torch.loadto a safer weights-only mode. - You should prefer safetensors (or GGUF) downloads and be careful with
.bin,.ptand.ckptfiles from sources you don't trust.
What Is GGUF?
GGUF is the model format of llama.cpp, introduced in August 2023 to replace the older GGML format. A GGUF file contains:
- Metadata: the architecture, context length, tokenizer, chat template and other settings.
- Tensor information and data: the weights, usually quantised.
Because everything is in one file, a GGUF model "just works" in tools built on llama.cpp, such as Ollama, LM Studio and Jan. The format supports memory-mapping for fast loading and a wide range of quantisation levels, and runs on CPUs, Apple Silicon and most GPUs.
GGUF quantisation names
GGUF files are usually named with their quantisation type:
| Name | Approximate bits per weight | Typical use |
|---|---|---|
| F16 / BF16 | 16 | Full quality; the source for other quants |
| Q8_0 | 8 | Near-lossless; large |
| Q6_K | About 6.5 | Very close to full quality |
| Q5_K_M | About 5.7 | High quality, moderate size |
| Q4_K_M | About 4.8 | The common default: good balance of size and quality |
| IQ3, Q3_K variants | About 3–3.5 | Squeezing bigger models onto smaller hardware |
| IQ2, Q2_K variants | About 2–2.6 | Noticeable quality loss; last resort |
"K" quants use smarter block-wise scaling; "IQ" quants use newer methods that keep more quality at very low bit rates. Our guide to LLM quantization explains how much quality each level costs.
What Is MLX?
MLX is Apple's open-source machine-learning framework for Apple Silicon, released in December 2023. It's built for the Mac's unified memory, where CPU and GPU share one pool. MLX models are usually stored as safetensors files plus a config, often quantised to 4-bit or 8-bit, and published by the community on Hugging Face (for example under the mlx-community organisation).
MLX models run only on Apple Silicon. You use them through the mlx-lm Python package or apps such as LM Studio on a Mac.
MLX vs GGUF on a Mac
MLX vs GGUF is the main choice for Mac users, because both run well on Apple Silicon:
- Speed: MLX is often reported to generate tokens faster than GGUF on the same Mac at the same quantisation level, since it's built specifically for Apple's hardware. Results vary by model and version, so test both.
- Compatibility: GGUF works across Mac, Windows and Linux, and in more apps. MLX is Mac-only.
- Model availability: GGUF versions of new models usually appear very quickly; MLX versions are also common for popular models.
- Tools: LM Studio runs both, so you can compare on your own machine. Ollama uses GGUF.
Practical rule: on a Mac with LM Studio, try the MLX version first and keep GGUF as the fallback. Our Ollama vs LM Studio comparison covers the apps.
GGUF vs Safetensors in ComfyUI
The GGUF vs safetensors ComfyUI question matters for image and video models:
- Safetensors is ComfyUI's standard format for checkpoints, LoRAs, VAEs and text encoders. Full-precision and FP8 safetensors files usually give the best speed on GPUs with enough VRAM.
- GGUF versions of large image and video models, such as Flux and Wan, are available through community custom nodes. They use quantisation (for example Q8, Q5 or Q4) to fit large models on GPUs with less VRAM.
- Trade-off: GGUF lets a 12–16 GB GPU run models that otherwise wouldn't fit, at some cost in speed and quality, especially at 4-bit and below. If your GPU has enough memory, safetensors (FP16 or FP8) is usually faster.
LoRAs are typically still loaded as safetensors files alongside a GGUF base model.
GGUF vs AWQ vs GPTQ and Other Formats
GGUF vs AWQ vs GPTQ is a question of which software and hardware you're targeting:
| Format | What it is | Used by |
|---|---|---|
| GGUF | Single-file format with built-in quantisation | llama.cpp, Ollama, LM Studio, local apps |
| GPTQ | GPU quantisation method, stored in safetensors | vLLM, Transformers, other GPU servers |
| AWQ | Activation-aware GPU quantisation, stored in safetensors | vLLM, Transformers, other GPU servers |
| FP8 | 8-bit floating point weights for newer GPUs | vLLM, SGLang, TensorRT-LLM, ComfyUI |
| EXL2 / EXL3 | Flexible GPU quantisation for the ExLlama runtime | ExLlama and apps built on it |
| MXFP4 and other 4-bit floats | Newer 4-bit floating-point formats some models ship in | Recent GPU runtimes and llama.cpp |
| ONNX | Format with weights plus the computation graph | ONNX Runtime, browsers, mobile and edge |
Rough guide: GPTQ, AWQ and FP8 are for serving on Nvidia (and some AMD) GPUs with high throughput; GGUF is for running locally on whatever hardware you have.
How to Read Model File Names
Model repositories pack a lot into names. Examples:
Qwen3-8Bwith.safetensorsfiles: original 16-bit weights.Qwen3-8B-GGUF/qwen3-8b-Q4_K_M.gguf: GGUF, 4-bit K-quant, medium.Qwen3-8B-AWQor-GPTQ-Int4: 4-bit GPU quantisation for vLLM or Transformers.Qwen3-8B-FP8: 8-bit floating point for newer GPUs.Qwen3-8B-MLX-4bit(often undermlx-community): 4-bit MLX for Macs.-Instructor-it: tuned to follow instructions and chat; base models without it are for further training.
Always check the model card for the licence, the recommended chat template and any quantisation notes.
How Big Each Format Is
Approximate file sizes for two common model sizes:
| Format | 8B model | 70B model |
|---|---|---|
| Safetensors, 16-bit (BF16/FP16) | About 16 GB | About 140 GB |
| FP8 | About 8–9 GB | About 70–75 GB |
| GGUF Q8_0 | About 8.5 GB | About 75 GB |
| GGUF Q4_K_M | About 5 GB | About 42 GB |
| MLX 4-bit | About 4.5 GB | About 40 GB |
| AWQ or GPTQ 4-bit | About 5–6 GB | About 38–40 GB |
You need some extra memory beyond the file size for the context (KV cache) and the app itself, so leave headroom.
Which File to Download From a GGUF Repository
GGUF repositories on Hugging Face often contain a dozen files, one per quantisation level. To choose:
- Check your memory: GPU VRAM if the model will run on the GPU, or unified memory on a Mac or mini PC.
- Pick the largest file that fits with a few gigabytes to spare.
- Default to Q4_K_M if you're unsure; move up to Q5_K_M, Q6_K or Q8_0 if you have room, or down to Q3 or IQ3 variants only if you must.
- For split files (names ending in
-00001-of-00003.gguf), download all parts; llama.cpp loads them together. - Read the model card for the chat template, recommended settings and licence.
Security Beyond Pickle
Safetensors and GGUF remove the biggest risk, code execution on load, but a few cautions remain:
- Keep runtimes updated. File parsers can have bugs; llama.cpp and other tools fix security issues in new releases.
- Download from known publishers or well-known community uploaders.
- Be careful with custom code. Some Hugging Face models need
trust_remote_code, which runs Python from the repository; only enable it for sources you trust. - Check licences, which travel with the original model whatever the format.
How to Convert Between Formats
You rarely need to convert, because community uploads cover most popular models, but it's straightforward:
Safetensors to GGUF with llama.cpp:
# Convert a Hugging Face model folder to a 16-bit GGUF file
python convert_hf_to_gguf.py ./models/my-model --outfile my-model-f16.gguf
# Quantise it to Q4_K_M
./llama-quantize my-model-f16.gguf my-model-Q4_K_M.gguf Q4_K_MHugging Face model to MLX:
pip install mlx-lm
mlx_lm.convert --hf-path Qwen/Qwen3-8B -qThe -q flag quantises the model (4-bit by default) and writes MLX-ready safetensors files.
Going from GGUF back to safetensors is uncommon and loses quality if the GGUF was quantised; start from the original weights instead. Our guide on how to run an LLM locally covers getting a model running once you have the file.
Which Model Format Should You Use?
| You want to... | Use |
|---|---|
| Chat with a model in Ollama, LM Studio or Jan | GGUF |
| Run on a CPU, a mixed-GPU PC or a small device | GGUF |
| Get the fastest local speed on a Mac | MLX (try GGUF too) |
| Serve a model to many users with vLLM or SGLang | Safetensors (full precision, FP8, AWQ or GPTQ) |
| Fine-tune or train a model | Safetensors (full precision) |
| Run Stable Diffusion or Flux in ComfyUI with enough VRAM | Safetensors |
| Run a large image or video model on a small GPU in ComfyUI | GGUF via custom nodes |
| Run in a browser or on mobile | ONNX or another runtime-specific format |
FAQ
What is the difference between GGUF and safetensors?
Safetensors stores a model's raw weights safely and is the standard for Python, GPU serving, training and image models. GGUF is a single-file format from llama.cpp that bundles quantised weights, tokenizer and settings for local apps like Ollama and LM Studio.
Is GGUF better than safetensors?
Neither is better overall. GGUF is better for easy local use on ordinary hardware, especially with quantisation. Safetensors is better for GPU serving, fine-tuning and tools built on PyTorch. Use whichever your software expects.
Is MLX faster than GGUF on a Mac?
Often, yes: MLX is built for Apple Silicon and is frequently reported to generate tokens faster than GGUF at the same quantisation. Results vary by model and app version, so it's worth testing both in LM Studio.
Why is safetensors safer than pickle?
Pickle-based files (.bin, .pt, .ckpt) can contain code that runs when the file is loaded, so a malicious model could compromise your computer. Safetensors stores only tensor data and metadata, so loading it can't execute code.
Can I use GGUF models in vLLM?
vLLM has some GGUF support, but it's built mainly around safetensors and GPU quantisation formats such as AWQ, GPTQ and FP8. For GGUF files, llama.cpp, Ollama or LM Studio are usually the better fit.