# Precision Where It Matters: A Novel Spike Aware Mixed-Precision Quantization Strategy for LLaMA-Based Language Models

Lucas Maisonnave, Cyril Moineau, Olivier Bichler, Fabrice Rastello

► To cite this version:

Lucas Maisonnave, Cyril Moineau, Olivier Bichler, Fabrice Rastello. Precision Where It Matters: A Novel Spike Aware Mixed-Precision Quantization Strategy for LLaMA-Based Language Models. ICONIP 2024 - International Conference on Neural Information Processing, Dec 2024, Auckland, New Zealand. pp.327-341, 10.1007/978-981-96-7030-7_23 . hal-05460303

HAL Id: hal-05460303

https://inria.hal.science/hal-05460303v1

Submitted on 15 Jan 2026

**HAL** is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_1.png" /></figure>

Distributed under a Creative Commons CC BY 4.0 - Attribution - International License
arXiv:2504.21553v1 [cs.CL] 30 Apr 2025

Precision Where It Matters: A Novel Spike
Aware Mixed-Precision Quantization Strategy for
LLaMA-based Language Models

Lucas Maisonnave¹, Cyril Moineau¹, Olivier Bichler¹, and Fabrice Rastello²

¹ Univ. Paris-Saclay, CEA LIST, F-91120, Palaiseau, France
lucas.maisonnave, cyril.moineau, olivier.bichler@cea.fr

² Univ. Grenoble Alpes, Inria, CNRS, Grenoble INP, LIG, 38000 Grenoble, France
fabrice.rastello@inria.fr

**Abstract.** Large Language Models (LLMs) have demonstrated remarkable capabilities in various natural language processing tasks. However, their size presents significant challenges for deployment and inference. This paper investigates the quantization of LLMs, focusing on the LLaMA architecture and its derivatives. We challenge existing assumptions about activation outliers in LLMs and propose a novel mixed-precision quantization approach tailored for LLaMA-like models. Our method leverages the observation that activation spikes in LLaMA architectures are predominantly concentrated in specific projection layers. By applying higher precision (FP16 or FP8) to these layers while quantizing the rest of the model to lower bit-widths, we achieve superior performance compared to existing quantization techniques. Experimental results on LLaMA2, LLaMA3, and Mistral models demonstrate significant improvements in perplexity and zero-shot accuracy, particularly for 8-bit per-tensor quantization. Our approach outperforms general-purpose methods designed to handle outliers across all architecture types, highlighting the benefits of architecture-specific quantization strategies. This research contributes to the ongoing efforts to make LLMs more efficient and deployable, potentially enabling their use in resource-constrained environments. Our findings emphasize the importance of considering model-specific characteristics in developing effective quantization pipelines for state-of-the-art language models by identifying and targeting a small number of projections that concentrate activation spikes.

**Keywords:** Large Language Models · Quantization · Mixed Precision · Outliers

# 1 Introduction

Large Language Models (LLMs), such as GPT-4 and LLaMA, have become central to numerous natural language processing (NLP) tasks, demonstrating exceptional capabilities in understanding and generating human language. These models are typically built upon billions of parameters (and even trillions for
GLaM [5]), enabling them to capture complex linguistic patterns and nuances. However, the sheer size of LLMs brings significant challenges in terms of computational resources and storage requirements. The most recent models like GPT4-o or Claude 3.5 Sonnet are built with the objective to have a faster and lighter model to use on a phone in the future.

Compression methods like quantization is a very effective way to reduce model size, but also to accelerate inference. Various method were built for LLMs and work very efficiently like GPTQ [6] which is a Post-Training Quantization (PTQ) method able to reduce the size of weights up to 4 bits without significant drop of performance. Quantization Aware Training (QAT) is more difficult to apply because of the need to retrain the model from scratch but it can reduce memory footprint even further like BitNet 1.58 bits [11] which is able to use ternary weights for a LLaMA architecture.

Today the urge to compress LLM models is motivated to reduce the models storage and increase their speed but also to reduce their environmental impact. Most of the newest open source models like LLaMA [18], BLOOM [10] or Mistral [9] are published with their carbon cost of training. For example the latest LLaMA3-70B model published by Meta consumed 1900 teqCO2 to be trained [8]. Compression and quantization are effective ways to reduce the energy summation of LLM like QLoRA [4] which enables to fine-tune an 8 bits quantized model with only one GPU A100.

While quantizing weights is relatively straightforward, quantizing activations presents a unique challenge, especially in LLMs. Activations often exhibit outliers—extremely high compared to the typical range [21,16]. These outliers can distort the scale used for quantization, leading to significant information loss and degradation in model performance. The presence of outliers necessitates more sophisticated quantization strategies to ensure that the quantized activations retain the representational power of the original model.

Our research offers two primary contributions to LLM activation quantization:

- We critically examine existing literature, challenging some overly broad assumptions about outlier behavior in LLMs. Specifically, we question the notion that certain dimensions consistently capture most outliers. We also highlight contradictions in reported outlier locations and imprecise outlier definitions, which hinder result reproducibility. This analysis leads us to conclude that developing a universal method for managing outliers across diverse decoder architectures like LLaMA, OPT, or GPT is challenging.

- Given these findings, we narrow our focus to the LLaMA architecture, an open-source, high-performance model that forms the foundation for various other architectures, including Mistral. Our experiments reveal the benefits of applying varied precision levels to specific model layers. We find that enhancing computational accuracy for certain layers yields significant advantages in the quantization process.

This approach allows us to address the unique characteristics of LLaMA-based models while developing an effective quantization strategy.
# 2 Related Works

## 2.1 Quantization

Quantizing model is the process of reducing the number of bits used to store and compute the model activations. To do this we need to define a scaling factor which defines the distance between 2 bins and the range of values to compress. For a symmetric uniform quantization we apply a rounding function on a scaled distribution :

$$ \hat{X} = \lfloor \frac{X}{\Delta} \rfloor \Delta, \quad \Delta = \frac{\max|X|}{2^{b-1} - 1} \qquad (1) $$

Where $\Delta$ is the scaling factor, $b$ is the bitwidth and we use the maximum absolute value as the range of our distribution which preserves extreme values for activations. Such quantization can be applied per-token so each token has a different scaling factor but it is more difficult to use efficiently in practice compared to per-tensor quantization which uses only one scaling factor for each activation tensor. Scaling factors can be static at inference and based on statistics computed on a small part of the dataset or it can be dynamic and recomputed every time. Quantization can cause a huge drop of performance when it is done post-training [20,15] that's why some methods adapt weights to the noise added during a training phase [19,11].

Usually for LLM we only quantize linear layers gathering most of the computation cost and we do not quantize the normalisation layer, the matrix multiplication and the softmax function inside the attention block.

## 2.2 Outliers in LLMs

Quantizing LLMs weights is quite easy and it doesn't require much efforts to make it work. Numerous techniques, such as GPTQ [6], allow for 8-bit quantization without requiring retraining or sacrificing model accuracy. Some QAT methods can go even further and perform 1 bits quantization like BitNet [19] or ternary quantization [11].

LLMs are challenging to quantize due to the widespread presence of extreme high values throughout the model's activations [7]. The scaling factor, which is directly related to the maximum absolute value, causes most of the distribution to be rounded to zero, leading to performance degradation. To address this issue, techniques like LLM.int8() [3] cluster these outliers and quantize them separately from the main distribution. Alternative methods such as SmoothQuant [20] shift the quantization challenge from activations to weights by introducing a scaling parameter between them. Other approaches attempt to relocate these spikes into sink tokens before quantization [15].

Ultimately, some research aims to study the problem upstream during the learning process and understand the causes of these “spikes” appearance, thus allowing to limit their impact after training [21]. Other works seek to better locate these outliers, particularly by visualizing the layers, dimensions, and tokens that could be their cause [13,7].
<figure><img src="image_2.png" /><figcaption>Fig. 1: Causal architecture of OPT and LLaMA model. There are 2 main differences: the location of the layer norm and RMS Norm, and the MLP in LLaMA uses a gate projection</figcaption></figure>

## 3 Analyzing Spikes in LLaMA Architectures

This section aims to review and analyze the findings on activation outliers presented in current research, with the goal of extracting valuable insights to develop our own optimized pipeline. While numerous papers address activation outliers in LLMs, we've observed that some hypothesis about these outliers can be highly specific to the architecture studied. Notably, we found that outliers manifest quite differently in LLaMA-like architectures compared to OPT-like models (Figure 1), and appear to be more manageable in the former. Consequently, we've chosen to focus on the LLaMA architecture, developing a PTQ mixed precision method using FP8 format.
## 3.1 Definition of an outlier

The concept of outliers in transformer activations was first introduced in [2]. They defined outliers as values exceeding six standard deviations from the activation tensor's mean, using this definition to identify dimensions with high values in a BERT model.

LLM.int8() [3] took a different approach, eschewing a statistical definition in favor of problem-specific criteria: "features with a magnitude of at least 6.0, affecting a minimum of 25% of layers and 6% of sequence dimensions".

These definitions have evolved over time. Currently, an outlier is generally considered a value that is an order of magnitude larger than the main distribution. While less precise, this definition is more practical for our goal of reducing a distribution's maximum absolute value to achieve a more accurate scaling factor (1).

In the context of quantization, what we refer to as an "outlier" is more accurately described as a "spike", a term introduced in [21,16]. We will use 'spike' for the remainder of this paper when discussing outliers.

<figure><img src="image_3.png" /><figcaption>Fig. 2: Layer 19 activations values of (a) the first RMSNorm's input in a LLaMA3-8B (b) k-proj output in a Mistral 7B</figcaption></figure>

## 3.2 Dimensions gathering outliers

A significant hypothesis in the literature posits that certain dimensions of the embedding absorb most of the model's outliers [2,3,20,21]. Various approaches have been used to demonstrate this hypothesis, employing the different outlier definitions mentioned earlier. Recent studies have attempted to verify this claim on newer models beyond BERT or OPT [13,7].

However, we question the universality of this statement, particularly when some findings are challenging to reproduce, such as in [1] where a clear outlier definition is lacking. Our observations of LLaMA2 and LLaMA3 models reveal
no dimensions consistently gathering outliers. Instead, we note spikes at specific points in activations (Figure 2a). This contrasts with [20], where one channel exhibits spikes across all tokens.

Interestingly, in the Mistral7B model, we do observe spikes across dimensions (Figure 2b), but these differ significantly from those reported in SmoothQuant or LLM.int8(). These patterns are consistent across all layers of LLaMA3 and Mistral7B, though the manifestation of outliers varies depending on the specific block examined (e.g., projection, layer normalization).

Our research corroborated a significant phenomenon in the LLaMA architecture: the presence of notable spikes in the Beginning-of-Text (BOT) token, as illustrated in Figure 2a. To validate this observation, we conducted experiments where we selectively avoided quantizing this token and compared the resulting perplexity across various models (see Table 1). The results for LLaMA models showed a substantial reduction in perplexity when the BOT token was left unquantized, strongly indicating that these spikes are predominantly associated with this token. In contrast, while Mistral architectures also exhibited a decrease in perplexity under similar conditions, the effect was notably less pronounced.

<table><caption>Table 1: Perplexity on WikiText2 comparison for different model with and without BOT quantized (per tensor quantization)</caption><thead><tr><th>Model</th><th>FP16</th><th>W8A8 w/ BOT</th><th>W8A8 w/o BOT</th></tr></thead><tbody><tr><td>LLaMA3 8b</td><td>6.14</td><td>59.9</td><td>9.02</td></tr><tr><td>LLaMA2 7b</td><td>5.47</td><td>9.89</td><td>9.05</td></tr><tr><td>LLaMA2 13b</td><td>4.88</td><td>57.36</td><td>8.93</td></tr><tr><td>Mistral 7b</td><td>5.25</td><td>80.53</td><td>61.96</td></tr></tbody></table>

<figure><img src="image_4.png" /><figcaption>Fig. 3: Maximum absolute value over layers for a LLaMA3-8B. Each color represents a different projection and we clearly see that down Proj has the biggest spikes in input and output. We also observe that RMSNorm propagate spikes through the entire model.</figcaption></figure>
## 3.3 Localisation of outliers

Another crucial question concerns the location of these spikes and their prevalence throughout the model. The answer varies between older and newer models. In OPT-like architectures, as noted in [3], spikes are absent in the second projection of the FFN. However, this is not the case for LLaMA, as observed in [1].

Figure 3 corroborates this phenomenon, clearly showing that the down projection exhibits the highest spikes in both the second and final layers of the model. Furthermore, Figure 3a demonstrates that spikes are present across all layers of the input RMSNorm and post-attention RMSNorm.

This observation indicates that the residual layer immediately preceding RMSNorm (Figure 1) propagates spikes throughout the model. This pattern is consistent across LLaMA2, and Mistral7B models (see Appendix A).

These findings highlight the architectural differences between model families and their impact on spike distribution, emphasizing the importance of model-specific considerations in addressing quantization challenges.

## 3.4 Architecture and training dependency

Contemporary LLMs are predominantly based on causal architectures such as GPT, OPT, or LLaMA (Figure 1), as opposed to encoding-decoding models like BERT. While different architectures lead to varying outlier patterns, some consistencies persist, such as the presence of spikes in layer normalization inputs and the propagation of spikes through residual layers.

A notable difference we've observed is the impact of normalization on spike amplitude. Contrary to the common understanding that normalization layers generate outliers and spikes [20], we find the opposite effect in LLaMA architectures (Figures 3a, 3b). The RMS Norm output actually reduces the amplitude of input spikes, which were initially quite high. This pattern is consistent across all LLaMA architectures, as well as Mistral models (Appendix A).

Training is also known to influence the emergence of spikes at inference. As observed in [1] hyper-parameters like weight decay, gradient clipping, encoding format or drop out can reduce the presence of outliers in LLMs.

To summarize the behavior in LLaMA architectures: spikes are initially generated by the down projection of the second layer, then propagated through the model via residual layers. Subsequently, normalization reduces their amplitude until the final down projection. Interestingly, this pattern doesn't hold for Mistral architectures, despite being based on LLaMA. This difference could be explained by the way Mistral is trained which is known to cause more or less outliers at inference [1].

# 4 Mixed Precision LLaMA

Our study focuses on LLaMA-like models, which exhibit numerous invariant features as previously discussed. We will primarily leverage the observation that
spikes occur predominantly in two projection layers to develop a mixed-precision quantization pipeline.

Furthermore, we intend to use a different coding format for these layers exhibiting spikes like FP8 which allow a wide range of values and a pretty good precision. This way we can quantize all our linear layers in 8 bits without a significant drop of performance

This targeted strategy aims to optimize quantization for LLaMA-like architectures by addressing the specific characteristics of their spike distribution and leveraging the resilience of these models to quantization.

## 4.1 Mixed Precision

As previously illustrated in Figure 3 and detailed in Appendix A, the LLaMA architecture exhibits activation spikes in the down projections (see Figure 1b) of only two layers: one at the beginning and one at the end of the model. Our proposed approach addresses this by treating these two projections distinctly. We compute these specific projections in FP16 precision, while the rest of the model's operations are executed in lower precision. This strategy enables efficient quantization of activations without resorting to specialized outlier-specific quantizers like SmoothQuant or LLM.int8(), or computing certain tokens in FP16 as in CushionCache [15].

Our mixed precision pipeline is designed to show that standard absolute maximum uniform quantization can be applied to nearly all layers, with only 2 or 3 projections requiring special treatment. Specifically, Mistral 7B, LLaMA2-7B and LLaMA2-13B models display spikes in the final output projection of their attention mechanism (as shown in Figures 5b and 6b). For these architectural designs, we decided to keep this specific projection in full precision when spike values exceed 100, exempting it from quantization. Table 2 provides an overview of all the layers we maintained in full precision within our mixed-precision approach.

<table><caption>Table 2: Summarize of layers not quantized for down and out projections</caption><thead><tr><th>Projection</th><th>LLaMA3-8B</th><th>LLaMA2-7B</th><th>LLaMA2-13B</th><th>Mistral-7B</th></tr></thead><tbody><tr><td>Down</td><td>2, 32</td><td>2, 31</td><td>4, 39</td><td>2, 31, 32</td></tr><tr><td>Out</td><td>-</td><td>32</td><td>40</td><td>32</td></tr></tbody></table>

## 4.2 FP8 format

To further enhance our quantization pipeline, we used the FP8 format [12] for down projections exhibiting spikes. PyTorch offers two variants of FP8: E5M2 and E4M3, denoting the number of bits allocated to the exponent and mantissa respectively. This format is particularly well-suited for our needs as it enables
non-uniform quantization, providing high precision for small values while still accommodating large values. In our specific case, we need to manage significant spiking values that can reach up to 2500 (as shown in Figure 4). Consequently, we opted for the E5M2 format, which has a maximum representable value of 57344, rather than E4M3, which is limited to a maximum of 448.

<table><caption>Table 3: Perplexity on WikiText2 for different model with a naive quantization, SmoothQuant and our MixPrecision LLM</caption><thead><tr><th>Bits</th><th>Type</th><th>Smooth/Mix</th><th>LLaMA3-8B</th><th>LLaMA2-7B</th><th>LLaMA2-13B</th><th>Mistral-7B</th></tr></thead><tbody><tr><td>16</td><td>-</td><td>-</td><td>6.136</td><td>5.47</td><td>4.88</td><td>5.25</td></tr><tr><td rowspan="2">8</td><td rowspan="2">perboole</td><td>Smooth</td><td>40.454</td><td>8.82</td><td>50.22</td><td>80.58</td></tr><tr><td>Mix</td><td>44.735</td><td>9.90</td><td>57.36</td><td>80.53</td></tr><tr><td rowspan="2">8</td><td rowspan="2">perboole</td><td>Smooth</td><td>8.24</td><td>6.27</td><td>8.38</td><td>10.14</td></tr><tr><td>Mix</td><td>6.270</td><td>5.58</td><td>4.95</td><td>5.32</td></tr><tr><td rowspan="2">8</td><td rowspan="2">perboole</td><td>Smooth</td><td>6.266</td><td>5.59</td><td>4.94</td><td>5.30</td></tr><tr><td>Mix</td><td>6.250</td><td>5.57</td><td>4.94</td><td>5.32</td></tr><tr><td rowspan="2">6</td><td rowspan="2">perboole</td><td>Smooth</td><td>666.033</td><td>525.18</td><td>4341.79</td><td>431.06</td></tr><tr><td>Mix</td><td>1343.003</td><td>393.42</td><td>5045.24</td><td>1617.82</td></tr><tr><td rowspan="2">6</td><td rowspan="2">perboole</td><td>Smooth</td><td>196.751</td><td>79.4</td><td>2046</td><td>241.27</td></tr><tr><td>Mix</td><td>7.857</td><td>6.94</td><td>5.71</td><td>6.70</td></tr><tr><td rowspan="2">6</td><td rowspan="2">perboole</td><td>Smooth</td><td>7.825</td><td>6.92</td><td>5.37</td><td>8.63</td></tr><tr><td>Mix</td><td>7.461</td><td>6.84</td><td>5.67</td><td>6.1</td></tr></tbody></table>

# 5 Experiments

## 5.1 Setups

Our experiments were made on 4 different architectures: LLaMA2-7B, LLaMA2-13B, LLaMA3-8B and Mistral7B and we compared our results with a very used state of the art quantization scheme: SmoothQuant and a naive uniform quantization.

To compare our performances we computed the perplexity of the predictions on WikiText2 and the average accuracy on 7 zero shot benchmarks: Wino-grande, Lambda, RTE, OpenBookQA, PIQA, HellaSwag and COPA. To perform the evaluation of our model we used LM evaluation harness benchmark by EleutherAI [17]. We used a context size of 2048 tokens for all our experiments.

Our quantization strategy is selectively applied to specific components of the model. We implement quantization in linear layers, including the Query-Key-Value projections and the Multi-Layer Perceptron (MLP) components. However, we maintain full precision for certain critical operations: the matrix multiplication and softmax function within the attention mechanism, as well as the Root Mean Square (RMS) normalization. This targeted approach allows us to balance efficiency gains from quantization with preservation of model accuracy in key computational steps.
<table><caption>Table 4: Average Zero Shot accuracy on 7 benchmark for different model with a naive quantization, SmoothQuant and our MixPrecision LLM</caption><thead><tr><th>Bits</th><th>Type</th><th>Smooth/Mix</th><th>LLaMA3-8B</th><th>LLaMA2-7B</th><th>LLaMA2-13B</th><th>Mistral-7B</th></tr></thead><tbody><tr><td>16</td><td>-</td><td>-</td><td>67.89</td><td>64.85</td><td>67.60</td><td>68.23</td></tr><tr><td rowspan="4">8</td><td rowspan="3">per par-tensor</td><td>Smooth</td><td>51.52</td><td>57.36</td><td>51.02</td><td>46.06</td></tr><tr><td>Mix</td><td>51.54</td><td>57.15</td><td>50.73</td><td>45.62</td></tr><tr><td></td><td><strong>65.46</strong></td><td><strong>62.87</strong></td><td><strong>60.26</strong></td><td><strong>59.36</strong></td></tr><tr><td>per par-token</td><td>Smooth</td><td>67.34</td><td>63.96</td><td>67.05</td><td>67.74</td></tr><tr><td rowspan="4">6</td><td rowspan="3">per par-tensor</td><td>Smooth</td><td>67.24</td><td>64.52</td><td>66.62</td><td>67.66</td></tr><tr><td>Mix</td><td>62.84</td><td>61.39</td><td>62.93</td><td>64.15</td></tr><tr><td></td><td><strong>39.23</strong></td><td><strong>45.68</strong></td><td><strong>37.04</strong></td><td><strong>44.5</strong></td></tr><tr><td>per par-token</td><td>Smooth</td><td>63.26</td><td>63.46</td><td>64.37</td><td>66.24</td></tr><tr><td></td><td>Mix</td><td>63.11</td><td>61.5</td><td>63.79</td><td>64.15</td></tr></tbody></table>

## 5.2 Results

**Unquantized Down and Out Projections**. Tables 3 presents the perplexity (PPL) results for our mixed precision method (excluding FP8). Our approach consistently outperforms perplexity of alternative schemes, particularly in 8-bit per-tensor quantization, where we observe a PPL reduction exceeding 30 for LLaMA3-8B. While 6-bit quantization remains somewhat unstable, our method still achieves applicative performances despite elevated perplexity. Per-token quantization proves less challenging for all methods, yet our approach maintains its edge in this scenario as well.

About the average zero shot accuracy Table 4 our mixed precision method is very efficient in 8 and 6 bits per tensor where we can increase accuracy over 10 points. Per token quantization is slightly different, in 8 bits all methods almost reach FP16 baseline and in 6 bits it appears to be dominated by SmoothQuant method and not ours even if PPL is lower.

These findings support our primary hypothesis that in LLaMA-like models, spikes are predominantly concentrated in two or three specific locations. This allows us to quantize the remaining portions effectively without considering outliers, while maintaining performance integrity.

**Random Mixed Precision**. To further validate our hypothesis that the outlier problem is primarily associated with specific down and out projections, we conducted an experiment where we randomly apply FP16 to different down and out projections from Table 2. Table 5 presents a comparison of perplexity between random and targeted mixed precision approaches, averaged across three different seeds.

The results clearly demonstrate that applying higher precision to random projections, rather than targeting those known to contain spikes, does not yield
performance improvements. This finding strongly supports our conclusion that the quantization challenge in LLaMA models is primarily confined to three specific linear projections, rather than being a model-wide issue.

<table><caption>Table 5: Comparison of Perplexity between targeted Mixed Precision with Random layer Mixed Precision in 8 bits per tensor averaged on 3 different seeds</caption><thead><tr><th>Bits</th><th>Type</th><th>Mix/Rand</th><th>LLaMA3-8B</th><th>LLaMA2-7B</th><th>LLaMA2-13B</th><th>Mistral-7B</th></tr></thead><tbody><tr><td rowspan="2">8</td><td rowspan="2">per_tensor</td><td>Mix</td><td>8.24</td><td>6.28</td><td>8.38</td><td>10.14</td></tr><tr><td>Mix + Rand</td><td>39.76 ± 0.24</td><td>8.68 ± 0.12</td><td>49.28 ± 0.46</td><td>78.82 ± 1.14</td></tr></tbody></table>

**FP8 Down Projections** We now test FP8 format on down and out projections that were previously excluded from quantization. Table 6 shows the results on WikiText2 perplexity in 8 bits quantization and we can see that most of the time using FP8 format doesn't injure performances and can even outperform previous capacities like for LLaMA3-8B per token which is better by 1 point of PPL than using FP16 format. Research has demonstrated that full model quantization to FP8 is highly effective for BERT models [14], and this approach appears to be similarly successful when applied to LLaMA models (FP8 row of Table 6). While FP8 quantization is beneficial, 8-bit integer (INT8) operations offer even faster computation. This suggests that combining both FP8 and INT8 quantization techniques could be particularly advantageous for optimizing model performance and efficiency.

These results show the potential of these techniques on LLaMA-like architectures. By only treating 2 or 3 projections in FP8 we can outperform quantization techniques that were specifically designed to handle spikes and outliers for all types of architectures. We showed that the problem of spikes is relevant only in specific locations and that we don't need a general method to outperform previous techniques.

<table><caption>Table 6: Comparison of Perplexity between Mixed Precision with and without FP8 format for down and out projections</caption><thead><tr><th>Bits</th><th>Type</th><th>Mix/FP8</th><th>LLaMA3-8B</th><th>LLaMA2-7B</th><th>LLaMA2-13B</th><th>Mistral-7B</th></tr></thead><tbody><tr><td colspan="2">FP8</td><td></td><td>6.42</td><td>5.58</td><td>4.98</td><td>5.35</td></tr><tr><td rowspan="2">8</td><td rowspan="2">per_tensor</td><td>Mix</td><td>8.24</td><td>6.28</td><td>8.31</td><td>9.97</td></tr><tr><td>Mix + FP8</td><td>10.64</td><td>6.44</td><td>8.50</td><td>8.23</td></tr><tr><td rowspan="2">per_token</td><td>Mix</td><td>6.250</td><td>5.57</td><td>4.94</td><td>5.32</td></tr><tr><td>Mix + FP8</td><td>5.32</td><td>5.57</td><td>4.95</td><td>6.26</td></tr></tbody></table>
# 6 Conclusion

In this paper, we have presented a comprehensive analysis of activation outliers in LLMs, with a specific focus on the LLaMA architecture. Our investigation challenges some existing assumptions about the nature and distribution of outliers in LLMs, revealing that their behavior can vary significantly across different model architectures.

We proposed a novel mixed-precision quantization approach tailored for LLaMA-like models, leveraging the observation that spikes predominantly occur in specific projection layers. By treating these layers separately with higher precision (FP16 or FP8) while quantizing the rest of the model to lower bit-widths, we achieved superior performance compared to existing quantization methods.

Our experimental results demonstrate the effectiveness of this approach across various LLaMA-based models, including LLaMA2, LLaMA3, and Mistral. We observed significant improvements in perplexity and zero-shot accuracy, particularly for 8-bit per-tensor quantization. The method also showed promise for more aggressive 6-bit quantization, though with some instability.

The success of our mixed-precision approach underscores the importance of architecture-specific quantization strategies. By focusing on the unique characteristics of LLaMA-like models, we were able to develop a more efficient quantization pipeline that outperforms general-purpose methods designed to handle outliers across all types of architectures.

Future work could explore the application of this method to other model families, investigate the causes of the remaining instability in 6-bit quantization, and further optimize the use of FP8 format for critical layers. Additionally, combining our approach with other quantization techniques, such as SmoothQuant, could potentially yield even greater performance improvements.

**Disclosure of Interests.** The authors have no competing interests to declare that are relevant to the content of this article
# Appendix

## A Spikes in LLaMA like architectures

<figure><img src="image_5.png" /><figcaption>Fig. 4: Maximum absolute value over layers for a LLaMA2-7B.</figcaption></figure>

<figure><img src="image_6.png" /><figcaption>Fig. 5: Maximum absolute value over layers for a LLaMA2-13B.</figcaption></figure>

<figure><img src="image_7.png" /><figcaption>Fig. 6: Maximum absolute value over layers for a Mistral-7B.</figcaption></figure>
References

1. Ahmadian, A., Dash, S., Chen, H., Venkitesh, B., Gou, Z.S., Blunsom, P., Üstün, A., Hooker, S.: Intriguing properties of quantization at scale. Advances in Neural Information Processing Systems 36, 34278–34294 (2023)

2. Bondarenko, Y., Nagel, M., Blankevoort, T.: Understanding and overcoming the challenges of efficient transformer quantization. arXiv preprint arXiv:2109.12948 (2021)

3. Dettmers, T., Lewis, M., Belkada, Y., Zettlemoyer, L.: Gpt3. int8 (): 8-bit matrix multiplication for transformers at scale. Advances in Neural Information Processing Systems 35, 30318–30332 (2022)

4. Dettmers, T., Pagnoni, A., Holtzman, A., Zettlemoyer, L.: Qlora: Efficient fine-tuning of quantized llms. Advances in Neural Information Processing Systems 36 (2024)

5. Du, N., Huang, Y., Dai, A.M., Tong, S., Lepikhin, D., Xu, Y., Krikun, M., Zhou, Y., Yu, A.W., Firat, O., et al.: Glam: Efficient scaling of language models with mixture-of-experts. In: International Conference on Machine Learning. pp. 5547–5569. PMLR (2022)

6. Frantar, E., Ashkboos, S., Hoefler, T., Alistarh, D.: Gptq: Accurate post-training quantization for generative pre-trained transformers. arXiv preprint arXiv:2210.17323 (2022)

7. He, B., Noci, L., Paliotta, D., Schlag, I., Hofmann, T.: Understanding and minimising outlier features in neural network training. arXiv preprint arXiv:2405.19279 (2024)

8. HuggingFace: Meta-llama-3-8b (2024), https://huggingface.co/meta-llama Meta-LLama-3-8B

9. Jiang, A.Q., Sablayrolles, A., Mensch, A., Bamford, C., Chaplot, D.S., Casas, D.d.l., Bressand, F., Lengyel, G., Lample, G., Saulnier, L., et al.: Mistral 7b. arXiv preprint arXiv:2310.06825 (2023)

10. Le Scao, T., Fan, A., Akiki, C., Pavlick, E., Ilić, S., Hesslow, D., Castagné, R., Luccioni, A.S., Yvon, F., Gallé, M., et al.: Bloom: A 176b-parameter open-access multilingual language model (2023)

11. Ma, S., Wang, H., Ma, L., Wang, L., Wang, W., Huang, S., Dong, L., Wang, R., Xue, J., Wei, F.: The era of 1-bit llms: All large language models are in 1.58 bits. arXiv preprint arXiv:2402.17764 (2024)

12. Micikevicius, P., Stosic, D., Burgess, N., Cornea, M., Dubey, P., Grisenthwaite, R., Ha, S., Heinecke, A., Judd, P., Kamalu, J., et al.: Fp8 formats for deep learning. arXiv preprint arXiv:2209.05433 (2022)

13. Paglieri, D., Dash, S., Rocktäschel, T., Parker-Holder, J.: Outliers and calibration sets have diminishing effect on quantization of modern llms. arXiv preprint arXiv:2405.20835 (2024)

14. Shen, H., Mellempudi, N., He, X., Gao, Q., Wang, C., Wang, M.: Efficient post-training quantization with fp8 formats. Proceedings of Machine Learning and Systems 6, 483–498 (2024)

15. Son, S., Park, W., Han, W., Kim, K., Lee, J.: Prefixing attention sinks can mitigate activation outliers for large language model quantization. arXiv preprint arXiv:2406.12016 (2024)

16. Sun, M., Chen, X., Kolter, J.Z., Liu, Z.: Massive activations in large language models. arXiv preprint arXiv:2402.17762 (2024)
17. Sutawika, L., Gao, L., Schoelkopf, H., Biderman, S., Tow, J., Abbasi, B., ben fattori, Lovering, C., farzanehnakhaee70, Phang, J., Thite, A., Fazz, Aflah, Muen-nighoff, N., Wang, T., sdtblck, nopperl, gakada, tttyuntian, researcher2, Chris, Etxaniz, J., Kasner, Z., Khalid, Hsu, J., AndyZwei, Ammanamanchi, P.S., Groen-eveld, D., Smith, E., Tang, E.: Eleutherai/lm-evaluation-harness: Major refactor (Dec 2023). https://doi.org/10.5281/zenodo.10256836, https://doi.org/10.5281/zenodo.10256836

18. Touvron, H., Martin, L., Stone, K., Albert, P., Almahairi, A., Babaei, Y., Bash-lykov, N., Batra, S., Bhargava, P., Bhosale, S., et al.: Llama 2: Open foundation and fine-tuned chat models. arXiv preprint arXiv:2307.09288 (2023)

19. Wang, H., Ma, S., Dong, L., Huang, S., Wang, H., Ma, L., Yang, F., Wang, R., Wu, Y., Wei, F.: Bitnet: Scaling 1-bit transformers for large language models. arXiv preprint arXiv:2310.11453 (2023)

20. Xiao, G., Lin, J., Seznec, M., Wu, H., Demouth, J., Han, S.: Smoothquant: Accurate and efficient post-training quantization for large language models. In: International Conference on Machine Learning. pp. 38087–38099. PMLR (2023)

21. Yang, J., Kim, H., Kim, Y.: Mitigating quantization errors due to activation spikes in glu-based llms. arXiv preprint arXiv:2405.14428 (2024)