LM Studio Guide
Isometric scene of a mini PC and monitor showing a cyan cube, cabled to a block of stacked tensor tiles and an open hard case holding layered grid trays, with a chip
model-formats

GGUF vs Safetensors: Differences and LM Studio Support

Compare GGUF and safetensors, choose a model for LM Studio or ComfyUI, fix the No LM Runtime error, and follow commands to convert both ways.

By LM Studio Guide Editorial · ·Updated · 10 min read

Choose GGUF to run a supported model in LM Studio, Ollama, or llama.cpp. Choose safetensors weights with their model configuration and tokenizer for Transformers training or vLLM serving. On Apple Silicon, LM Studio also runs compatible MLX packages that contain safetensors weights. GGUF specification, Transformers model API, vLLM weight loading, LM Studio’s MLX announcement.

Evidence note: The LM Studio 0.4.28 changelog and app documentation, GGUF v3 specification, llama.cpp master documentation, Transformers v5 and main documentation, and Safetensors and ComfyUI project documentation were checked on November 25, 2026. Commands and benchmarks were not run for this guide. LM Studio changelog.

What each format was designed to do

Safetensors stores named tensors behind a JSON header. When provided, configuration, tokenizer, and chat template files are separate from the safetensors weights. The format requires every byte of its tensor buffer to be indexed, with no gaps, to prevent polyglot files that can be interpreted as more than one format. Safetensors documentation, Safetensors format and design notes.

GGUF packages weights with metadata a compatible inference engine uses, including architecture settings and tokenizer data. It can also carry a Jinja chat template in the tokenizer.chat_template field. GGUF supports both full-precision and quantized weights. GGUF specification, Hugging Face GGUF guide.

PyTorch pickle and ONNX serve other purposes. Pickle can serialize Python objects and can execute code when unpickled, so only unpickle files you trust. An ONNX export describes the model’s computation as a graph for compatible runtimes. Hugging Face model format guide, ONNX concepts.

Side by side

GGUFSafetensors
Best fitDistribute a model for local inferenceStore weights for training, fine-tuning, or serving
What travels with the weightsModel settings, tokenizer, and chat template when includedA tensor index and optional string metadata. The model repository supplies the configuration and tokenizer
File layoutGGUF magic bytes, v3 header, key-value metadata, aligned tensor data8-byte header length, JSON header, tensor bytes
QuantizationFormats such as Q4_K_M and Q8_0The loading framework interprets quantized weights, such as MLX 4-bit
Memory-mapped loadingSupported by designSupported for tensor reads
Typical runtimesllama.cpp, LM Studio, OllamaTransformers, vLLM, MLX, ComfyUI
LM Studio supportllama.cpp loads supported GGUF modelsThe MLX runtime loads supported MLX packages on Apple Silicon

GGUF specification, Safetensors format, MLX LM conversion guide, LM Studio runtimes.

Loading speed and generation speed

For GPT-2 weights, Hugging Face reported the Safetensors loader was 76.6× as fast as torch.load on a 2.00 GHz Intel Xeon and 2.1× as fast on a Tesla T4 with SAFETENSORS_FAST_GPU=1. The Safetensors maintainers also report that BLOOM load time across eight GPUs fell from 10 minutes to 45 seconds. Both examples measure loading weights. Hugging Face speed comparison, Safetensors lazy-loading notes.

For inference, llama.cpp reports a different trade-off for Llama 3.1 8B. In its benchmark, Q4_K_M used a smaller file and generated tokens faster, while F16 processed the prompt faster. Both rows are GGUF files. llama.cpp quantization benchmark.

GGUF weightsFile sizePrompt processing at 512 tokensGeneration at 128 tokens
F1614.96 GiB923.49 ± 0.53 tokens/s29.17 ± 0.04 tokens/s
Q4_K_M4.58 GiB821.81 ± 21.44 tokens/s71.93 ± 1.52 tokens/s

For quality, perplexity (ppl) measures how well the model predicts the next token on a text sample. Kullback–Leibler divergence (kld) measures how far the quantized model’s token probabilities move from a reference model’s probabilities. Compare quantizations on the same text. Hugging Face perplexity guide, llama.cpp quality measurements.

An importance matrix uses calibration text to help preserve accuracy during quantization. The calibration commands below show how to collect it and pass it to llama-quantize with --imatrix. llama.cpp importance matrix guide, llama.cpp quantization options.

Can LM Studio run safetensors?

LM Studio opens supported GGUF files with llama.cpp. On an Apple Silicon Mac running macOS 14.0 or later, it can also open supported MLX packages, including their safetensors weights. For a stock Transformers checkpoint, look for a GGUF or MLX conversion. LM Studio app docs, system requirements, LM Studio MLX engine.

  1. Open Discover with Cmd+2 on Mac or Ctrl+2 on Windows or Linux. Search the model name or paste its Hugging Face URL. The search shortcut is Cmd+Shift+M on Mac or Ctrl+Shift+M on Windows. LM Studio download guide, Hugging Face LM Studio guide.
  2. At a terminal, use lms get qwen --gguf or, on Apple Silicon, lms get qwen --mlx. To request a particular GGUF quantization, append a selector such as @Q6_K to its Hugging Face repository URL. LM Studio CLI download reference, Hugging Face LM Studio guide.
  3. If the original checkpoint is the only download, follow the GGUF conversion steps below. On Apple Silicon, mlx_lm.convert --model mistralai/Mistral-7B-Instruct-v0.3 -q is MLX LM’s example for a compatible Transformers model. MLX LM conversion guide.

No LM Runtime found for model format

Match the format at the end of the error to the checkpoint and your OS. LM Studio’s Windows issue report includes safetensors and torchSafetensors. A maintainer identified the downloaded model in the report as MLX. LM Studio issue 569.

Error formatWhat to try
'safetensors'If the repository is an MLX conversion, use it with the MLX runtime on Apple Silicon. On Windows or Linux, download a GGUF build. For a stock checkpoint, find a compatible conversion.
'torchSafetensors'Check the repository for a supported GGUF or MLX download. For an ordinary PyTorch/Transformers checkpoint, download or create a conversion suited to your platform.
'gguf'Open LM Runtimes with Cmd+Shift+R on Mac or Ctrl+Shift+R on Windows or Linux. Install or update the llama.cpp runtime and try loading the model again.

LM Studio runtime management, LM Studio issue 317, LM Studio issue 569.

At the terminal, list the installed runtimes with lms runtime ls. Use lms runtime get if the required runtime is missing or lms runtime update for an installed runtime. Run lms runtime select to choose the active version. LM Studio runtime CLI.

If the GGUF error persists, check for AVX2 on x64. LM Studio requires AVX2 support on x64 Windows and ships with AVX2 support by default on x64 Linux. LM Studio system requirements.

Continuous batching for GGUF

LM Studio’s parallel-request guide specifies llama.cpp runtime v2.0.0 for continuous batching. It lets the server combine overlapping requests into a batch. In the model loader, turn on Manually choose model load parameters, select a model, then turn on Show advanced settings. Set Max Concurrent Predictions, which defaults to 4. LM Studio parallel requests.

GGUF vs MLX vs safetensors

MLX is an inference and machine learning framework that can use safetensors weights. Check the repository’s name and file list before downloading. LM Studio added its MLX runtime in 0.3.4 and can load GGUF and MLX models simultaneously. LM Studio MLX announcement, MLX LM documentation.

ChoiceWhat to look forLM Studio runtime
GGUFA compatible .gguf download in your chosen quantizationllama.cpp on supported platforms
MLXA repository marked MLX. For example, LM Studio’s MLX LFM2 release has model.safetensors, config.json, and tokenizer filesMLX on Apple Silicon
Stock safetensors checkpointWeights, configuration and tokenizer published for the source framework. A sharded model such as Qwen2.5 also has a weights indexChoose a GGUF or MLX build for your platform

Hugging Face GGUF guide, LM Studio’s MLX file list, Qwen’s Transformers file list.

The compatibilityTypes field in model.yaml describes model variants in the catalog. It can list both gguf and safetensors. The model listing API reports the actual model file format as gguf, mlx, or null. LM Studio model.yaml, LM Studio model listing API.

GGUF vs safetensors in ComfyUI

ComfyUI’s built-in Load Checkpoint node loads safetensors checkpoints. The ComfyUI-GGUF custom nodes can load GGUF diffusion weights for models such as Flux. Compare the files in city96’s FLUX.1-dev model card and download listing.

FLUX.1-dev quantizationF16Q8_0Q6_KQ5_K_SQ4_K_SQ3_K_SQ2_K
File size23.8 GB12.7 GB9.86 GB8.29 GB6.81 GB5.23 GB4.03 GB

ComfyUI’s Flux examples offer flux1-dev-fp8.safetensors for Load Checkpoint. For this checkpoint, put it in ComfyUI/models/checkpoints and set CFG to 1.0. The examples also show how to reduce memory use by setting weight_dtype to FP8 in Load Diffusion Model. The examples recommend full 16-bit weights when resources permit because FP8 can reduce quality. ComfyUI Flux workflows.

If FP8 fits in VRAM, compare sampling speed on the same workflow before switching. ComfyUI has a dedicated FP8 linear path, while the GGUF custom node expands quantized weights during layer execution. That extra work can offset a smaller GGUF download when both models fit and the backend can use the FP8 path. ComfyUI FP8 code, ComfyUI-GGUF weight handling.

To use a Flux GGUF in ComfyUI, follow the ComfyUI-GGUF install and usage instructions.

  1. From ComfyUI/custom_nodes, run git clone https://github.com/city96/ComfyUI-GGUF. Install the dependency into ComfyUI’s Python environment with pip install --upgrade gguf.
  2. Place the .gguf file in ComfyUI/models/unet.
  3. Use Unet Loader (GGUF) in the bootleg category in place of Load Diffusion Model.

For a safetensors checkpoint that bundles the diffusion model, text encoder, and VAE, put it in ComfyUI/models/checkpoints and select it in Load Checkpoint. ComfyUI Load Checkpoint documentation.

Where to get a compatible model

Look for a supported build before converting. Use the LM Studio app and its model downloader to search for a GGUF or MLX release. If you already have Ollama or llama.cpp installed, these commands open the same example Hub GGUF at Q8_0. Hugging Face Ollama guide, Hugging Face llama.cpp guide.

ollama run hf.co/bartowski/Llama-3.2-3B-Instruct-GGUF:Q8_0
llama cli -hf bartowski/Llama-3.2-3B-Instruct-GGUF:Q8_0

Converting safetensors to GGUF

For an architecture supported by llama.cpp, first convert the original weights to a high-precision GGUF, then quantize. Keep enough disk space for the source weights, intermediate GGUF, and final quantized file. llama.cpp quantization guide.

  1. Clone and build llama.cpp, then install its Python requirements. llama.cpp build instructions, Python requirements.

    git clone https://github.com/ggml-org/llama.cpp
    cd llama.cpp
    cmake -B build
    cmake --build build --config Release
    python3 -m pip install -r requirements.txt
  2. Download the source model directory with the weight files, model configuration and tokenizer. Point convert_hf_to_gguf.py at that directory. Here ./Model-Dir stands for its local path. llama.cpp converter arguments.

    python convert_hf_to_gguf.py ./Model-Dir --outfile model-bf16.gguf --outtype bf16
  3. Pass Q4_K_M to llama-quantize. The converter’s --outtype accepts bf16, but rejects q4_k_m. llama.cpp quantization guide, converter output types.

    ./build/bin/llama-quantize model-bf16.gguf model-Q4_K_M.gguf Q4_K_M
  4. Run lms import model-Q4_K_M.gguf --copy and follow the prompts. The --copy flag keeps the original file in place. Then select the imported model in LM Studio. LM Studio import guide, CLI import options, Loading a model in LM Studio.

To use a calibration matrix in step 3, put representative text in calibration-data.txt and run the following commands from the llama.cpp repository. llama.cpp importance matrix guide.

./build/bin/llama-imatrix -m model-bf16.gguf -f calibration-data.txt -o imatrix.gguf
./build/bin/llama-quantize --imatrix imatrix.gguf model-bf16.gguf model-Q4_K_M.gguf Q4_K_M

For a Hub repository, the quantization guide also shows a --remote conversion and a separate --mmproj export for vision weights. llama.cpp quantization guide.

Converting GGUF to safetensors

Transformers can export a supported GGUF as a dense model. Dequantization expands the rounded weights and cannot recover the original precision. For fine-tuning where that precision matters, start from the original checkpoint. Transformers GGUF guide, llama.cpp quantization guide.

The example uses the Qwen checkpoint from the Transformers docs. Substitute your compatible repository and filename. GgufConfig(dequantize=True) explicitly loads dense weights. The legacy loader already dequantizes supported architectures such as Llama, Mistral, and Qwen2. Budget memory for the expanded weights. Transformers GGUF guide.

import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, GgufConfig

model_id = "unsloth/Qwen3.5-4B-GGUF"
filename = "Qwen3.5-4B-Q4_K_M.gguf"

tokenizer = AutoTokenizer.from_pretrained(model_id, gguf_file=filename)
model = AutoModelForCausalLM.from_pretrained(
    model_id,
    gguf_file=filename,
    quantization_config=GgufConfig(dequantize=True),
    dtype=torch.bfloat16,
)

model.save_pretrained("output-directory")
tokenizer.save_pretrained("output-directory")

The output directory contains model weights, model configuration, and tokenizer files. In Transformers v5, omit safe_serialization from save_pretrained(). It writes safetensors weights by default and no longer accepts that parameter. For LM Studio, use the original supported GGUF or a compatible MLX package. Transformers model API, tokenizer API, Transformers v5 migration guide, LM Studio runtimes.

Running packed GGUF weights in Transformers

For inference on Apple Silicon, the September 2026 Transformers update documents packed execution for Qwen3.5 dense and MoE architectures, including compatible Qwen3.8 checkpoints. The packed path uses the ggml-org/ggml-quantization Metal kernel through PyTorch MPS. Hugging Face packed GGUF announcement.

With a compatible Transformers and PyTorch installation, run pip install kernels. Use the same from_pretrained(..., gguf_file=filename) call and omit the explicit dequantization configuration and dtype. The loader falls back to dense weights if a compatible kernel is unavailable. Transformers GGUF guide, Hugging Face packed GGUF requirements.

Applying a LoRA adapter to a GGUF model

If your fine-tune is a PEFT LoRA adapter, convert just the adapter with GGUF-my-LoRA. Sign in to Hugging Face in GGUF-my-LoRA, select the adapter, then download the result from the new repository in your account. Load the matching base model with -m and the adapter with --lora. llama.cpp GGUF-my-LoRA announcement, llama.cpp CLI options.

llama cli \
  -m Meta-Llama-3.1-8B-Instruct-Q4_K_M.gguf \
  --lora Llama-3-Instruct-abliteration-8B.gguf

Pick a quantization that fits

Check runtime support before downloading weights. Then use which GGUF quant level: Q4_K_M vs Q8_0 to pick a variant. To check whether it fits, use how much VRAM a 7B model needs or the VRAM and GGUF sizer. LM Studio’s system requirements covers platform requirements.

For serving the model from another machine, see running LM Studio headless on Unraid.

Sources

  1. GGUF format specification (ggml-org)
  2. Hugging Face - Safetensors documentation
  3. LM Studio Documentation - Introduction to model.yaml
  4. LM Studio Blog - LM Studio 0.3.4 ships with Apple MLX
  5. Hugging Face Transformers docs - GGUF loading and dequantization
  6. Hugging Face Transformers docs - Models (save_pretrained)
  7. Hugging Face Transformers - v5 migration guide (safe_serialization removed)
  8. MLX LM - Model conversion and quantization
  9. Safetensors README (file format and header size limit)
  10. Hugging Face Hub docs - GGUF
  11. Hugging Face Hub docs - GGUF usage with LM Studio
  12. llama.cpp - quantize README (conversion commands and size table)
  13. llama.cpp - Build documentation (CMake)
  14. LM Studio mlx-engine repository
  15. LM Studio Docs - App overview and shortcuts
  16. LM Studio Docs - lms runtime CLI
  17. LM Studio Docs - System requirements
  18. LM Studio Changelog
  19. LM Studio Docs - Download an LLM
  20. LM Studio Docs - Import models
  21. lmstudio-bug-tracker issue 569 - No LM Runtime found for model format 'safetensors'
  22. lmstudio-bug-tracker issue 317 - No LM Runtime found for model format 'gguf'
  23. ComfyUI-GGUF custom nodes (city96)
  24. city96/FLUX.1-dev-gguf model card
  25. ComfyUI Examples - Flux
  26. ComfyUI Docs - Load Checkpoint (CheckpointLoaderSimple)
  27. Hugging Face Safetensors load-time benchmarks
  28. Hugging Face guide to model formats
  29. ONNX concepts
  30. vLLM load configuration
  31. Hugging Face Ollama integration
  32. Hugging Face llama.cpp integration
  33. LM Studio parallel requests
  34. LM Studio CLI model downloads
  35. LM Studio REST model listing
  36. LM Studio community MLX model files
  37. Qwen Transformers model files
  38. Hugging Face perplexity guide
  39. llama.cpp perplexity and divergence
  40. llama.cpp importance matrix
  41. FLUX.1-dev GGUF file list
  42. ComfyUI FP8 linear operations
  43. ComfyUI-GGUF weight dequantization
  44. llama.cpp converter source
  45. Transformers tokenizer API
  46. Hugging Face packed GGUF announcement
  47. llama.cpp maintainer announcement for GGUF-my-LoRA
  48. ComfyUI's FLUX.1-dev FP8 checkpoint
  49. LM Studio CLI import options
  50. llama.cpp CLI options

Related