Text Generation
GGUF
English
quant
experimental
conversational

Experimental layer-wise quantization of allenai/OLMo-2-1124-7B-Instruct

Using LLaMA C++ release b5220 for quantization.

Original model: allenai/OLMo-2-1124-7B-Instruct

From the original model creators:

OLMo 2 7B Instruct November 2024 is post-trained variant of the OLMo-2 7B November 2024 model, which has undergone supervised finetuning on an OLMo-specific variant of the Tülu 3 dataset and further DPO training on this dataset, and finally RLVR training using this data. Tülu 3 is designed for state-of-the-art performance on a diversity of tasks in addition to chat, such as MATH, GSM8K, and IFEval. Check out the OLMo 2 paper or Tülu 3 paper for more details!

OLMo is a series of Open Language Models designed to enable the science of language models. These models are trained on the Dolma dataset. We are releasing all code, checkpoints, logs (coming soon), and associated training details. The core models released in this batch include the following:

PLEASE READ THIS BEFORE USING THESE EXPERIMENTAL VERSIONS!

An area of personal interest is finding ways to optimize the inference performance of LLMs when deployed in resource-constrained environments like commodity hardware, desktops, laptops, mobiles, edge devices, etc. There are many approaches to accomplish this, including architecture simplification and knowledge distillation, but my focus has been primarily on quantization and pruning.

The method used to produce these experimental versions is covered in Squeezing Tensor Bits: the quest for smaller LLMs, but at a high level it involves using a custom version of llama-imatrix and llama-quantize to identify influential tensors, and quantize the most important layers to higher bit precision and the less important to lower bits. This process was partly inspired by Dumitru's et al Layer-Wise Quantization: A Pragmatic and Effective Method for Quantizing LLMs Beyond Integer Bit-Levels.

As of version b5125 llama-quantize can now perform tensor-wide quantization (TWQ), whereby user-defined tensors are quantized at a specific level, or perform layer-wise quantization (LWQ) by selecting different quantization types per tensor/layer. For example, --tensor-type attn_v=q6_k will quantize all Attention Value tensors at q6_k (TWQ), and --tensor-type "\.([0-9]|1[01257]|31)\.attn_k=q4_k" will quantize Attention Key tensors on layers 0 to 9, 10, 11, 12, 15, 17 and 31 at q4_k, leaving the remaining layers at their default value (LWQ).

The modified version of llama-imatrix generates useful statistics to guide the tensor selection process, --show-statistics will display:

  • Σ(Bias): the sum of all activations over the tensor (i.e. the Importance Scores)
  • Min & Max: minimum and maximum activation values
  • μ & σ: activations' mean and standard deviation
  • % Active: proportion of elements whose average activation exceeds a very small threshold (1e-6). Helpful to determine how alive/dormant the tensor is during inference
  • N: number of activations in the tensor
  • Entropy: entropy of the activation distribution, in bits (standard Shannon entropy measurement)
  • E (norm): Normalized entropy.
  • ZD Score: z-score distribution as described in 3.1 Layer Importance Scores in the Layer-Wise Quantization paper
  • CosSim: cosine similarity between same type tensors with respect to the previous layer (i.e. blk.7.attn_k and blk.6.attn_k)

Please note that statistics are calculated for each individial tensor and should be used to compare between tensors of the same type only. For example, assuming that attn_k in layer 10 has a higher influence during inference than attn_k in layer 7 because its Σ(Bias) is larger makes sense, whilst concluding the same between attn_k and ffn_down does not.

There’s a pull request to merge these changes back into the core llama.cpp project. This may or may not ever happen so, until then, the modified version will be available on GitHub.

For testing and comparison I use models produced by Unsloth (Daniel and Michael Han do some really advanced level stuff!) and Bartowski (see credits below) but if they don't provide versions of the required model, all tests and comparisons are done against naive quantizations obtained by simply running llama-quantize with no further optimization.

All experimental versions were generated using an appropriate imatrix created from calibration datasets available at eaddario/imatrix-calibration. At its core, an Importance Matrix (imatrix) is a table or, more broadly, a structured representation that scores the relative importance of different features or parameters in a machine learning model. It essentially quantifies the "impact" each feature has on a specific outcome, prediction, or relationship being modeled, and it helps to counterbalance the negative effects of quantization and pruning.

The process to generate these models is roughly as follows:

  1. Convert the the original model's tensors to GGUF F16*
  2. Estimate the Perplexity score for the F16 model (baseline) using the wikitext-2-raw-v1 dataset, and save the logits
  3. Generate an imatrix from selected calibration datasets
  4. Determine tensor and layer Importance Score contribution using the modified version of llama-imatrix
  5. Select an appropiate quant level for each tensor and quantize the model using llama-quantize
  6. Calculate Perplexity, KL Divergence, ARC (Easy+Challenge), HellaSwag, MMLU, Truthful QA and WinoGrande scores for each quantized model
  7. Keep versions with the best scores
  8. Repeat until all desired quants are created. I find that quantizations below Q3/IQ3 are not fit for my purposes and therefore do not usually generate them, but happy to provide other quants on request.

*BF16 would be preferred, but Apple's GPUs don't support it yet, and therefore any operations are executed in the CPU, making it unacceptably slow. This is expected to change in the near term but until then, if you are using Apple kit avoid using any models tagged BF16

Models

Sizes (in GB)

Perplexity and KL Divergence scores

Model μPPL 𝜌PPL μKLD RMS Δp
OLMo-2-1124-7B-Instruct-IQ3_M 9.201710 ±0.071255 96.92% 0.153149 ±0.000797 11.390 ±0.060
OLMo-2-1124-7B-Instruct-IQ3_S 9.306264 ±0.071084 95.94% 0.197699 ±0.000965 12.938 ±0.062
OLMo-2-1124-7B-Instruct-IQ4_NL 8.680650 ±0.065689 98.37% 0.076583 ±0.000454 8.111 ±0.049
OLMo-2-1124-7B-Instruct-Q3_K_L 9.252820 ±0.070404 95.74% 0.204708 ±0.001020 13.139 ±0.063
OLMo-2-1124-7B-Instruct-Q3_K_M 9.242884 ±0.069850 95.38% 0.220640 ±0.001086 13.659 ±0.065
OLMo-2-1124-7B-Instruct-Q3_K_S 9.651383 ±0.073494 94.01% 0.287772 ±0.001362 15.534 ±0.069
OLMo-2-1124-7B-Instruct-Q4_K_M 8.683512 ±0.065748 98.46% 0.071862 ±0.000424 7.858 ±0.048
OLMo-2-1124-7B-Instruct-Q4_K_M-bartowski 7.951677 ±0.058104 97.11% 0.144072 ±0.001123 10.504 ±0.065
OLMo-2-1124-7B-Instruct-Q4_K_S 8.665009 ±0.065466 98.38% 0.076159 ±0.000445 8.104 ±0.049
OLMo-2-1124-7B-Instruct-Q5_K_M 8.475671 ±0.064030 99.41% 0.025628 ±0.000174 4.820 ±0.037
OLMo-2-1124-7B-Instruct-Q5_K_S 8.494382 ±0.064237 99.39% 0.026960 ±0.000180 4.932 ±0.038
OLMo-2-1124-7B-Instruct-Q6_K 8.425234 ±0.063616 99.67% 0.013181 ±0.000105 3.474 ±0.032
OLMo-2-1124-7B-Instruct-Q8_0 8.416597 ±0.063592 99.74% 0.009659 ±0.000089 2.993 ±0.031
OLMo-2-1124-7B-Instruct-F16 8.368713 ±0.062985 100% N/A N/A

ARC, HellaSwag, MMLU, Truthful QA and WinoGrande scores

Scores generated using llama-perplexity with 750 tasks per test, and a context size of 768 tokens.

For the test data used in the generation of these scores, follow the appropiate links: HellaSwag, ARC, MMLU, Truthful QA and WinoGrande

Model ARC HellaSwag MMLU Truthful QA WinoGrande Avg Score
OLMo-2-1124-7B-Instruct-IQ3_M 64.9333 ±1.7436 82.53 40.9333 ±1.7967 34.8000 ±1.7405 72.5333 ±1.6309 59.15
OLMo-2-1124-7B-Instruct-IQ3_S 65.2000 ±1.7405 82.66 41.3333 ±1.7993 33.6000 ±1.7259 71.7333 ±1.6453 58.91
OLMo-2-1124-7B-Instruct-IQ4_NL 67.0667 ±1.7172 83.33 41.7333 ±1.8018 37.3333 ±1.7674 74.4000 ±1.5947 60.77
OLMo-2-1124-7B-Instruct-Q3_K_L 64.5333 ±1.7481 81.47 40.9333 ±1.7967 33.3333 ±1.7225 72.5333 ±1.6309 58.56
OLMo-2-1124-7B-Instruct-Q3_K_M 63.4667 ±1.7594 81.86 41.3333 ±1.7993 33.6000 ±1.7259 73.2000 ±1.6184 58.69
OLMo-2-1124-7B-Instruct-Q3_K_S 64.9333 ±1.7436 81.60 40.4000 ±1.7930 33.2000 ±1.7207 71.8667 ±1.6430 58.40
OLMo-2-1124-7B-Instruct-Q4_K_M 66.5333 ±1.7242 83.87 42.0000 ±1.8034 36.9333 ±1.7635 71.4667 ±1.6500 60.16
OLMo-2-1124-7B-Instruct-Q4_K_M-bartowski 65.8667 ±1.7325 82.40 42.1333 ±1.8042 34.0000 ±1.7309 74.2667 ±1.5974 59.73
OLMo-2-1124-7B-Instruct-Q4_K_S 66.2667 ±1.7276 83.87 42.5333 ±1.8065 36.6667 ±1.7608 71.3333 ±1.6523 60.13
OLMo-2-1124-7B-Instruct-Q5_K_M 67.4667 ±1.7119 83.33 42.0000 ±1.8034 37.6000 ±1.7699 74.4000 ±1.5947 60.96
OLMo-2-1124-7B-Instruct-Q5_K_S 67.3333 ±1.7137 83.47 42.0000 ±1.8034 37.2000 ±1.7661 74.8000 ±1.5864 60.96
OLMo-2-1124-7B-Instruct-Q6_K 67.0667 ±1.7172 83.33 42.2667 ±1.8050 37.4667 ±1.7686 74.4000 ±1.5947 60.91
OLMo-2-1124-7B-Instruct-Q8_0 66.6667 ±1.7225 83.20 42.4000 ±1.8057 37.7333 ±1.7711 73.8667 ±1.6054 60.77
OLMo-2-1124-7B-Instruct-F16 67.3333 ±1.7137 83.20 41.8667 ±1.8026 37.8667 ±1.7724 72.6667 ±1.6284 60.59

Tokens per Second - Benchmarks

Scores generated using llama-bench. Naive (llama-quantize with no optimization) Q4_K_M quantization included for comparison.

model size params backend threads test t/s
OLMo-2-1124-7B-Instruct-Q4_K_M 3.73 GiB 7.30 B Metal,BLAS 6 pp512 331.23 ± 0.55
OLMo-2-1124-7B-Instruct-Q4_K_M 3.73 GiB 7.30 B Metal,BLAS 6 tg128 29.25 ± 0.19
OLMo-2-1124-7B-Instruct-Q4_K_M 3.73 GiB 7.30 B Metal,BLAS 6 pp1024+tg1024 44.26 ± 0.13
OLMo-2-1124-7B-Instruct-Q4_K_M-bartowski 4.16 GiB 7.30 B Metal,BLAS 6 pp512 345.11 ± 0.95
OLMo-2-1124-7B-Instruct-Q4_K_M-bartowski 4.16 GiB 7.30 B Metal,BLAS 6 tg128 27.54 ± 0.15
OLMo-2-1124-7B-Instruct-Q4_K_M-bartowski 4.16 GiB 7.30 B Metal,BLAS 6 pp1024+tg1024 42.76 ± 0.18

Metrics used

Perplexity: one of the key metrics used in NLP evaluation. It measures the quality of a language model by evaluating how well it predicts the next token given a particular sequence of words. A PPL of 1 indicates an exact match between predicted and actual, whereas values greater than one indicate a degree of "surprise" the generated token differs from the expected.

Kullback–Leibler (KL) Divergence: a statistical measure of how much a probability distribution differs from another. When quantizing models (or altering the original tensors in any way for that matter), the closest we can preserve the weights' probability distribution to the original model the better, thus the closest to 0 the better.

AI2 Reasoning Challenge (ARC): a benchmark to evaluate the ability of AI models to answer complex science questions that require logical reasoning beyond pattern matching.

HellaSwag: the Harder Endings, Longer contexts, and Low-shot Activities for Situations With Adversarial Generations (bit of a mouthful!) is a benchmark designed to test commonsense natural language inference. It requires the model to predict the most likely ending of a sentence.

MMLU: the Massive Multitask Language Understanding evaluates LLMs’ general knowledge and problem-solving abilities across 57 subjects, including elementary mathematics, US history, computer science, and law.

Truthful QA: evaluates how well LLMs generate truthful responses to questions. It identifies whether AI models can avoid generating false or misleading information, particularly in areas where human knowledge is prone to misconceptions.

Winogrande: based on the Winograd Schema Challenge, is a natural language understanding task requiring models to resolve ambiguities in sentences involving pronoun references.

Credits

A big Thank You! to Colin Kealty for the many contributions and for being one of the best sources of high quality quantized models available on Huggingface, and a really big Thank You! to Georgi Gerganov for his amazing work with llama.cpp and the ggml/gguf libraries.

Downloads last month
170
GGUF
Model size
7.3B params
Architecture
olmo2
Hardware compatibility
Log In to view the estimation

3-bit

4-bit

5-bit

6-bit

8-bit

16-bit

Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for eaddario/OLMo-2-1124-7B-Instruct-GGUF

Dataset used to train eaddario/OLMo-2-1124-7B-Instruct-GGUF