Q4_K_M
Q4_K_M is a 4-bit quantization method in llama.cpp that combines 4-bit quantization for most weights with higher precision for important weights using a block size of 32.
Q4_K_M stands for '4-bit, K-quant, Medium', part of a family of K-quant quantization types in llama.cpp designed by Gerganov and team. It divides weights into blocks of 32, and within each block, it uses a super-block structure: a 6-bit scale (super-block), 4-bit sub-blocks, and a 4-bit minimum value for the super-block. The method is 'mixed' in that some very important weights are quantized to 6-bit precision to preserve quality, while the majority stay at 4 bits. Specifically, each super-block contains 32 weights, stored as 4-bit integers plus a 6-bit scale and 4-bit min. This achieves an effective bitrate around 4.5 bits per weight, but with superior quality compared to naive 4-bit quantization. Q4_K_M is the recommended 4-bit quantization level in llama.cpp because it provides a balanced trade-off between model size, inference speed, and perplexity. In benchmarks, Q4_K_M often matches or exceeds the quality of other 4-bit methods like Q4_0, while only using slightly more memory. The 'K' stands for K-quant, which is an umbrella term for quantization schemes that use a combination of per-block scales and min values to compress groups of weights. Compared to Q4_K_S (smaller, lower quality) and Q4_K_L (larger, higher quality), Q4_K_M sits in the middle and is the default for many users. It is widely used to run models like Llama 3, Mistral, and CodeLlama on consumer hardware. Inference speed is excellent, often achieving 20-40 tokens per second on a mid-range GPU. The format is natively supported in llama.cpp, Ollama, LM Studio, and other GGUF-based tools. When choosing a quantization level, Q4_K_M is often the first recommendation for local LLM deployment.
Q4_K_M uses only 4 bits per weight; in reality it uses an average of ~4.5 bits due to mixed precision and block overhead, which improves quality.
Related terms
Concepts you'll usually encounter alongside this one.
Q5_K_M is a 5-bit mixed-precision quantization method in llama.cpp that offers higher accuracy than 4-bit methods with moderate memory increase.
Q8_0 is an 8-bit integer quantization format in llama.cpp that balances high accuracy with good compression, offering near-lossless quality for many LLMs.
GGUF is a binary format for storing quantized LLM models, designed for efficient CPU and GPU inference, superseding GGML.
INT4 is a 4-bit integer quantization format that compresses model weights by 8x vs FP32, enabling large LLMs to run on consumer hardware with modest quality loss.
Used in benchmarks
Workloads on MyAI Bench that involve Q4_K_M.
Mentioned in tutorials
Hands-on guides that put this concept to work.
Stand up a fully functional local LLM stack on Ubuntu 22.04, NVIDIA drivers, CUDA, Ollama, and your first model, in under 30 minutes.
Run local LLMs on Windows 11 the right way, WSL2, the WSL CUDA toolkit, and Ollama with full GPU acceleration. Native installer covered too.
Apple Silicon is shockingly good at LLM inference. Get Ollama running with unified memory acceleration on any M-series Mac in 15 minutes.
DeepSeek's reasoning model rivals GPT-4 on math and code. Run the distilled 7B/14B/32B variants on consumer hardware in 30 minutes.
See how this term affects your memory budget.
Real numbers, real chips, every workload.
Picks for builders, by use case.
Stay Ahead of the AI Curve
Get weekly AI hardware news, benchmark updates, and deals in your inbox. Founding-subscriber list, be one of the first.