LM Studio Guide
Isometric illustration of one large pink sphere ringed by smaller spheres on a dashed pad, representing a model reduced to smaller quantized versions
getting-started

GGUF Quantization: Q4_K_M vs Q8_0 for LM Studio.

Compare GGUF file sizes for Q4_K_M, Q8_0, and IQ4_XS. Work out your memory budget for context and set GPU offload before loading in LM Studio.

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

Start with Q4_K_M for local inference in LM Studio when memory is tight. Choose Q8_0 if both variants fit at the context length you need and preserving more weight precision matters. Try IQ4_XS if Q4_K_M leaves too little room for context.

What quantization actually changes

GGUF is the file format. Quantization reduces the precision of the model weights stored inside it, which shrinks the file and can affect the accuracy of the model’s answers. GGUF format specification · llama.cpp quantize README

Reading the naming scheme

In the llama.cpp example gemma-4-E2B-it-Q4_K_M.gguf, read the name from right to left.

  • .gguf is the file format.
  • Q4_K_M is the quantization. Q4 indicates the four-bit class, K identifies the K-quant family, and M is the medium mix of tensor types. The llama.cpp model loader calls it “Q4_K - Medium.”
  • gemma-4-E2B-it identifies the instruction-tuned Gemma 4 E2B model. The E in E2B refers to effective parameters. Google’s Gemma 4 E2B model card

When a listing says “Q8 GGUF,” check for the exact Q8_0.gguf suffix before using the Q8_0 figures. Other suffixes, such as Q4_K_S.gguf and Q5_K_M.gguf, indicate different variants.

The llama.cpp quantize README lists these file sizes and effective bits per weight for Llama 3.1 8B. Use the file size of the specific build you plan to load.

GGUF variantFile size (GiB)Effective bits per weight
Q4_K_M4.584.8944
Q8_07.958.5008
IQ4_XS4.174.4597

Fitting it to your hardware

Start with available memory after leaving room for the operating system and other apps. Use the GGUF file size as a rough estimate for the weights, then add room for the key-value (KV) cache and other runtime allocations. Longer contexts can require more cache memory. Hugging Face Transformers cache guide

Say you have 8 GiB available and set aside a hypothetical 1 GiB for context and the runtime. The same-model comparison comes out like this.

  • Q4_K_M comes to 4.58 + 1 = 5.58 GiB, within budget. Start here if the load estimate fits at the context you need.
  • Q8_0 comes to 7.95 + 1 = 8.95 GiB, over budget. Choose it when the higher weight precision is worth the extra memory and the load estimate still fits.
  • IQ4_XS comes to 4.17 + 1 = 5.17 GiB, saving 0.41 GiB over Q4_K_M in this example. Try it when that extra room could let you keep the context you need.

Use the example to pick a candidate, then check the actual settings in LM Studio.

  1. Open My Models and click the gear beside the downloaded variant.
  2. Set the context size you need and how much of the model to offload to the GPU. These defaults apply on the next load. LM Studio Per-model Defaults
  3. If the model is still running, run lms unload and select the loaded model. In Chat, open the model loader and select the variant again. LM Studio CLI unload instructions · LM Studio model loader
  4. Review the memory estimate in the load settings before loading. If GPU memory is tight, try less offload and recheck. If the estimate fits, load the model. LM Studio resource estimates
  5. To compare variants, load them one at a time. Use the same model release, context size, GPU offload, Flash Attention setting, and prompt. If a variant exceeds the memory budget at those settings, start with the smaller one.

Use the VRAM and GGUF sizer for an initial estimate or the LM Studio system requirements guide for hardware compatibility.

Common mistakes

Check that your download is a supported GGUF model before choosing a quantization suffix. See GGUF vs MLX vs safetensors for format compatibility and how to load a model in LM Studio for download and import steps.

Where the model runs

If LM Studio runs on a server, use that machine’s available memory for the budget. For setup, see running LM Studio headless on Unraid.

Evidence and limits. File sizes are from the llama.cpp quantize README on master. The load steps are based on LM Studio’s Per-model Defaults guide and its 0.3.27 resource-estimate notes. The load steps were not run.

Sources

  1. GGUF format specification (ggml-org)
  2. llama.cpp — Quantize README
  3. llama.cpp — Model loader quantization labels
  4. Google — Gemma 4 E2B instruction-tuned model card
  5. Hugging Face Transformers — Cache strategies
  6. LM Studio — Per-model Defaults
  7. LM Studio 0.3.27 — Model Resource Estimates
  8. LM Studio — Get started with LM Studio
  9. LM Studio CLI — lms load and unload

Related