What GGUF and k-quants are
GGUF is the single-file format of llama.cpp and the ggml library: a header of key–value metadata (architecture, tokenizer, hyperparameters), then each tensor's name, shape, block type and offset, then the tensor data. Each tensor can use its own block type, a fixed layout of a few bytes of scales followed by packed integer codes. The k-quants are llama.cpp's 2- to 6-bit block types, built from 256-weight super-blocks whose sub-block scales are themselves quantized.
This page reads Qwen's own qwen2.5-0.5b-instruct-q4_k_m.gguf byte by byte: one super-block of layer 12's down_proj (blk.12.ffn_down, 896 × 4,864, stored as Q4_K), the decoded matrix and its error, the block types the file mixes, and what the whole file says once decoded in PyTorch.
One Q4_K super-block
A Q4_K super-block holds 256 consecutive weights of one row in 144 bytes: an fp16 scale , an fp16 minimum scale , 12 bytes packing eight 6-bit sub-block scales and eight 6-bit mins , and 128 bytes of 4-bit codes. Weight of sub-block (32 weights each) decodes as
so every sub-block of 32 has its own step and its own offset , both 6-bit multiples of the block's two fp16 numbers. That is bits per weight. The One Q4_K super-block panel colours its 144 bytes by field, and Decoded: 8 sub-blocks of 32 lists each sub-block's scale, min and codes, with the formula filled in for the selected weight.
Quantizing the scales is the k-quants' idea. Groups of 32 with fp16 scales and offsets, as the older Q4_1 type has, cost 1 extra bit per weight; groups of 128 with fp16 scales, as GPTQ's format, cost less but adapt to a coarser range. A 256-weight super-block with 6-bit sub-block scales keeps the small groups for half a bit.
What “Q4_K_M” is made of
"Q4_K_M" names a mix, not one type. Of the file's 291 tensors, the table on the page counts 12 in Q4_K, 12 in Q6_K (6.56 bits per weight), 133 in Q5_0 (5.50), 13 in Q8_0 (8.50) and 121 norm and bias vectors in F32; over all its weights the file averages 6.16 bits per weight and takes 491 MB, against 988 MB for the bf16 original.
Half of the 24 down_proj matrices are Q6_K and half Q4_K: the k-quants pull request defines the medium mix as Q6_K for half of the feed-forward output and attention value matrices and Q4_K for the rest. Only down_proj, whose rows are 4,864 = 19 × 256 long, can use k-quants at all: every other matrix reads the 896-wide hidden state, and 896 is not a multiple of 256, so llama.cpp fell back to the 32-weight Q5_0, and to Q8_0 for the half of the v_proj matrices that the mix would have given Q6_K. The embedding is Q5_0 and the output layer Q8_0, two 896 × 151,936 matrices that hold a large share of this small model's 630.2 million weights.
Scaled weights from the AWQ release
Qwen converted this file from the AWQ release's scaled weights, not from the original: its RMSNorm weights equal the AWQ release's to within 0.0078, against differences up to 6.86 from the original's. So every matrix carries AWQ's per-input-channel scales (the AWQ tab). The page reads them back from the file's own norms and up_proj, as the AWQ tab does, and divides them out before comparing with the original; the amber column in The matrix and the file is input channel 1292, the most active channel of the other tabs' crop.
What it buys
On layer 12's down_proj the relative weight error is 8.25 % for Q4_K against 12.56 % for round to nearest in GPTQ's symmetric format (groups of 128, 4.19 bits per weight, no compensation), and the output error on 4,096 held-out tokens is 7.73 % against 12.26 %. Q4_K spends half a bit more per weight than that format, on 32-weight sub-blocks with their own offsets.
Decoded into a PyTorch state dict and run in float32, the file answers "The capital of Australia is Canberra." like the original, with a next-token KL divergence of 0.0188 nats and a WikiText-2 perplexity of 21.00, against 19.93 for the original and 26.28 rounded to nearest. llama.cpp itself would not decode the weights first: its kernels compute dot products on the blocks directly.
Where it came from
llama.cpp's first block types (2023) were 32-weight blocks with one or two fp16 numbers each, such as Q4_0, Q4_1, Q5_0 and Q8_0. Iwan Kawrakow's k-quants pull request (June 2023) added the Q2_K to Q6_K super-block types and the S, M and L mixes. GGUF replaced the earlier GGML, GGMF and GGJT files in August 2023, so that one file carries everything needed to load a model. Dettmers and Zettlemoyer's inference scaling laws (2022) had found that small quantization blocks are among the few changes that improve 4-bit accuracy for a given number of bits. In January 2024 llama.cpp let the k-quants use an importance matrix from calibration text, which weights each column's rounding error by how active its inputs are.
Papers
- k-quants The llama.cpp pull request that introduced the Q2_K to Q6_K super-block types and the Q4_K_M mix, with perplexity against file size for LLaMA.
- GGUF file format specification The container: header, metadata keys, tensor descriptors with block types and offsets, and alignment.
- AWQ: Activation-aware Weight Quantization for LLM Compression and Acceleration The per-channel scales already folded into the weights this file was converted from.
- GPTQ: Accurate Post-Training Quantization for Generative Pre-trained Transformers The symmetric 4-bit format in groups of 128 that the page's round-to-nearest comparison uses.
- The case for 4-bit precision: k-bit Inference Scaling Laws Compares bits per parameter with model size over 35,000 experiments and finds small blocks and 4 bits the best trade-off.
- Qwen2.5 Technical Report The Qwen2.5 models, including the 0.5B instruct model whose q4_k_m file this page reads.