원시데이터 수집 시스템
선정목록으로

Divergent Token Metrics: Measuring degradation to prune away LLM components – and optimize quantization

관련 모빌리티 소재 · (4) 카시트 모듈

기본 정보

저자
  1. Björn Deiseroth
  2. Max Meuer
  3. Nikolas Gritsch
  4. Constantin Eichenberg
  5. Patrick Schramowski
  6. Matthias Aßenmacher
  7. Kristian Kersting
DOI
10.18653/v1/2024.naacl-long.377
저널
–
발행년도
2024
발행기관
–
피인용수
2
라이선스
cc-by
논문 유형
–
언어
–
원문 페이지
https://doi.org/10.18653/v1/2024.naacl-long.377
토픽
Advancements in Photolithography Techniques
OpenAlex ID
W4401042820

평가 내용

관련도
관련
사업분야
모빌리티 소재 · (4) 카시트 모듈
부 분야
–
R&D 측면
–
확신도
–
근거 용어
–
판단 근거
임베딩 유사도 기반 평가로 '모빌리티 소재 > 카시트 모듈' 분야에 선정된 논문입니다.
R&D 활용 포인트
–
평가 입력
–

초록

Björn Deiseroth, Max Meuer, Nikolas Gritsch, Constantin Eichenberg, Patrick Schramowski, Matthias Aßenmacher, Kristian Kersting. Proceedings of the 2024 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies (Volume 1: Long Papers). 2024.

본문 72,305자

본문 펼치기
# Divergent Token Metrics: Measuring degradation to prune away LLM components – and optimize quantization Björn Deiseroth <sup>1</sup> <sup>_,_</sup> <sup>2</sup> <sup>_,_</sup> <sup>3</sup> Max Meuer <sup>1</sup> Nikolas Gritsch <sup>1</sup> <sup>_,_</sup> <sup>5</sup> Constantin Eichenberg <sup>1</sup> {bjoern.deiseroth, max.meuer, nikolas.gritsch, constantin.eichenberg}@aleph-alpha.com Patrick Schramowski <sup>2</sup> <sup>_,_</sup> <sup>3</sup> <sup>_,_</sup> <sup>4</sup> Matthias Aßenmacher <sup>5</sup> <sup>_,_</sup> <sup>6</sup> Kristian Kersting <sup>2</sup> <sup>_,_</sup> <sup>3</sup> <sup>_,_</sup> <sup>4</sup> patrick.schramowski@dfki.de matthias@stat.uni-muenchen.de kersting@cs.tu-darmstadt.de 1 Aleph Alpha @ IPAI 2 Technical University Darmstadt 3 Hessian Center for Artificial Intelligence (hessian.AI) 4 German Center for Artificial Intelligence (DFKI) 5 Department of Statistics, LMU 6 Munich Center for Machine Learning (MCML) Abstract Large Language Models (LLMs) have reshaped natural language processing with their impressive capabilities. However, their everincreasing size has raised concerns about their effective deployment and the need for LLM compression. This study introduces the _Diver-_ _gent Token_ Metrics (DTMs), a novel approach to assessing compressed LLMs, addressing the limitations of traditional perplexity or accuracy measures that fail to accurately reflect text generation quality. DTMs measure token divergences that allow deeper insights into the subtleties of model compression, in particular, when evaluating components’ impacts individually. Utilizing the _First_ _Divergent_ _To-_ _ken_ Metric (FDTM) in model sparsification reveals that 25% of all attention components can be pruned beyond 90% on the Llama-2 model family, still keeping SOTA performance. For quantization, FDTM suggests that more than 80% of the parameters can be naively transformed to int8 without special outlier management. These evaluations indicate the necessity of choosing appropriate compressions for parameters individually—and that FDTM can identify those—while standard metrics result in deteriorated outcomes. 1 Introduction Cutting-edge Large Language Models (LLMs) based on the transformer architecture (Vaswani et al., 2017) have revolutionized Natural Language Processing with their exceptional performance, notably exemplified by the GPT series (Radford et al., https://github.com/Aleph-Alpha/Divergent_Tokens 2018, 2019; Brown et al., 2020; Bubeck et al., 2023) in text generation. However, these models have grown massively, even exceeding half a trillion parameters (Chowdhery et al., 2023). Although the large number of parameters aid in early training convergence, their practical utility and true necessity remain unclear. In particular, for the attention mechanism, it was hinted that after some training convergence, certain heads dominate the inference process (Michel et al., 2019). Compression strategies such as sparsification and quantization can enhance the efficiency of the parameters. Current metrics, however, either average too coarsely, such as perplexity, or are by design too specific, such as standard NLP benchmarks. Both fail to capture the diverging performance nuances introduced early on by the compression as they ignore the actual discontinuous text generation process. This, however, is the main application of the final model, and so we argue that they are therefore insufficient measures for the performance of the compressed model. This misalignment can lead to unwanted subtle discrepancies in generation, such as grammatical errors or a mismatch in numbers, that cause subsequent divergences. As we will show, this even occurs when overall metrics, such as perplexity, appear satisfactory ( _cf._ Prop. 3.2, Sec. 4, Tab. 1). To meet these challenges, we introduce the family of _Divergent Token_ Metrics (DTMs) in Sec. 3. These metrics are tailored to measure the _model_ _divergence_ of LLMs throughout the compression process and in relation to the actual generation procedure on a token basis, as shown in Fig. 1. We 6764 _Proceedings of the 2024 Conference of the North American Chapter of the Association for Computational Linguistics:_ Figure 1: Illustration of a diverging generation process. Given the 3-token prefix as prompt, a baseline and its compressed model generate 8 subsequent tokens. Our proposed metric points to the first divergent token (FDT). The FDT may cause further divergence during the iterative generation process. Note how both models score the same perplexity value, as it does not reflect the actual sampling process ( _cf._ Fig. 2, Sec. 4 for an empirical exploration). demonstrate that the _First Divergent Token_ Metric (FDTM) and the _Share of Divergent Tokens_ Metric (SDTM) offer a more nuanced evaluation compared to perplexity. They also enable individual component evaluation to rank parts of the model best suited for compression, thus enabling meaningful compression while preserving text generation quality. Based on FDT probing, we introduce new strategies for sparsifying and quantizing models in Sec. 4. Specifically, our proposed individual component sparsification indicates significant differences in component utilization across layers. For the first time, we show that 25% percent of the models’ attention components can be pruned beyond 90%, and several even entirely removed, while preserving a single-digit perplexity. Consequently, a sparse matrix format can be employed to accelerate computational efficiency. Likewise, for precision reduction, we show that sorting components by FDTM coincidentally correlates to sorting by their induced number of outliers when being naively converted to int8. FDTM identifies the optimal 80% of the components that maintain overall performance without specific outlier handling. The observed decline in performance with more outliers, and the significant influence of specific components on those, suggests reevaluating the applied normalization methods throughout the model. We demonstrate that this level of precision goes beyond what standard perplexity and conventional NLP benchmarks can achieve. The proposed Divergent Token Metrics closely reflect the generation process and so can be a measure to foster confidence in the deployed compressed models. 2 Compression Principles Model compression aims to reduce the hardware resources needed to operate the model. However, doing so may sacrifice the accuracy of the model. To keep the loss as small as possible, a corrective measure is typically used. Here, we discuss the most commonly used concepts and state-of-the-art methods for LLM sparsification and quantization. Outlier and Hessians. Most model compression methods rely either on the separation of outliers (Dettmers et al., 2022; Sun et al., 2023) or the computation of a Hessian matrix (Frantar et al., 2023; Frantar and Alistarh, 2023). Outliers usually refer to significantly larger values in magnitude occurring either in the weight matrix directly or in the activations during a forward pass. As most computations are linear matrix multiplications, such outliers strongly influence the remaining entropy contained in consecutive computations. In the case of sparsification, outliers should be left intact, and values with the least magnitude, which are consequently the least influential, should instead be masked (Han et al., 2015). On the other hand, Hessian matrices can be applied to correct errors (Frantar et al., 2023). They can effectively be approximated by computing backpropagation gradients for a small number of samples and represent a second-order approximation to reconstruct the original model. Sparsification. The goal of sparsification is a reduction in the total number of weights and therefore a distillation of the relevant computation. Typically, this method is divided into “structured” and “unstructured” pruning. _Structured-pruning_ aims to locate dynamics, such as the irrelevance of an entire layer or dimension for a given use case, and prunes these entirely. _Unstructured-pruning_ usually refers to weight masking, that is, setting irrelevant weights to 0. High levels of sparse matrix computations could result in more efficient kernels and computations. In scenarios where masks exceed a 90% threshold, the implementation of a specialized sparse matrix format becomes feasible. This format predominantly stores the indices of non-zero weights. Although some additional storage is required for these indices, the overall requirement is reduced due to the exclusion of zero 6765 values. Moreover, this approach substantially improves computational performance. _Magnitude_ _pruning_ selects the masking of weights based only on their magnitudes. This is fast to compute but significantly degrades model performance when pruning large amounts simultaneously. To resolve this issue, _wanda_ (Sun et al., 2023) proposes to sample a small amount of data and incorporates activations of the forward pass. This was shown to generate more effective one-shot pruning masks. _SparseGPT_ (Frantar and Alistarh, 2023) computes iterative Hessian approximations to select the lowest impact weights and correct the remaining. Note that the incorporation of activations can, to some extent, be interpreted as a form of training. Moreover, despite these efforts, one-shot pruning has not yet produced directly usable models without further final fine-tunings. This is in particular the case for the high sparsity levels beyond 70% that we target. Finally, there has not yet been any investigation of the individual components. Quantization. Model quantization refers to the reduction of the precision of the used numerical format. Usually, LLMs are trained in 16-bit floating point (fp16) and converted to 8-bit integer (int8) representations. The naive conversion of float matrices to integers is _AbsMax_ rounding. This divides a number by the maximum value occurring in the matrix and multiplies by the largest available integer, as such, it spans a uniform representation grid. The largest float value is stored and multiplied for dequantization. The most prominent methods for minimizing the introduced rounding errors are LLM.int8 and GPTQ. Dettmers et al. (2022) introduced _LLM.int8()_, which identifies vectors containing outliers and retains them in their original fp16 form during the matrix multiplication of a forward pass. The vectors lacking outliers are fully quantized. The int8 weights and activations during the forward pass are subsequently multiplied and dequantized afterward. This allows them to be integrated with the fp16 representation of the outliers. Through empirical investigation optimizing the trade-off between degradation in perplexity and the number of outliers preserved in fp16, they fixed an absolute outlier threshold. The _GPTQ_ framework offers a more robust quantization approach, in particular, to different integer bit precisions. It does not rely on any outlier detection mechanism or mixed precision computations— matrix multiplications with the weights are fully performed using integers. Frantar et al. (2023) introduce an efficient Hessian approximation and iteratively quantize the weights of the matrices while performing error corrections on the remaining weights. 3 Model Divergence Metrics Perplexity fails to identify minor variations in model degradation at an early stage. This behavior is depicted in Fig. 1 and 2 and discussed in Sec. 3.5 and 4 in more detail. To assess model divergence and enhance the model compression process, we introduce token-based metrics specifically designed to detect those nuances occurring in early compression stages. We start by establishing our notation and presenting the perplexity metric (PPL). Subsequently, we introduce an enhanced variant of PPL and propose the _Share of Divergent Tokens_ Metric (SDTM) and _First Divergent Token_ Metric (FDTM). We conclude by discussing the advantages of each metric compared to traditional measures based on perplexity when assessing the degradation of the generative performance of compressed models. 3.1 Basic notation Let _F_ denote an auto-regressive model over a vocabulary _V_ = _{_ 0 _,_ 1 _, ..., |V| −_ 1 _}_, _y_ = ( _y_ 1 _, .., yN_ ) _∈V_ <sup>_N_</sup> an arbitrary token sequence and _F_ ( _y_ ) = _F_ ( _y_ ) _ij_ _∈_ R <sup>_N_</sup> <sup>_×|V|_</sup> the model logits, with _i_ denoting the sequence and _j_ the respective vocabulary positions. Given a prefix length _n < N_, we denote the token prefix _y_ : _n_ = ( _y_ 1 _, ..., yn_ ) and the greedily decoded completion up to index _N_ by _G_ ( _F, y_ : _n, N_ ). It is defined recursively as follows: _G_ ( _F, y_ : _n, N_ ): _n_ = _y_ : _n_, and for _n ≤_ _i ≤_ _N_ _−_ 1 _G_ ( _F, y_ : _n,N_ ) _i_ +1 = arg max _j F_ ( _G_ ( _F, y_ : _n, N_ ): _i_ ) _ij._ 3.2 Perplexity (PPL) Given a ground truth sequence _y_ and model _F_, the negative log-likelihood of _y_ given _F_ is NLL( _y, F,n_ ) = _−_ _N_ <u>1</u> _−n_ _i_ = _n_ <sup>log P(</sup> <sup>_yi_</sup> <sup>+1</sup> <sup>_|yi, .., y_</sup> <sup>1)</sup> <sup>_,_</sup> - _N_ _−_ 1 with P( _yi_ +1 _|yi, .., y_ 1) = (softmax _F_ ( _y_ )) _iyi_ +1. Then the _perplexity (PPL)_ is given by PPL( _y, F, n_ ) = exp(NLL( _y, F, n_ )) _._ 6766 1000 800 600 400 200 0 FDT SDT DPPL PPL Figure 2: Pruning lowest weights, and random weights. FDT is able to discriminate the cases. PPL exactly performs on the level of guessing. _Cf._ Sec. 4.2. A common practice in the literature, e.g. (Dettmers et al., 2022), is to measure model degradation as the increase in average perplexity over a given test dataset _D_, e.g. randomly sampled from C4 (Raffel et al., 2020). Usually, this metric is computed disregarding the prefix, i.e., with PPL( _y, F_ ) := PPL( _y, F,_ 1). 3.3 Context aware model comparison First, we argue that standard evaluation does not reflect the typical generative model usage, i.e., there are no empty prompts, and as such, those positions should not be taken into account when evaluating the generative performance. Moreover, when comparing a compressed model _F_ <sup>_′_</sup> to the original model _F_, one is interested to what extent _the origi-_ _nal behavior is kept_ . Therefore, we propose to use the outputs of the original model _F_ as a ground truth to assess the performance of the compressed model _F_ <sup>_′_</sup> . This leads to the definition of the _diver-_ _gent perplexity (DPPL) metric_ as _M_ DPPL( _F,F_ <sup>_′_</sup> _, y_ : _n, N_ ) (1) = PPL( _G_ ( _F, y_ : _n, N_ ) _, F_ <sup>_′_</sup> _, n_ ) _._ Finally, let _D_ be an arbitrary test dataset containing documents of potentially varying length. For a fixed prompt length _n_ and completion length _N_, we define the _aggregated divergent perplexity metric_ as the complete evaluation on the dataset: the _share of divergent tokens (SDT)_ as follows: SDT( _y,F, n_ ) = _|{i ≥_ _n_ : arg max _j_ _F_ ( _y_ ) _ij̸_ = _yi_ +1 _}|,_ SDT( _y, F, n_ ) can be interpreted as the number of times the model would need to be corrected during decoding to match the ground truth after consuming the prefix. This measure provides a more direct interpretation of the errors that occur during actual token generation, as opposed to estimating prediction certainties as PPL does. FDT. In addition to SDT, we introduce the _first_ _divergent token (FDT)_ as FDT( _y, F, n_ ) (3) _M_ DPPL( _F, F_ <sup>_′_</sup> _, n, N_ ) = (2) <u>1</u> = min _{i ≥_ _n_ : arg max _j_ _F_ ( _y_ ) _i,j̸_ = _yi_ +1 _} −_ _n,_ with the convention that the minimum is equal to _N_ if the set on the right-hand side is empty. Analogously to Eq. 1 and Eq. 2, we define _M_ SDT _, M_ FDT, _M_ SDT and _M_ FDT in the same way. As an illustrative example, consider computing _M_ FDT( _F, F_ <sup>_′_</sup> _, y_ : _n, N_ ). We first perform a greedy decoding of _N_ _−_ _n_ tokens with the base model _F_ given the prefix _y_ : _n_ . We then feed the sequence _G_ ( _F, y_ : _n, N_ ) into the compressed model _F_ <sup>_′_</sup> and find the first index greater than or equal to _n_, where the logit argmax of _F_ <sup>_′_</sup> differs from what _F_ generated. This computation can be done in a single forward pass similar to perplexity, and so is more efficient than accuracy-based evaluations. Trivially, 0 _≤_ _M_ FDT( _F, F_ <sup>_′_</sup> _, y_ : _n, N_ ) _≤_ _N_ _−_ _n_, where the upper bound is reached if and only if _F_ and _F_ <sup>_′_</sup> would generate the exact same sequence up to position _N_ given the prefix _y_ : _n_ . Further note that _M_ FDT is symmetric, i.e. _M_ FDT( _F, F_ <sup>_′_</sup> _, y_ : _n, N_ ) = _M_ FDT( _F_ <sup>_′_</sup> _, F, y_ : _n, N_ ), in contrast to PPL. In the following, we will ease the notation and omit _M_, some parameters, or the words aggregated and metric, when they are clear from the context. 3.5 Token vs. Perplexity Metrics It turns out that divergent token metrics offer a superior criterion for analyzing model performance degradation compared to perplexity-based metrics, especially in the context of greedy decoding. The main reason is that the greedy decoding operation _G_ is a discontinuous function of the logits. To formalize this, let us discard the model itself and focus notation solely on the concept of logits. Definition 3.1. _The operators and metrics from pre-_ _vious sections defined for models F, F_ <sup>_′_</sup> _are defined_ <u>1</u> _|D|_ _y∈D_ <sup>_M_</sup> <sup>DPPL(</sup> <sup>_F, F ′, y_</sup> <sup>:</sup> <sup>_n, N_</sup> <sup>)</sup> <sup>_._</sup> DPPL already substantially improves discrimina-� DPPL already substantially improves discriminative capabilities over PPL, as we will demonstrate in the empirical evaluation. 3.4 Divergent Token Metrics SDT. To further improve on the expressiveness and interpretability of model divergence, we propose 6767 _for_ _logits_ _l, l_ <sup>_′_</sup> _∈_ R <sup>_N_</sup> <sup>_×|V|_</sup> _by_ _replacing_ _all_ _occur-_ _rences of F, F_ <sup>_′_</sup> _with l, l_ <sup>_′_</sup> _._ For example, _G_ ( _l, y_ : _n, N_ ) _i_ +1 = arg max _j lij_, for _n ≤_ _i ≤_ _N_ . Proposition 3.2. _Given any y, N_ _and ε >_ 0 _there_ _exist logits l, l_ <sup>_′_</sup> _∈_ R <sup>_N_</sup> <sup>_×|V|_</sup> _such that_ _|_ PPL( _y, l,_ 1) _−_ PPL( _y, l_ <sup>_′_</sup> _,_ 1) _| < ε,_ _M_ SDT( _l, l_ <sup>_′_</sup> _, y_ :1 _, N_ ) = _N._ _Proof._ See App. A. This means that even if the average perplexity of a compressed model matches the perplexity of the original model, the compressed model can produce a very different (and potentially worse) output when performing greedy decoding. Hence leading to a false positive. In practice, this is a severe issue since even a single diverging token can lead to a completely different subsequent output. It is illustrated in Fig. 1 and 2 and discussed in Sec. 4.2. As described above, another option is to compute the perplexity with respect to the generated completions of the original model. This metric relates more reasonably to the share of divergent tokens (SDT): Proposition 3.3. _The following upper bound holds:_ _M_ SDT( _l, l_ <sup>_′_</sup> _, y_ : _n, N_ ) _≤_ <sup>_<u>N</u>_</sup> log 2 <sup>_<u>−n</u>_</sup> <sup>log</sup> <sup>_M_</sup> <sup>DPPL(</sup> <sup>_l, l′, y_</sup> <sup>:</sup> <sup>_n, N_</sup> <sup>)</sup> <sup>_._</sup> _Proof._ See App. A. However, a comparable lower bound generally does not hold. In fact, in the case _l_ = _l_ <sup>_′_</sup> we trivially have _M_ SDT( _l, l, y_ : _n, N_ ) = 0. Further, the value of _M_ DPPL( _l, l, y_ : _n, N_ ) can still be as high as the maximal value, which occurs when _l_ is a perfectly flat distribution at any sequence index. This could lead to a false negative signal for the generation process. In conclusion, perplexity-based metrics suffer from false positives or false negatives when evaluating the degradation of generative performance. The case for FDT and SDT is quite straightforward in that they both directly measure the difference between model outputs in a _what-you-see-is-what-_ _you-get_ manner. Note that additional token-based metrics, such as the measurement of the distance between erroneous predictions, can be readily formulated. These metrics may prove especially valuable when assessing potential benefits, for instance, in the context of correction-based inference strategies such as speculative decoding (Leviathan et al., 2023). App. I further discusses the use of ground-truth versus model generated probes. We now empirically demonstrate the improvements of well-known compression methods using our metrics. 4 Token Metrics Improve Model Compression We will demonstrate in the following how the pro posed metrics provide novel insights into the efficiency of the architecture of LLMs and establish benchmarks for model compression. Throughout all experiments, we outperform standard PPL as a ranking metric. More precisely, we apply componentwise probing to sparsification to determine individual sparsity rates. Interestingly, the model tends to completely remove components of the attention mechanism in certain layers. In total, 40 out of 160 attention components are sparsed beyond 90% and 15 removed completely. For quantization, on the other hand, we show how component selection significantly influences the overall number of model outliers. For the first time, almost 10% of the model components can be converted to 4-bit integer representations without significant model degradation. 4.1 Experimental Protocol Let us start by clarifying the experimental setup. Test environment. All experiments were performed on the public Llama2-7B and 13B models (Touvron et al., 2023). Note, however, that we observed similar behavior amongst other decoder transformer models. It remains, in particular, with upscaled sizes and smaller variations on the architecture or the training procedure. For all experiments, we follow best practices for compression evaluations (Sun et al., 2023) and randomly sample data from the C4 dataset (Raffel et al., 2020) for training iterations. The final model evaluation is performed comparing the loss on the Wikitext2 dataset (Merity et al., 2017) and the standard NLP benchmarks (Gao et al., 2021). Metrics. We apply our proposed metrics for performance evaluation, as well as selection criteria. We employ FDT, SDT, DPPL and PPL as metrics to assess the overall model divergence. With regard to model compression, we demonstrate that both PPL and our variant DPPL typically struggle to measure minor changes adequately ( _cf._ Sec. 3.5, 4.2 and Fig. 2). However, FDT is particularly suited to 6768 <u>Algorithm 1</u> <u>Iteration of pruning algorithm</u> input: _F, step_ _▷_ current model, target sparsity 300 200 100 50 25 FDT75 std 0.07 0.06 0.05 0.04 0.03 0.02 0.01 fdt_sparse_map _←{}_ for _ci_ _∈_ Components do 10 <u>0.1</u> <u>1.0</u> <u>4.0</u> Sparsification step (%) 0.00 fdt_sparse_map[ _ci_ ] _←_ [100 _,_ _M_ FDT75( _F, F_ <sup>_ci_</sup> <sup>+</sup> <sup>_step/_</sup> <sup>2</sup> ) _,_ _M_ FDT75( _F, F_ <sup>_ci_</sup> <sup>+</sup> <sup>_step_</sup> <sup>+</sup> <sup>_step/_</sup> <sup>2</sup> ) _,_ 0] Figure 3: Hyperparameter selection of FDT. Visualized is the standard deviation (std) in FDT75 over all components when varying prefix length (y-axis) and applying different choices for sparsity-step increases (x-axis), _cf._ Sec. 4.1 and 4.2. characterize errors for subtle model changes. Consequently, we apply FDT for model compression. In the following paragraph, we describe the parameters selected for using FDT in more detail. Divergent Token Parameters. We empirically selected hyperparameters as follows. Through preliminary sparsification experiments, we observed that the most variance is present in the 75%quantile of FDT, as defined in Eq. 3 ( _cf._ Fig. 22). We denote this value by _FDT_ 75. In the following, it is our compare-to value. Next, we sweep over the given _context_ _prefix_ _length_ _n_ of FDT and sparsification steps as depicted in Fig. 3 on the y- and x-axis, respectively. The heatmap shows the overall standard deviation of FDT75 on 5k probes. For simplicity, we fixed the prefix length to 100 tokens, as it is most discriminative on average. We observed that most of the sparsification steps introduce an error in FDT75 within the range of 100 _completion_ _tokens_ . Therefore, we selected _N_ = 100. Finally, to determine the _number_ _of_ _probes |D|_, we compared the mean deviation with a baseline of 5000 probes. As the deviation in the value of _MF_ 75 of 1000 to 5000 probes only differs on average by a value 4, we selected _|D|_ = 1000 ( _cf._ Fig. 20). Pruning of LLMs. In Sec. 4.2, we will show that FDT improves sparsification procedures to achieve high compression rates on LLama2-13B. To this end, we iterate small unstructured sparsification with continued training steps for the model to attune to the remaining weights and recover performance. Specifically, we apply eight iterations to increase the average model sparsity by 20 _,_ 15 _,_ 10 _,_ 10 _,_ 5 _,_ 5 _,_ 5 _,_ and 5 percent, resulting in a final model with 25% total parameters remaining. We run this experiment in two configurations, normalized sparsity of such that <sup>�</sup> _i_ <sup>_s_</sup> <sup>˜</sup> <sup>_i_</sup> <sup>=</sup> <sup>_step_</sup> <sup>using</sup> <sup>_s_</sup> <sup>˜</sup> <sup>_i_</sup> <sup>to</sup> <sup>represent</sup> <sup>the</sup> normalized sparsity of _si_ relative to the individual such that <sup>�</sup> _▷_ FDT values measured for added sparsities of 0, _step/_ 2, _step_ + _step/_ 2, 100% to component _ci_ on model _F_ . The maximal FDT value measured is 100. end for _f_ _←_ 100 _▷_ iteratively decrease from maximum _s ←_ 0 _▷_ track current added sparsity comp_sparse_map _←{}_ while _s ≤_ _step_ and _f_ _≥_ 0 do for _ci_ _∈_ Components do comp_sparse_map[ _ci_ ] _←_ _lin_ _ _interpol_ ( _lin_ _ _interpol_ (fdt_sparse_map[ _ci_ ] _, f_ ) end for _s ←_ _weighted_ _ _mean_ (comp_sparse_map) _f_ _←_ _f_ _−_ 1 end while _F_ <sup>_′_</sup> _←_ _F_ pruned by comp_sparse_map <u>output:</u> _F_ <sup>_<u>′</u>_</sup> uniform and FDT-selective. Uniform sparsification applies the target increase of the current round uniformly to each component, pruning their lowest weights. For FDT, we determine individual component sparsification values to evenly distribute the induced error as depicted in Algorithm 1: Based on the previous sparsed model _F_ and for the current target increase _step_, we probe each component _ci_ separately with an additional _step±step/_ 2 percent of the lowest weights pruned, denoted by _F_ <sup>_ci_</sup> <sup>+</sup> <sup>_s_</sup>, to determine its _MFDT_ 75 value. We further add the constant extrema, that is, step sparsity 0 and 100% with values of 100 and 0. Given these four data points, we segment-wise interpolate linearly to achieve the highest value of _MFDT_ 75 possible across all components, but on average yielding the target sparsity. Specifically, we find the set of component-sparsities _{si}_ that optimize for arg max _{si}_ min _i M_ FDT75( _F, F_ <sup>_ci_</sup> <sup>+</sup> <sup>_si_</sup> ) _,_ 6769 3.0 2.5 2.0 Uniform FDT (our) 0 500 1000 1500 2000 2500 3000 3500 4000 Training Step <u>1e7</u> 80 60 40 20 PPL LLM.Int8() 0 50 100 150 200 No. Quantized Components FDT DPPL | 0.025 0.020 0.015 0.010 0.005 0.000 1.25 1.00 0.75 0.50 0.25 0.00 (a) Comparison of uniform and componentwise pruning using FDT as a metric for comparison. (a) Performance of FDT, DPPL and PPL. 100 90 80 70 60 50 40 Comp. Type A. Query A. Key A. Value A. Dense MLP Up MLP Down MLP Gate 30 20 10 0 0 50 100 150 200 Component Type MLP Gate MLP Down MLP Up A. Query A. Key A. Value A. Dense 0 50 100 150 200 No. Quantized Components 0 5 10 15 20 25 30 35 40 Layer (b) Converged component config with 75% average sparsity. Layers (x-axis), Component-sparsity (y-axis). Figure 4: Depiction of the proposed sparsification process that converged to a 75% sparse Llama-2-13B. a) Model training performance throughout all rounds. Our FDT-based sparsification clearly outperforms uniform magnitude pruning. b) Converged sparsity values per component. One quarter of attention components are pruned beyond 90% sparsity. Significant outliers appear in first and last layers. parameters of component _ci_ . We further follow the findings of AC/DC (Peste et al., 2021) and alternate compressed and decompressed iterations as follows: Each round we train a total of 500 steps, of which the first 450 are with the sparsification mask applied and the following 50 without any masks. We found that this alternation produces smaller spikes in training loss after sparsification steps. This yields a total of 4000 training steps. During training, we apply a weight decay of 0 _._ 01, batch size 256, and sequence length 2048. Note that throughout this series of experiments, we only apply pure magnitude pruning per iteration. Other pruning methods, such as wanda (Sun et al., 2023), can also be straightforwardly augmented by this probing strategy. Quantization of LLMs. For model quantization, we compare the performance of the proposed metrics on the task of sorting the model’s components by their lowest introduced error. To this end, we build a search tree to find the best model configuration as follows: We build a parallel depth-first search tree with a branching width of 10, which (b) Selected Components FDT (top) vs PPL (bottom). Figure 5: Evaluation of the Tree Search as described in text. a) Comparison of Tree Search based componentwise quantization. Different numbers of components (x-axis) lead to different token divergence scores (y-axis, normalized to [0 _,_ 1]), and in particular correlates early on to introduced outliers (second y-axis). Throughout the entire search, FDT is able to rank components by their potential errors and, coincidentally, outliers. b) Selected components at respective depth. A.Key and A.Value induce most error. relates to a beam search with beam width 10. In particular, at each level of the tree, we simultaneously explore all possible successor configurations for the currently top-10 performing nodes, with one more component naively quantized using AbsMax. From this newly identified set of nodes, we again select the best performing 10 nodes for the next iteration. Starting with the unquantized base model Llama2-7B, each node contains exactly the number of quantized components respective to its depth, while the final node is a fully AbsMax quantized model. We further apply deduplication to prevent redundant computations. 4.2 Sparsification reveals: Attention is not all you need! We applied stepwise uniform magnitude pruning, and our balanced componentwise pruning using FDT, to achieve 75% model sparsity. A summary of the results is shown in Fig. 4. Attention almost erased. Fig. 4b visualizes the converged sparsity values when applying our balanced pruning using FDT. Notably, the model 30 20 10 0 6770 Sparsification <u>Model</u> <u>FDT</u> _<u>↑</u>_ <u>PPL</u> _<u>↓</u>_ <u>NLP</u> _<u>↑</u>_ <u>Llama2-13B</u> <u>-</u> <u>4.884</u> <u>53.59</u> _<u>∼</u>_ <u>60% sparse (unif.)</u> <u>4.7</u> <u>9.244</u> <u>46.32</u> _<u>∼</u>_ <u>60% sparse (our)</u> <u>7.9</u> <u>6.242</u> <u>48.89</u> _<u>∼</u>_ <u>75% sparse (unif.)</u> <u>3.5</u> <u>13.512</u> <u>41.67</u> _<u>∼</u>_ <u>75% sparse (our)</u> <u>5.5</u> <u>8.101</u> <u>46.32</u> _∼_ <u>80% sparse (our)</u> <u>5.2</u> <u>9.531</u> <u>45.66</u> Quantization <u>Model</u> <u>FDT</u> _<u>↑</u>_ <u>PPL</u> _<u>↓</u>_ <u>NLP</u> _<u>↑</u>_ <u>Llama2-7B</u> <u>-</u> <u>5.472</u> <u>50.79</u> <u>LLM.int8()</u> _all_ <u>36.1</u> <u>5.505</u> <u>50.81</u> AbsMax PPL150 46.3 5.500 50.72 AbsMax DPPL150 54.1 5.490 50.75 <u>AbsMax FDT150</u> (our) <u>71.7</u> <u>5.489</u> <u>50.75</u> <u>GPTQ</u> _all_ <u>11.1</u> <u>5.665</u> <u>48.34</u> GPTQ PPL16 45.0 5.511 49.91 GPTQ DPPL16 137.0 5.476 50.02 GPTQ FDT16 (our) 205.0 5.475 50.13 Table 1: Evaluations of the final Compressed Models. Even when evaluating these, aggregations of standard NLP benchmarks ( _cf._ Fig. 11,13) do not reflect the actual degradation of the model, as observed in AbsMax quantization. FDT and PPL are evaluated on Wikitext2 samples. Throughout all experiments, our FDT probed compression outperforms standard variations. Subscript refers to best found _k_ quantized components. Bold denotes the best values. favors pruning attention over MLP. In total 40 of 160 attention components are sparsed beyond 90% and 15 even completely removed. In general, the second half of the model appears to be more prunable than the first half. The value matrices are overall the least pruned of the attention matrices. Finally, significant outliers appear in the first and last layers. This finding indicates that attention is not utilized efficiently throughout model inference. In fact, only layers 3 to 20 and layer 40 appear to be of significant relevance for the model’s final prediction. This observation might be attributed to an evolving shift in distributions and, with that, the concepts processed in embeddings. Notably, in the first layer Attention Value and MLP Down remain significantly dense, while all others are comparably sparse. This observation indicates an incomplete shift of token embeddings. General Observations. As shown in Fig. 4a, FDT based balanced pruning significantly lowers the introduced error between sparsification rounds. Uniform pruning, on the other hand, substantially diverged, and in particular does not regain performance with the given amount of compute. Generally speaking, what is lost can hardly be recovered. The standard evaluation of FDT and PPL on Wikitext2, is found in Tab. 1. The 75% compressed 13B model, with several components pruned away, scored PPL 8.1, compared to PPL 4.8 of the base model. Note that no other model sparsed beyond 70% has yet been reported, in particular, achieving single-digit PPL. Uniform pruning achieved 13.5. Further note, that we almost doubled the mean FDT value when compared to uniform pruning. However, as the generally low FDT value suggests, it still diverged substantially from the base model. FDT is more discriminative. In practice, FDT is better able to discriminate subtle changes than PPL. We demonstrate this with the following experiment: On each component of the model, we prune 0.1% of the weights either randomly or from the lowest weights. The resulting model is probed for 1000 trials with all the discussed metrics used to distinguish the cases. The results in Fig. 2 clearly indicate that FDT is capable of distinguishing the cases, while they remain indifferent for PPL-based comparison. We therefore omit using PPL as a metric to determine step-sizes for the described sparsification experiment. 4.3 Quantization: Outliers can be prevented Finally, we demonstrate the impact of selecting the right components for quantization. We compare the proposed metrics PPL, DPPL, and FDT as ranking criteria to showcase their discrimation capabilities. Quantization without outlier-handling. Fig. 5 shows the average performance of the top 10 nodes occuring in the respective search tree depth (x-axis). FDT continuously outperforms the other metrics on the SDT value (y-axis). Notably, this is on par with the total number of outliers occurring for the respective configurations (second y-axis). Certain components appear to significantly influence the decline observed in both measures. Although DPPL enhances some aspects of performance, neither variant of PPL effectively distinguishes these components and tends to select those prematurely. With FDT, we can cast 80%, _i.e._ 150, of the model’s components directly into int8 using only naive AbsMax—and without further outlier handling—still outperforming the full LLM.int8() conversion in model performance. Selecting those 150 components with DPPL and FDT leads to close perplexity scores 5 _._ 490 and 5 _._ 489 on Wikitext2, _cf._ Tab. 1. However, the resulting mean FDT improves by almost 50% when also selecting the components by this metric. The larger generation of the same sequences suggests a model closer to the orig 6771 500 400 300 200 100 0 A. Query A. Key A. Value A. Dense MLP Up MLP Gate MLP Down Component (a) Quantization methods evaluated on Components. 4 8 16 32 64 96 128 160 192 No. Quantized Components Method AbsMax LLM.int8() GPTQ (8bit) GPTQ (4bit) 500 400 300 200 100 0 Criteria FDT DPPL (b) Selected GPTQ ( <mark>4bit</mark> ) com <mark>pone</mark> nts. Figure 6: Evaluation of FDT performance. a) evaluates components separately on all quantization methods. Clear outliers in performance are A. Value and MLP Up. GPTQ (8bit) is able to evenly amortize the induced error. b) Selecting top-k components of GPTQ (4bit). FDT is suited to rank components one-shot. inal when choosing FDT as a selection criterion. Fig. 5b) shows the selected components at each depth in relation to a). Most outliers occur when the Attention Key is selected early on. Notably, we observed in Sec. 4.2, that this is one of the matrices most suitable to sparsify. 16 components in 4-bit. Figure 6a) presents a comprehensive assessment of the quantization techniques discussed. First, it is noticeable that the LLM.int8() method slightly improves the lower quantile scores of FDT in comparison to AbsMax. However, GPTQ (8bit) demonstrates superior performance, outshining both plain AbsMax and LLM.int8(). This method achieves a more balanced error distribution across all components ( _cf._ App. Fig. 17). On the contrary, GPTQ (4-bit) shows noticeable deviations in the generation process, with only a limited number of components achieving FDT scores greater than 400. Despite this, the discriminative power of FDT enabled us to identify and merge the top 16 components that minimally compromised the integrity of the model, as illustrated in Fig. 6b). 5 Conclusion We introduced the Divergent Token Metrics (DTMs), a tailored approach to evaluate the performance differences of compressed generative models. In particular, DTMs respect the usually applied greedy sampling procedure to generate predictions. We proved that DTMs achieve appropriate metric bounds and are not affected from catastrophic artefacts that perplexity-based metrics encounter. We constructed algorithms for iterative sparsification and quantization processes based on DTM probing of individual components. Using DTMs, we achieved an outperforming 75% sparse version of Llama2-13B and successfully converted 80% of the LLama2-7B components naively to int8. Limitations With the proposed DTMs, compression processes can be tailored to use cases—and we can measure their performance degeneration. We hinted with the sparsification experiments, that MLP and Attention can be ascribed varying levels of significance throughout the layers. These studies should be further extended to various model architectures such as BERT or MoE. Moreover, variations of specific datasets to probe or finetune on could lead to interesting observations. For example, multilingual, multitasking and instruction tuned MoE models could be pruned multiple times using FDT to investigate how the information actually is stored and assembled. Note that this work solely relied on English-tailored pruning for a mostly Englishtrained model. Furthermore, augmenting our metrics to probe for (and investigate) specific aspects such as safety alignments, and preserving these elements throughout model compression would be a significant area of study. As a pruning strategy, we achieved outperforming results using only naive magnitude pruning. DTMs should be directly applicable to other masking strategies, such as Wanda (Sun et al., 2023), which may further improve results. Finally, the generalizability of the metrics to other sampling strategies should be investigated. Acknowledgments We thank the three anonymous referees for their constructive comments and suggestions, which helped us to improve this paper considerably. This work has been partially funded by the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) as part of BERD@NFDI grant number 460037581. We gratefully acknowledge support by the German Center for Artificial Intelligence (DFKI) 6772 project “SAINT”, the Hessian Ministry of Higher Education, the Research and the Arts (HMWK) cluster projects “The Adaptive Mind” and “The Third Wave of AI”, and the ICT-48 Network of AI Research Excellence Center “TAILOR” (EU Horizon 2020, GA No 952215). We thank Graphcore, Jamie Packer, Manuel Brack and Samuel Weinbach for the fruitful discussions and the invaluable feedback throughout this work. References Tom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, Sandhini Agarwal, Ariel Herbert-Voss, Gretchen Krueger, Tom Henighan, Rewon Child, Aditya Ramesh, Daniel M. Ziegler, Jeffrey Wu, Clemens Winter, Christopher Hesse, Mark Chen, Eric Sigler, Mateusz Litwin, Scott Gray, Benjamin Chess, Jack Clark, Christopher Berner, Sam McCandlish, Alec Radford, Ilya Sutskever, and Dario Amodei. 2020. Language models [are](https://proceedings.neurips.cc/paper/2020/hash/1457c0d6bfcb4967418bfb8ac142f64a-Abstract.html) few-shot learners. In _Advances in Neural Information Processing Systems_ . Sébastien Bubeck, Varun Chandrasekaran, Ronen Eldan, Johannes Gehrke, Eric Horvitz, Ece Kamar, Peter Lee, Yin Tat Lee, Yuanzhi Li, Scott M. Lundberg, Harsha Nori, Hamid Palangi, Marco Túlio Ribeiro, and Yi Zhang. 2023. Sparks of [artificial](https://doi.org/10.48550/ARXIV.2303.12712) general intelligence: [Early experiments with GPT-4.](https://doi.org/10.48550/ARXIV.2303.12712) _CoRR_, abs/2303.12712. Aakanksha Chowdhery, Sharan Narang, Jacob Devlin, Maarten Bosma, Gaurav Mishra, Adam Roberts, Paul Barham, Hyung Won Chung, Charles Sutton, Sebastian Gehrmann, Parker Schuh, Kensen Shi, Sasha Tsvyashchenko, Joshua Maynez, Abhishek Rao, Parker Barnes, Yi Tay, Noam Shazeer, Vinodkumar Prabhakaran, Emily Reif, Nan Du, Ben Hutchinson, Reiner Pope, James Bradbury, Jacob Austin, Michael Isard, Guy Gur-Ari, Pengcheng Yin, Toju Duke, Anselm Levskaya, Sanjay Ghemawat, Sunipa Dev, Henryk Michalewski, Xavier Garcia, Vedant Misra, Kevin Robinson, Liam Fedus, Denny Zhou, Daphne Ippolito, David Luan, Hyeontaek Lim, Barret Zoph, Alexander Spiridonov, Ryan Sepassi, David Dohan, Shivani Agrawal, Mark Omernick, Andrew M. Dai, Thanumalayan Sankaranarayana Pillai, Marie Pellat, Aitor Lewkowycz, Erica Moreira, Rewon Child, Oleksandr Polozov, Katherine Lee, Zongwei Zhou, Xuezhi Wang, Brennan Saeta, Mark Diaz, Orhan Firat, Michele Catasta, Jason Wei, Kathy Meier-Hellstern, Douglas Eck, Jeff Dean, Slav Petrov, and Noah Fiedel. 2023. [Palm: Scaling language mod-](http://jmlr.org/papers/v24/22-1144.html) [eling with pathways.](http://jmlr.org/papers/v24/22-1144.html) _Journal of Machine Learning_ _Research_, 24:240:1–240:113. Tim Dettmers, Mike Lewis, Younes Belkada, and Luke Zettlemoyer. 2022. Gpt3.int8(): [8-bit matrix multi-](https://proceedings.neurips.cc/paper_files/paper/2022/file/c3ba4962c05c49636d4c6206a97e9c8a-Paper-Conference.pdf) [plication for transformers at scale.](https://proceedings.neurips.cc/paper_files/paper/2022/file/c3ba4962c05c49636d4c6206a97e9c8a-Paper-Conference.pdf) In _Advances in_ _Neural Information Processing Systems_, volume 35, pages 30318–30332. Elias Frantar and Dan Alistarh. 2023. [Sparsegpt:](https://proceedings.mlr.press/v202/frantar23a.html) Mas sive language models [can](https://proceedings.mlr.press/v202/frantar23a.html) be accurately pruned in [one-shot.](https://proceedings.mlr.press/v202/frantar23a.html) In _International Conference on Machine_ _Learning_, volume 202, pages 10323–10337. Elias Frantar, Saleh Ashkboos, Torsten Hoefler, and Dan Alistarh. 2023. [OPTQ: accurate quantization for](https://openreview.net/pdf?id=tcbBPnfwxS) [generative pre-trained transformers.](https://openreview.net/pdf?id=tcbBPnfwxS) In _International_ _Conference on Learning Representations_ . Leo Gao, Jonathan Tow, Stella Biderman, Sid Black, Anthony DiPofi, Charles Foster, Laurence Golding, Jeffrey Hsu, Kyle McDonell, Niklas Muennighoff, Jason Phang, Laria Reynolds, Eric Tang, Anish Thite, Ben Wang, Kevin Wang, and Andy Zou. 2021. [A](https://doi.org/10.5281/zenodo.5371628) [framework for few-shot language model evaluation.](https://doi.org/10.5281/zenodo.5371628) Song Han, Jeff Pool, John Tran, and William J. Dally. 2015. Learning both [weights](https://proceedings.neurips.cc/paper/2015/hash/ae0eb3eed39d2bcef4622b2499a05fe6-Abstract.html) and connections for [efficient neural network.](https://proceedings.neurips.cc/paper/2015/hash/ae0eb3eed39d2bcef4622b2499a05fe6-Abstract.html) In _Advances in Neural In-_ _formation Processing Systems_, pages 1135–1143. Yaniv Leviathan, Matan Kalman, and Yossi Matias. 2023. Fast inference from [transformers](https://proceedings.mlr.press/v202/leviathan23a.html) via speculative [decoding.](https://proceedings.mlr.press/v202/leviathan23a.html) In _International_ _Conference_ _on_ _Machine Learning_, volume 202, pages 19274–19286. Stephen Merity, Caiming Xiong, James Bradbury, and Richard Socher. 2017. [Pointer sentinel mixture mod-](https://openreview.net/forum?id=Byj72udxe) [els.](https://openreview.net/forum?id=Byj72udxe) In _International Conference on Learning Repre-_ _sentations_ . Paul Michel, Omer Levy, and Graham Neubig. 2019. Are sixteen heads really better than one? _Advances_ _in neural information processing systems_, 32. Alexandra Peste, Eugenia Iofinova, Adrian Vladu, and Dan Alistarh. 2021. AC/DC: [alternating](https://proceedings.neurips.cc/paper/2021/hash/48000647b315f6f00f913caa757a70b3-Abstract.html) compressed/decompressed [training](https://proceedings.neurips.cc/paper/2021/hash/48000647b315f6f00f913caa757a70b3-Abstract.html) of deep neural net[works.](https://proceedings.neurips.cc/paper/2021/hash/48000647b315f6f00f913caa757a70b3-Abstract.html) In _Advances in Neural Information Process-_ _ing Systems_, pages 8557–8570. Alec Radford, Karthik Narasimhan, Tim Salimans, Ilya Sutskever, et al. 2018. Improving language understanding by generative pre-training. _OpenAI blog_ . Alec Radford, Jeffrey Wu, Rewon Child, David Luan, Dario Amodei, Ilya Sutskever, et al. 2019. Language models are unsupervised multitask learners. _OpenAI_ _blog_ . Colin Raffel, Noam Shazeer, Adam Roberts, Kather ine Lee, Sharan Narang, Michael Matena, Yanqi Zhou, Wei Li, and Peter J. Liu. 2020. [Exploring the](http://jmlr.org/papers/v21/20-074.html) [limits of transfer learning with a unified text-to-text](http://jmlr.org/papers/v21/20-074.html) [transformer.](http://jmlr.org/papers/v21/20-074.html) _Journal of Machine Learning Research_, 21:140:1–140:67. Mingjie Sun, Zhuang Liu, Anna Bair, and J. Zico Kolter. 2023. [A simple and effective pruning approach for](https://doi.org/10.48550/ARXIV.2306.11695) [large language models.](https://doi.org/10.48550/ARXIV.2306.11695) _CoRR_, abs/2306.11695. 6773 Hugo Touvron, Louis Martin, Kevin Stone, Peter Al bert, Amjad Almahairi, Yasmine Babaei, Nikolay Bashlykov, Soumya Batra, Prajjwal Bhargava, Shruti Bhosale, Dan Bikel, Lukas Blecher, Cristian CantonFerrer, Moya Chen, Guillem Cucurull, David Esiobu, Jude Fernandes, Jeremy Fu, Wenyin Fu, Brian Fuller, Cynthia Gao, Vedanuj Goswami, Naman Goyal, Anthony Hartshorn, Saghar Hosseini, Rui Hou, Hakan Inan, Marcin Kardas, Viktor Kerkez, Madian Khabsa, Isabel Kloumann, Artem Korenev, Punit Singh Koura, Marie-Anne Lachaux, Thibaut Lavril, Jenya Lee, Diana Liskovich, Yinghai Lu, Yuning Mao, Xavier Martinet, Todor Mihaylov, Pushkar Mishra, Igor Molybog, Yixin Nie, Andrew Poulton, Jeremy Reizenstein, Rashi Rungta, Kalyan Saladi, Alan Schelten, Ruan Silva, Eric Michael Smith, Ranjan Subramanian, Xiaoqing Ellen Tan, Binh Tang, Ross Taylor, Adina Williams, Jian Xiang Kuan, Puxin Xu, Zheng Yan, Iliyan Zarov, Yuchen Zhang, Angela Fan, Melanie Kambadur, Sharan Narang, Aurélien Rodriguez, Robert Stojnic, Sergey Edunov, and Thomas Scialom. 2023. Llama 2: [Open foundation and fine-](https://doi.org/10.48550/ARXIV.2307.09288) [tuned chat models.](https://doi.org/10.48550/ARXIV.2307.09288) _CoRR_, abs/2307.09288. Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Lukasz Kaiser, and Illia Polosukhin. 2017. [Attention is all](https://proceedings.neurips.cc/paper/2017/hash/3f5ee243547dee91fbd053c1c4a845aa-Abstract.html) [you need.](https://proceedings.neurips.cc/paper/2017/hash/3f5ee243547dee91fbd053c1c4a845aa-Abstract.html) In _Advances in Neural Information Pro-_ _cessing Systems_, pages 5998–6008. 6774 Appendix A Proof of Propositions _Proof of Proposition 3.2._ There are many ways to construct sequences that satisfy the desired relation. One is as follows: Let _l_ _∈_ R <sup>_N_</sup> <sup>_×|V|_</sup> be any logit sequence with no re-occurring values. Denote by _mk_ ( _l_ ) _i_ the top- _k_ value at position _i_, and by _ak_ ( _l_ ) _i_ the top- _k_ vocab index at position _i_, respectively. Now we pick any such sequence with the additional property that max _i m_ 1( _l_ ) _i −_ _m_ 2( _l_ ) _i_ _< δ_ for some small _δ_ . Define the sequence _l_ <sup>_′_</sup> by _lia_ <sup>_′_</sup> 2( _l_ ) _i_ <sup>=</sup> <sup>_lia_</sup> 2 <sup>(</sup> <sup>_l_</sup> <sup>)</sup> _i_ <sup>+</sup> <sup>_δ,_</sup> and _lij_ <sup>_′_</sup> <sup>=</sup> <sup>_lij_</sup> <sup>for</sup> <sup>all</sup> <sup>remaining</sup> <sup>indices.</sup> Then we have _a_ 1( _l_ ) _i̸_ = _a_ 1( _l_ <sup>_′_</sup> ) _i_ for all _i_ and hence _M_ SDT( _l, l_ <sup>_′_</sup> _, y_ :1 _, N_ ) = _N_ . On the other hand we have _||l −_ _l_ <sup>_′_</sup> _||∞_ _≤_ _δ_ . Since PPL( _y, l,_ 1) is a continuous function in _l_, we have _|_ PPL( _y, l,_ 1) _<u>−</u>_ PPL( _y, l_ <sup>_′_</sup> _,_ 1) _|_ _<_ _ε_ for any _ε_ and small enough _δ_ . _Proof of Proposition 3.3._ Let _z_ = _G_ ( _l, y_ : _n, N_ ) and _pi_ = (softmax _l_ <sup>_′_</sup> ) _izi_ +1. Applying the definitions and elementary operations, we have _N_ _i_ = _n_ _−_ log _pi_ = ( _N_ _−_ _n_ ) log _M_ DPPL( _l, l_ <sup>_′_</sup> _, y_ : _n, N_ ) _._ Let _A_ = _{i ≥_ _n_ : _pi_ _≤_ 1 _/_ 2 _}_ . Then _N_ _i_ = _n_ _−_ log _pi_ = _≥_ _i_ - _∈A_ <sup>_c_</sup> _i∈A_ <sup>_c_</sup> - _i∈A_ _i∈A_ - _i∈A_ _i∈A_ _−_ log _pi_ _−_ log _pi_ + _−_ log _pi_ _≥|A|_ log 2 _._ Here we first used that log _pi_ _≤_ 0 and then the observation that indices contained in _A_ satisfy _−_ log _pi_ _≥_ log 2 by the defining property of _A_ . Finally, we argue that SDT( _z, l_ <sup>_′_</sup> _, n_ ) _≤|A|_ . Indeed, at any position _i_ where arg max _j lij_ <sup>_′_</sup> _̸_ <sup>=</sup> <sup>_zi_</sup> <sup>+1 it must</sup> hold that _pi_ _≤_ 1 _/_ 2, since any softmax-value larger than 1 _/_ 2 is automatically the maximum value of the distribution, and the softmax operation is monotone. Putting everything together we arrive at the desired inequality. B FDT compared to standard model evaluations Fig. 10 shows a comparison of standard benchmarks (middle) to FDT (right) and PPL (left) Figure 7: Pruning MLP and Attn only indeed compromises remaining model capabilities. when quantizing parts of a model. Often, standard evaluations fail to distinguish between compressed models. Sometimes they even depict better performance—which may be true, when regarding compression as a fine-tuning method and considering the short required token predictions. FDT thoroughly gives discriminative statistics with resprect to the base model, on how much the compressed model equals the original. Note how the error seems to be upper bounded, which suggests that errors may average out throughout the model. Mean zeroshot accuracy denotes the average on the standard NLP-eval harness. C True positives can be predicted Fig. 8 shows several metrics applied to the tokendistributions, in order to estimate on whether the compressed and original model predictions are equal. Notably, L1 and L2 errors on the entire 6775 distribution seem to somewhat capture the discriminative capabilities of false predictions. The probability scores themselves are only marginally usable. Using top-2 uncertainty, i.e. the difference between the top-2 tokens as a measure, we obtain a reliable prediction of true positives. True negatives however still remain with a significant overlap. D MLP is for knowledge, Attention for relation Finally, we observed that when pruning only attention, prompt-extraction capabilities degenerate severely. When only pruning MLP components, on the other hand, it influences mostly world knowledge QA benchmarks, _cf._ Fig. 7. E Details on Search Tree, Sec. 4.3 Fig. 9 shows the layers (y-axis) of which components are selected at each round (x-axis). While there seems to be a pattern on when using FDT as a criteria (top), selection by PPL (bottom) looks more random. Fig. 15 shows the comparison of search tree as described to greedy search on a single evaluation of all components. Until 150 components, FDT proves more stable over the PPL variants as seen in Fig. 15a. F Details on Quantization Sec. 4.3 Fig. 17 shows detailed componentwise evaluations aggregated in Fig. 6a. Fig. 16 shows the final configurations as compared in Tab. 1. Fig. 11 shows the detailed nlp-eval scores of Tab. 1. Fig. 12 shows greedy search trees over various context lengths. In total the entire search evaluation required 16 GPU-days with A100s to complete all metrics. G Details on Sparsification, Sec. 4.2 Fig. 18 shows a different aggregated perspective of Fig. 4b, to point out more direct the occuring variances. Fig. 19 shows the rank of lowest influence (measured by FDT) of components (x-axis) throughout various sparsity levels (y-axis). I.e. starting with a uniformly pruned model in 5% steps, we measured the rank when adding an additional 2.5% only to a single component. Interestingly, components seem to retain their importance throughout the various levels of sparsity. Fig. 13 shows the detailed nlp-eval scores of Tab. 1. Note that, despite being often close in relative sparsity, the total number of parameters pruned for MLP is significantly larger than for Attention matrices (ratio 3:1). Finally, Fig. 22 shows detailed componentwise pruning experiments. In total one sparsification training required 32 GPU-days with A100s for our experiment, and 29 GPU-days for uniform pruning. H Further Hyperparameters Fig. 20 shows that 1k probes are enough to determine a stable _MF_ 75 value. I Model Completion vs. Ground Truth Fig. 21 shows the FDT value that compares the ground truth of the data set with the completion of the model on Wikitext2. Tab. 2 further gives an example for better comparison. It can be observed that, even though Wikitext2 was contained in the training dataset, Llama2-13B does not properly recall it, and as such, the FDT value is close to 0. Therefore, we cannot utilize generic data samples as ground truth alone in such a general-purpose pruning setup. Afterall, our goal is to measure the “deviation” of the compressed model to its base line. For more specific, e.g. Q/A datasets, it may, however, be more feasible. 6776 <u>Top-2 uncertainty</u> <u>L1 error</u> 1.0 0.5 <u>Different</u> prediction Probability difference for token predicted by baseline 0.0 <u>All</u> <u>Same</u> prediction <u>All</u> <u>Same</u> prediction <u>Different</u> prediction <u>All</u> <u>Same</u> prediction <u>Different</u> prediction <u>Different</u> prediction <u>L2 error</u> <u>All</u> <u>Same</u> prediction Figure 8: Top-2 uncertainty is discriminative enough to give clear true-positives estimates on compressed models. 30 25 20 15 10 5 30 25 20 15 10 5 10 5 0 10 5 0 Selection Criteria Llama2-7b AbsMax FDT150 AbsMax DPPL150 AbsMax PPL150 LLM.int8() 0 20 40 60 80 100 120 140 160 180 200 220 Number of Quantized Components per Config Figure 9: Layers selected in each round of the search tree. Top, when applying FDT, bottom, when applying PPL as a ranking metric. 0.8 0.6 0.4 0.2 0.0 0.8 0.6 0.4 0.2 0.0 (a) 8-bit Quantization NLP benchmarks Selection Criteria LLama2-7b GPTQ FDT16 GPTQ DPPL16 GPTQ PPL16 GPTQall 600 500 400 300 200 100 0 11.3 9.4 7.6 5.7 3.8 1.9 0.0 Acc <mark>urac</mark> y Metric FDT PPL Baseline Best Worst First Half Second Half Quantized Component Figure 10: Comparison of the discrimination capabilities of FDT and PPL for different configurations when applying LLM.int8() conversion on Llama2-7B. Best and Worst mark a single component being converted, with most and least mean influence. First and Second half consecutively convert half of the model each. While significant changes can be observed using FDT, all configurations appear indifferent for PPL. (b) 4-bit Quantization NLP benchmarks Figure 11: Detailed view on aggregated values of Tab. 1 when selecting Llama2-7B components to quantize by metrics. 6777 PPL LLM.Int8() FDT DPPL PPL LLM.Int8() 1.25 1.00 0.75 0.50 0.25 0.00 1.5 1.0 0.5 0.0 1.25 1.00 0.75 0.50 0.25 0.00 1.25 1.00 0.75 0.50 0.25 0.00 1.5 1.0 0.5 0.0 FDT DPPL 0.02 0.01 0.00 0.03 0.02 | | | 0.025 0.020 0.015 0.010 0.005 0.000 0.02 0.01 0.00 0.025 0.020 0.015 0.010 0.005 0.000 0.8 0.6 0.4 0.2 0.0 | <u>1e7</u> <u>1e7</u> 0 50 100 150 200 No. Quantized Components (a) Context size of 10 tokens. <u>1e7</u> <u>1e7</u> <u>1e7</u> | | 0 50 100 150 200 No. Quantized Components (b) Context size of 25 tokens. FDT DPPL PPL LLM.Int8() FDT DPPL PPL LLM.Int8() 0 50 100 150 200 No. Quantized Components (f) Context size of 400 tokens. 0 50 100 150 200 No. Quantized Components (c) Context size of 50 tokens. 0 50 100 150 200 No. Quantized Components (d) Context size of 200 tokens. FDT DPPL PPL LLM.Int8() FDT DPPL PPL LLM.Int8() <u>1e7</u> 0.01 0.00 0.025 0.020 0.015 0.010 0.005 0.000 0 50 100 150 200 No. Quantized Components (e) Context size of 300 tokens. 1.5 1.0 0.5 0.0 Figure 12: Greedy Search Tree results for different context sizes. Selection Criteria Llama2-13b 60% FDT 60% unif. 75% FDT 75% unif. 80% FDT Figure 13: Detailed view on aggregated values of Tab. 1 when selecting Llama2-13B components to sparsify by metrics. 6778 <u>1e7</u> <u>1e7</u> <u>1e7</u> 0 50 100 150 200 No. Quantized Components (b) DPPL tree vs greedy 0 50 100 150 200 No. Quantized Components (c) PPL tree vs greedy LLM.Int8() Tree Search DPPL Greedy Search DPPL LLM.Int8() Tree Search PPL Greedy Search PPL LLM.Int8() 0.025 0.020 | 0.015 0.010 0.005 0.000 0 50 100 150 200 No. Quantized Components (a) FDT tree vs greedy Tree Search FDT Greedy Search FDT | 0.030 0.025 0.020 0.015 0.010 0.005 | 0.030 0.025 0.020 0.015 0.010 0.005 1.25 1.00 0.75 0.50 0.25 0.00 1.25 1.00 0.75 0.50 0.25 0.00 1.25 1.00 0.75 0.50 0.25 0.00 Figure 14: Comparison of performance when selecting components by the tree-search as described to greedy selection of once evaluated components for all discussed metrics. Clearly, FDT is most stable until 150 components. FDT DPPL PPL LLM.Int8() <u>1e7</u> PPL LLM.Int8() <u>1e7</u> 1.25 1.00 0.75 0.50 0.25 0.00 FDT DPPL 1.25 1.00 0.75 0.50 0.25 0.00 0 50 100 150 200 No. Quantized Components 0 50 100 150 200 No. Quantized Components | | 0.02 0.01 0.00 0.03 0.02 0.01 0.00 | | 0.02 0.01 0.00 (a) Mean sorted greedy tree with 50 context tokens. (b) Std=0.25 sorted components with 50 context tokens. PPL LLM.Int8() <u>1e7</u> PPL LLM.Int8() <u>1e7</u> FDT DPPL 0 50 100 150 200 No. Quantized Components FDT DPPL 0 50 100 150 200 No. Quantized Components 0.02 0.01 0.00 1.25 1.00 0.75 0.50 0.25 0.00 1.25 1.00 0.75 0.50 0.25 0.00 (c) Mean sorted greedy tree with 100 context tokens. (d) Std=0.25 sorted components with 100 context tokens. Figure 15: Comparing the ranking of the components based on mean or standard deviation. 6779 A. Dense A. Query A. Value A. Key MLP Up MLP Down MLP Gate A. Dense A. Query A. Value A. Key MLP Up MLP Down MLP Gate 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Layer (a) The 150 selected components selected by metrics for 8-bit AbsMax conversion. 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Layer (b) The 16 selected components selected by metrics for 4-bit GPTQ conversion. Selection Criteria DPPL PPL FDT Selection Criteria DPPL PPL FDT Figure 16: Detailed view of the Llama2-7B components in Tab. 1 selected by metrics for lower precision conversion. Prefix: ‘Where On June 19, 1865, Union General Gordon Granger, standing on its balcony, read the contents of “ General Order No. 3 ”, thereby emancipating all slaves in the state of Texas . St. Joseph ’ s Church was built by German immigrants in 1859 @-@ 60 and is the oldest wooden church building in Galveston and the oldest German Catholic Church in Texas . The church was ’ Ground-truth: ‘dedicated in April 1860, to St. Joseph, the patron saint of laborers . The building is a wooden gothic revival structure, rectangular with a square bell tower with trefoil window . The U.S. Custom House began construction in 1860 and was completed in 1861 . The Confederate Army occupied the building during the American Civil War, In 1865, the Custom House was the site of the’ Llama2-7B completion: ‘built in the Gothic Revival style, and its bell tower has a spire that rises 125 feet . The church is located in the East End Historic District, which is listed on the National Register of Historic Places . The church was added to the National Register of Historic Places in 1975 . The Strand National Historic Landmark District is a National Historic Landmark District in Galveston, Texas, United States . It is located on the Strand,’ LLM.int8(Llama2-7B) completion: ‘originally located on 25th Street between Broadway and Strand Street in Galveston . It was moved to its present location in 1892 . The church was designated a Recorded Texas Historic Landmark in 1964, listed on the National Register of Historic Places in 1975, and designated a National Historic Landmark in 2000 . The Galveston Daily News Building is a historic commercial building in Galveston, Texas .’ Table 2: Example of a Wikitext2 probe as used to determined the FDT value. It can be observed that the fully LLM.int8 compressed model, though having only minor differences in the NLP and PPL benchmarks, substantially alters the original model completion, starting at the very first token. 6780 FDT <u>0</u> <u>100</u> <u>20</u> <u><mark>0</mark></u> <mark>300</mark> <mark>400</mark> <mark>50</mark> 0 LLM.int8() FDT <u>0</u> <u>100</u> <u>200</u> <u><mark>300</mark></u> <mark>400</mark> <mark>50</mark> 0 GPTQ (8bit) FDT <u>0</u> <mark>100</mark> <mark>200</mark> <mark>300</mark> <mark>400</mark> <mark>50</mark> 0 GPTQ (4bit) Layer: 0 Module: MLP DownLayer: 1 Module: MLP DownLayer: 2 Module: MLP DownLayer: 3 Module: MLP DownLayer: 4 Module: MLP DownLayer: 5 Module: MLP DownLayer: 6 Module: MLP DownLayer: 7 Module: MLP DownLayer: 8 Module: MLP DownLayer: 0 Module: MLP GateLayer: 1 Module: MLP GateLayer: 2 Module: MLP GateLayer: 3 Module: MLP GateLayer: 4 Module: MLP GateLayer: 5 Module: MLP GateLayer: 6 Module: MLP GateLayer: 7 Module: MLP GateLayer: 8 Module: MLP GateLayer: 0 Module: A. DenseLayer: 1 Module: A. DenseLayer: 2 Module: A. DenseLayer: 3 Module: A. DenseLayer: 4 Module: A. DenseLayer: 5 Module: A. DenseLayer: 6 Module: A. DenseLayer: 7 Module: A. DenseLayer: 8 Module: A. DenseLayer: 9 Module: A. DenseLayer: 0 Module: A. QueryLayer: 1 Module: A. QueryLayer: 2 Module: A. QueryLayer: 3 Module: A. QueryLayer: 4 Module: A. QueryLayer: 5 Module: A. QueryLayer: 6 Module: A. QueryLayer: 7 Module: A. QueryLayer: 8 Module: A. QueryLayer: 9 Module: A. QueryLayer: 0 Module: A. ValueLayer: 1 Module: A. ValueLayer: 2 Module: A. ValueLayer: 3 Module: A. ValueLayer: 4 Module: A. ValueLayer: 5 Module: A. ValueLayer: 6 Module: A. ValueLayer: 7 Module: A. ValueLayer: 8 Module: A. ValueLayer: 0 Module: MLP UpLayer: 1 Module: MLP UpLayer: 2 Module: MLP UpLayer: 3 Module: MLP UpLayer: 4 Module: MLP UpLayer: 5 Module: MLP UpLayer: 6 Module: MLP UpLayer: 7 Module: MLP UpLayer: 8 Module: MLP UpLayer: 0 Module: A. KeyLayer: 1 Module: A. KeyLayer: 2 Module: A. KeyLayer: 3 Module: A. KeyLayer: 4 Module: A. KeyLayer: 5 Module: A. KeyLayer: 6 Module: A. KeyLayer: 7 Module: A. KeyLayer: 8 Module: A. KeyLayer: 9 Module: A. Key Layer: 10 Module: MLP DownLayer: 11 Module: MLP DownLayer: 12 Module: MLP DownLayer: 13 Module: MLP DownLayer: 14 Module: MLP DownLayer: 15 Module: MLP DownLayer: 16 Module: MLP DownLayer: 17 Module: MLP DownLayer: 18 Module: MLP DownLayer: 19 Module: MLP DownLayer: 20 Module: MLP DownLayer: 21 Module: MLP DownLayer: 22 Module: MLP DownLayer: 23 Module: MLP DownLayer: 24 Module: MLP DownLayer: 25 Module: MLP DownLayer: 26 Module: MLP DownLayer: 27 Module: MLP DownLayer: 28 Module: MLP DownLayer: 29 Module: MLP DownLayer: 30 Module: MLP DownLayer: 31 Module: MLP DownLayer: 10 Module: MLP GateLayer: 11 Module: MLP GateLayer: 12 Module: MLP GateLayer: 13 Module: MLP GateLayer: 14 Module: MLP GateLayer: 15 Module: MLP GateLayer: 16 Module: MLP GateLayer: 17 Module: MLP GateLayer: 18 Module: MLP GateLayer: 19 Module: MLP GateLayer: 20 Module: MLP GateLayer: 21 Module: MLP GateLayer: 22 Module: MLP GateLayer: 23 Module: MLP GateLayer: 24 Module: MLP GateLayer: 25 Module: MLP GateLayer: 26 Module: MLP GateLayer: 27 Module: MLP GateLayer: 28 Module: MLP GateLayer: 29 Module: MLP GateLayer: 30 Module: MLP GateLayer: 31 Module: MLP GateLayer: 0 Module: MLP DownLayer: 1 Module: MLP DownLayer: 2 Module: MLP DownLayer: 3 Module: MLP DownLayer: 4 Module: MLP DownLayer: 5 Module: MLP DownLayer: 6 Module: MLP DownLayer: 7 Module: MLP DownLayer: 8 Module: MLP DownLayer: 9 Module: MLP DownLayer: 10 Module: A. DenseLayer: 11 Module: A. DenseLayer: 12 Module: A. DenseLayer: 13 Module: A. DenseLayer: 14 Module: A. DenseLayer: 15 Module: A. DenseLayer: 16 Module: A. DenseLayer: 17 Module: A. DenseLayer: 18 Module: A. DenseLayer: 19 Module: A. DenseLayer: 20 Module: A. DenseLayer: 21 Module: A. DenseLayer: 22 Module: A. DenseLayer: 23 Module: A. DenseLayer: 24 Module: A. DenseLayer: 25 Module: A. DenseLayer: 26 Module: A. DenseLayer: 27 Module: A. DenseLayer: 28 Module: A. DenseLayer: 29 Module: A. DenseLayer: 30 Module: A. DenseLayer: 31 Module: A. DenseLayer: 10 Module: A. QueryLayer: 11 Module: A. QueryLayer: 12 Module: A. QueryLayer: 13 Module: A. QueryLayer: 14 Module: A. QueryLayer: 15 Module: A. QueryLayer: 16 Module: A. QueryLayer: 17 Module: A. QueryLayer: 18 Module: A. QueryLayer: 19 Module: A. QueryLayer: 20 Module: A. QueryLayer: 21 Module: A. QueryLayer: 22 Module: A. QueryLayer: 23 Module: A. QueryLayer: 24 Module: A. QueryLayer: 25 Module: A. QueryLayer: 26 Module: A. QueryLayer: 27 Module: A. QueryLayer: 28 Module: A. QueryLayer: 29 Module: A. QueryLayer: 30 Module: A. QueryLayer: 31 Module: A. QueryLayer: 0 Module: MLP GateLayer: 1 Module: MLP GateLayer: 2 Module: MLP GateLayer: 3 Module: MLP GateLayer: 4 Module: MLP GateLayer: 5 Module: MLP GateLayer: 6 Module: MLP GateLayer: 7 Module: MLP GateLayer: 8 Module: MLP GateLayer: 9 Module: MLP GateLayer: 10 Module: A. ValueLayer: 11 Module: A. ValueLayer: 12 Module: A. ValueLayer: 13 Module: A. ValueLayer: 14 Module: A. ValueLayer: 15 Module: A. ValueLayer: 16 Module: A. ValueLayer: 17 Module: A. ValueLayer: 18 Module: A. ValueLayer: 19 Module: A. ValueLayer: 20 Module: A. ValueLayer: 21 Module: A. ValueLayer: 22 Module: A. ValueLayer: 23 Module: A. ValueLayer: 24 Module: A. ValueLayer: 25 Module: A. ValueLayer: 26 Module: A. ValueLayer: 27 Module: A. ValueLayer: 28 Module: A. ValueLayer: 29 Module: A. ValueLayer: 30 Module: A. ValueLayer: 31 Module: A. ValueLayer: 1 Module: A. DenseLayer: 2 Module: A. DenseLayer: 3 Module: A. DenseLayer: 4 Module: A. DenseLayer: 5 Module: A. DenseLayer: 6 Module: A. DenseLayer: 7 Module: A. DenseLayer: 8 Module: A. DenseLayer: 9 Module: A. DenseLayer: 1 Module: A. QueryLayer: 2 Module: A. QueryLayer: 3 Module: A. QueryLayer: 4 Module: A. QueryLayer: 5 Module: A. QueryLayer: 6 Module: A. QueryLayer: 7 Module: A. QueryLayer: 8 Module: A. QueryLayer: 9 Module: A. QueryLayer: 10 Module: MLP UpLayer: 11 Module: MLP UpLayer: 12 Module: MLP UpLayer: 13 Module: MLP UpLayer: 14 Module: MLP UpLayer: 15 Module: MLP UpLayer: 16 Module: MLP UpLayer: 17 Module: MLP UpLayer: 18 Module: MLP UpLayer: 19 Module: MLP UpLayer: 20 Module: MLP UpLayer: 21 Module: MLP UpLayer: 22 Module: MLP UpLayer: 23 Module: MLP UpLayer: 24 Module: MLP UpLayer: 25 Module: MLP UpLayer: 26 Module: MLP UpLayer: 27 Module: MLP UpLayer: 28 Module: MLP UpLayer: 29 Module: MLP UpLayer: 30 Module: MLP UpLayer: 0 Module: A. ValueLayer: 1 Module: A. ValueLayer: 2 Module: A. ValueLayer: 3 Module: A. ValueLayer: 4 Module: A. ValueLayer: 5 Module: A. ValueLayer: 6 Module: A. ValueLayer: 7 Module: A. ValueLayer: 8 Module: A. ValueLayer: 9 Module: A. ValueLayer: 10 Module: A. KeyLayer: 11 Module: A. KeyLayer: 12 Module: A. KeyLayer: 13 Module: A. KeyLayer: 14 Module: A. KeyLayer: 15 Module: A. KeyLayer: 16 Module: A. KeyLayer: 17 Module: A. KeyLayer: 18 Module: A. KeyLayer: 19 Module: A. KeyLayer: 20 Module: A. KeyLayer: 21 Module: A. KeyLayer: 22 Module: A. KeyLayer: 23 Module: A. KeyLayer: 24 Module: A. KeyLayer: 25 Module: A. KeyLayer: 26 Module: A. KeyLayer: 27 Module: A. KeyLayer: 28 Module: A. KeyLayer: 29 Module: A. KeyLayer: 30 Module: A. KeyLayer: 31 Module: A. KeyLayer: 0 Module: MLP UpLayer: 1 Module: MLP UpLayer: 2 Module: MLP UpLayer: 3 Module: MLP UpLayer: 4 Module: MLP UpLayer: 5 Module: MLP UpLayer: 6 Module: MLP UpLayer: 7 Module: MLP UpLayer: 8 Module: MLP UpLayer: 9 Module: MLP UpLayer: 1 Module: A. KeyLayer: 2 Module: A. KeyLayer: 3 Module: A. KeyLayer: 4 Module: A. KeyLayer: 5 Module: A. KeyLayer: 6 Module: A. KeyLayer: 7 Module: A. KeyLayer: 8 Module: A. KeyLayer: 9 Module: A. Key Layer: 31 Module: MLP Up FDT <u>0</u> <u>100</u> <u>20</u> <u><mark>0</mark></u> <mark>300</mark> <mark>400</mark> <mark>50</mark> 0 AbsMax Figure 17: Full view of the influence of individual componentwise quantization measured by FDT. 6781 1.0 0.9 0.8 0.7 0.6 0.5 0.4 1.0 0.9 0.8 0.7 0.6 0.5 0.4 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 Layer First-half Second-half A. Query A. Key A. Value A. Dense MLP Up MLP Down MLP Gate Component Figure 18: Distribution of 75% average model sparsity. A. denotes Attention. Top : Aggregated by layers. The first and last layer have highest variance (MLP most important, _cf._ Fig. 4b). Second half reaches sparsities close component removal. Bottom : Per component aggregation. In the second half of layers, the importance of attention drops drastically. MLP almost remains, with outliers to larger importance. Figure 19: Trends during sparsification. We plot the ranking of the components FDT value through various sparsity levels (y-axis) for all components (x-axis). Interestingly, there is a clear trend of components retaining “their importance”. 10 8 6 4 2 0 <u>1k vs 5k</u> Figure 20: Boxplot of the absolute differences in _MF_ 75 value for 1000 experiments comparing aggregating with 1k and 5k samples of _F_ 75 values. Figure 21: Boxplot shows FDT value (y-axis) for 1000 samples of the original Wikitext2 completions and LLama2-13b completions. 6782 Figure 22: In style of Fig. 17, Boxplots of the FDT value for all components, when pruning the lowest 60% weights of a single at once for Llama-13B. Almost depicting a sinus curve, “most equal” relevance of compo 6783 t i th iddl f th d l Th fi t d

섹션 본문 98문단 · 37,755자

(제목 없음)

1Large Language Models (LLMs) have reshaped natural language processing with their impressive capabilities.However, their everincreasing size has raised concerns about their effective deployment and the need for LLM compression.This study introduces the Divergent Token Metrics (DTMs), a novel approach to assessing compressed LLMs, addressing the limitations of traditional perplexity or accuracy measures that fail to accurately reflect text generation quality.DTMs measure token divergences that allow deeper insights into the subtleties of model compression, in particular, when evaluating components' impacts individually.Utilizing the First Divergent Token Metric (FDTM) in model sparsification reveals that 25% of all attention components can be pruned beyond 90% on the Llama-2 model family, still keeping SOTA performance.For quantization, FDTM suggests that more than 80% of the parameters can be naively transformed to int8 without special outlier management.These evaluations indicate the necessity of choosing appropriate compressions for parameters individually-and that FDTM can identify those-while standard metrics result in deteriorated outcomes.

Introduction

2Cutting-edge Large Language Models (LLMs) based on the transformer architecture (Vaswani et al., 2017) have revolutionized Natural Language Processing with their exceptional performance, notably exemplified by the GPT series (Radford et al., https://github.com/Aleph-Alpha/Divergent_Tokens2018, 2019; Brown et al., 2020;Bubeck et al., 2023) in text generation.However, these models have grown massively, even exceeding half a trillion parameters (Chowdhery et al., 2023).Although the large number of parameters aid in early training convergence, their practical utility and true necessity remain unclear.In particular, for the attention mechanism, it was hinted that after some training convergence, certain heads dominate the inference process (Michel et al., 2019).

3Compression strategies such as sparsification and quantization can enhance the efficiency of the parameters.Current metrics, however, either average too coarsely, such as perplexity, or are by design too specific, such as standard NLP benchmarks.Both fail to capture the diverging performance nuances introduced early on by the compression as they ignore the actual discontinuous text generation process.This, however, is the main application of the final model, and so we argue that they are therefore insufficient measures for the performance of the compressed model.This misalignment can lead to unwanted subtle discrepancies in generation, such as grammatical errors or a mismatch in numbers, that cause subsequent divergences.As we will show, this even occurs when overall metrics, such as perplexity, appear satisfactory (cf.Prop. 3.2,Sec. 4,Tab. 1).

4To meet these challenges, we introduce the family of Divergent Token Metrics (DTMs) in Sec. 3.These metrics are tailored to measure the model divergence of LLMs throughout the compression process and in relation to the actual generation procedure on a token basis, as shown in Fig. 1.We Figure 1: Illustration of a diverging generation process.Given the 3-token prefix as prompt, a baseline and its compressed model generate 8 subsequent tokens.Our proposed metric points to the first divergent token (FDT).The FDT may cause further divergence during the iterative generation process.Note how both models score the same perplexity value, as it does not reflect the actual sampling process (cf.Fig. 2, Sec. 4 for an empirical exploration).

5demonstrate that the First Divergent Token Metric (FDTM) and the Share of Divergent Tokens Metric (SDTM) offer a more nuanced evaluation compared to perplexity.They also enable individual component evaluation to rank parts of the model best suited for compression, thus enabling meaningful compression while preserving text generation quality.Based on FDT probing, we introduce new strategies for sparsifying and quantizing models in Sec. 4. Specifically, our proposed individual component sparsification indicates significant differences in component utilization across layers.For the first time, we show that 25% percent of the models' attention components can be pruned beyond 90%, and several even entirely removed, while preserving a single-digit perplexity.Consequently, a sparse matrix format can be employed to accelerate computational efficiency.Likewise, for precision reduction, we show that sorting components by FDTM coincidentally correlates to sorting by their induced number of outliers when being naively converted to int8.FDTM identifies the optimal 80% of the components that maintain overall performance without specific outlier handling.The observed decline in performance with more outliers, and the significant influence of specific components on those, suggests reevaluating the applied normalization methods throughout the model.We demonstrate that this level of precision goes beyond what standard perplexity and conventional NLP benchmarks can achieve.The proposed Divergent Token Metrics closely reflect the generation process and so can be a measure to foster confidence in the deployed compressed models.

Compression Principles

6Model compression aims to reduce the hardware resources needed to operate the model.However, doing so may sacrifice the accuracy of the model.To keep the loss as small as possible, a corrective measure is typically used.Here, we discuss the most commonly used concepts and state-of-the-art methods for LLM sparsification and quantization.

7Outlier and Hessians.Most model compression methods rely either on the separation of outliers (Dettmers et al., 2022;Sun et al., 2023) or the computation of a Hessian matrix (Frantar et al., 2023;Frantar and Alistarh, 2023).Outliers usually refer to significantly larger values in magnitude occurring either in the weight matrix directly or in the activations during a forward pass.As most computations are linear matrix multiplications, such outliers strongly influence the remaining entropy contained in consecutive computations.In the case of sparsification, outliers should be left intact, and values with the least magnitude, which are consequently the least influential, should instead be masked (Han et al., 2015).On the other hand, Hessian matrices can be applied to correct errors (Frantar et al., 2023).They can effectively be approximated by computing backpropagation gradients for a small number of samples and represent a second-order approximation to reconstruct the original model.

8Sparsification.The goal of sparsification is a reduction in the total number of weights and therefore a distillation of the relevant computation.Typically, this method is divided into "structured" and "unstructured" pruning.Structured-pruning aims to locate dynamics, such as the irrelevance of an entire layer or dimension for a given use case, and prunes these entirely.Unstructured-pruning usually refers to weight masking, that is, setting irrelevant weights to 0. High levels of sparse matrix computations could result in more efficient kernels and computations.In scenarios where masks exceed a 90% threshold, the implementation of a specialized sparse matrix format becomes feasible.This format predominantly stores the indices of non-zero weights.Although some additional storage is required for these indices, the overall requirement is reduced due to the exclusion of zero values.Moreover, this approach substantially improves computational performance.

9Magnitude pruning selects the masking of weights based only on their magnitudes.This is fast to compute but significantly degrades model performance when pruning large amounts simultaneously.To resolve this issue, wanda (Sun et al., 2023) proposes to sample a small amount of data and incorporates activations of the forward pass.This was shown to generate more effective one-shot pruning masks.SparseGPT (Frantar and Alistarh, 2023) computes iterative Hessian approximations to select the lowest impact weights and correct the remaining.

10Note that the incorporation of activations can, to some extent, be interpreted as a form of training.Moreover, despite these efforts, one-shot pruning has not yet produced directly usable models without further final fine-tunings.This is in particular the case for the high sparsity levels beyond 70% that we target.Finally, there has not yet been any investigation of the individual components.

11Quantization.Model quantization refers to the reduction of the precision of the used numerical format.Usually, LLMs are trained in 16-bit floating point (fp16) and converted to 8-bit integer (int8) representations.The naive conversion of float matrices to integers is AbsMax rounding.This divides a number by the maximum value occurring in the matrix and multiplies by the largest available integer, as such, it spans a uniform representation grid.The largest float value is stored and multiplied for dequantization.The most prominent methods for minimizing the introduced rounding errors are LLM.int8 and GPTQ.Dettmers et al. (2022) introduced LLM.int8(), which identifies vectors containing outliers and retains them in their original fp16 form during the matrix multiplication of a forward pass.The vectors lacking outliers are fully quantized.The int8 weights and activations during the forward pass are subsequently multiplied and dequantized afterward.This allows them to be integrated with the fp16 representation of the outliers.Through empirical investigation optimizing the trade-off between degradation in perplexity and the number of outliers preserved in fp16, they fixed an absolute outlier threshold.

12The GPTQ framework offers a more robust quantization approach, in particular, to different integer bit precisions.It does not rely on any outlier detection mechanism or mixed precision computations-matrix multiplications with the weights are fully performed using integers.Frantar et al. (2023) introduce an efficient Hessian approximation and iteratively quantize the weights of the matrices while performing error corrections on the remaining weights.

Model Divergence Metrics

13Perplexity fails to identify minor variations in model degradation at an early stage.This behavior is depicted in Fig. 1 and 2 and discussed in Sec.3.5 and 4 in more detail.To assess model divergence and enhance the model compression process, we introduce token-based metrics specifically designed to detect those nuances occurring in early compression stages.We start by establishing our notation and presenting the perplexity metric (PPL).Subsequently, we introduce an enhanced variant of PPL and propose the Share of Divergent Tokens Metric (SDTM) and First Divergent Token Metric (FDTM).We conclude by discussing the advantages of each metric compared to traditional measures based on perplexity when assessing the degradation of the generative performance of compressed models.

Basic notation

14Let F denote an auto-regressive model over a vocabulary V = {0, 1, ..., |V| − 1}, y = (y 1 , .., y N ) ∈ V N an arbitrary token sequence and F (y) = F (y) ij ∈ R N ×|V| the model logits, with i denoting the sequence and j the respective vocabulary positions.Given a prefix length n < N , we denote the token prefix y :n = (y 1 , ..., y n ) and the greedily decoded completion up to index N by G(F, y :n , N ).It is defined recursively as follows: G(F, y :n , N ) :n = y :n , and for n

Perplexity (PPL)

15Given a ground truth sequence y and model F , the negative log-likelihood of y given F is

16i=n log P(y i+1 |y i , .., y 1 ), with P(y i+1 |y i , .., y 1 ) = (softmax F (y)) iy i+1 .Then the perplexity (PPL) is given by PPL(y, F, n) = exp(NLL(y, F, n)).A common practice in the literature, e.g.(Dettmers et al., 2022), is to measure model degradation as the increase in average perplexity over a given test dataset D, e.g.randomly sampled from C4 (Raffel et al., 2020).Usually, this metric is computed disregarding the prefix, i.e., with PPL(y, F ) := PPL(y, F, 1).

Context aware model comparison

17First, we argue that standard evaluation does not reflect the typical generative model usage, i.e., there are no empty prompts, and as such, those positions should not be taken into account when evaluating the generative performance.Moreover, when comparing a compressed model F ′ to the original model F , one is interested to what extent the original behavior is kept.Therefore, we propose to use the outputs of the original model F as a ground truth to assess the performance of the compressed model F ′ .This leads to the definition of the divergent perplexity (DPPL) metric as

18Finally, let D be an arbitrary test dataset containing documents of potentially varying length.For a fixed prompt length n and completion length N , we define the aggregated divergent perplexity metric as the complete evaluation on the dataset:

19DPPL already substantially improves discriminative capabilities over PPL, as we will demonstrate in the empirical evaluation.

Divergent Token Metrics

20SDT.To further improve on the expressiveness and interpretability of model divergence, we propose the share of divergent tokens (SDT) as follows:

21SDT(y, F, n) can be interpreted as the number of times the model would need to be corrected during decoding to match the ground truth after consuming the prefix.This measure provides a more direct interpretation of the errors that occur during actual token generation, as opposed to estimating prediction certainties as PPL does.

22FDT.In addition to SDT, we introduce the first divergent token (FDT) as

23with the convention that the minimum is equal to N if the set on the right-hand side is empty.Analogously to Eq. 1 and Eq. 2, we define M SDT , M FDT , M SDT and M FDT in the same way.

24As an illustrative example, consider computing M FDT (F, F ′ , y :n , N ).We first perform a greedy decoding of N − n tokens with the base model F given the prefix y :n .We then feed the sequence G(F, y :n , N ) into the compressed model F ′ and find the first index greater than or equal to n, where the logit argmax of F ′ differs from what F generated.This computation can be done in a single forward pass similar to perplexity, and so is more efficient than accuracy-based evaluations.Trivially, 0 ≤ M FDT (F, F ′ , y :n , N ) ≤ N − n, where the upper bound is reached if and only if F and F ′ would generate the exact same sequence up to position N given the prefix y :n .Further note that

25In the following, we will ease the notation and omit M, some parameters, or the words aggregated and metric, when they are clear from the context.

Token vs. Perplexity Metrics

26It turns out that divergent token metrics offer a superior criterion for analyzing model performance degradation compared to perplexity-based metrics, especially in the context of greedy decoding.The main reason is that the greedy decoding operation G is a discontinuous function of the logits.To formalize this, let us discard the model itself and focus notation solely on the concept of logits.Definition 3.1.The operators and metrics from previous sections defined for models F, F ′ are defined for logits l, l ′ ∈ R N ×|V| by replacing all occurrences of F, F ′ with l, l ′ .

27For example, G(l, y :n , N ) i+1 = arg max j l ij , for n ≤ i ≤ N .Proposition 3.2.Given any y, N and ε > 0 there exist logits l, l ′ ∈ R N ×|V| such that

28This means that even if the average perplexity of a compressed model matches the perplexity of the original model, the compressed model can produce a very different (and potentially worse) output when performing greedy decoding.Hence leading to a false positive.In practice, this is a severe issue since even a single diverging token can lead to a completely different subsequent output.It is illustrated in Fig. 1 and 2 and discussed in Sec.4.2.

29As described above, another option is to compute the perplexity with respect to the generated completions of the original model.This metric relates more reasonably to the share of divergent tokens (SDT):

30Proposition 3.3.The following upper bound holds:

31Proof.See App. A.

32However, a comparable lower bound generally does not hold.In fact, in the case l = l ′ we trivially have M SDT (l, l, y :n , N ) = 0. Further, the value of M DPPL (l, l, y :n , N ) can still be as high as the maximal value, which occurs when l is a perfectly flat distribution at any sequence index.This could lead to a false negative signal for the generation process.

33In conclusion, perplexity-based metrics suffer from false positives or false negatives when evaluating the degradation of generative performance.The case for FDT and SDT is quite straightforward in that they both directly measure the difference between model outputs in a what-you-see-is-whatyou-get manner.

34Note that additional token-based metrics, such as the measurement of the distance between erroneous predictions, can be readily formulated.These metrics may prove especially valuable when assessing potential benefits, for instance, in the context of correction-based inference strategies such as speculative decoding (Leviathan et al., 2023).App.I further discusses the use of ground-truth versus model generated probes.We now empirically demonstrate the improvements of well-known compression methods using our metrics.

Token Metrics Improve Model Compression

35We will demonstrate in the following how the proposed metrics provide novel insights into the efficiency of the architecture of LLMs and establish benchmarks for model compression.Throughout all experiments, we outperform standard PPL as a ranking metric.

36More precisely, we apply componentwise probing to sparsification to determine individual sparsity rates.Interestingly, the model tends to completely remove components of the attention mechanism in certain layers.In total, 40 out of 160 attention components are sparsed beyond 90% and 15 removed completely.For quantization, on the other hand, we show how component selection significantly influences the overall number of model outliers.For the first time, almost 10% of the model components can be converted to 4-bit integer representations without significant model degradation.

Experimental Protocol

37Let us start by clarifying the experimental setup.

38Test environment.All experiments were performed on the public Llama2-7B and 13B models (Touvron et al., 2023).Note, however, that we observed similar behavior amongst other decoder transformer models.It remains, in particular, with upscaled sizes and smaller variations on the architecture or the training procedure.

39For all experiments, we follow best practices for compression evaluations (Sun et al., 2023) and randomly sample data from the C4 dataset (Raffel et al., 2020) for training iterations.The final model evaluation is performed comparing the loss on the Wikitext2 dataset (Merity et al., 2017) and the standard NLP benchmarks (Gao et al., 2021).

40Metrics.We apply our proposed metrics for performance evaluation, as well as selection criteria.We employ FDT, SDT, DPPL and PPL as metrics to assess the overall model divergence.With regard to model compression, we demonstrate that both PPL and our variant DPPL typically struggle to measure minor changes adequately (cf.Sec.3.5, 4.2 and Fig. 2).However, FDT is particularly suited to characterize errors for subtle model changes.Consequently, we apply FDT for model compression.

41In the following paragraph, we describe the parameters selected for using FDT in more detail.Divergent Token Parameters.We empirically selected hyperparameters as follows.Through preliminary sparsification experiments, we observed that the most variance is present in the 75%quantile of FDT, as defined in Eq. 3 (cf.Fig. 22).We denote this value by FDT 75 .In the following, it is our compare-to value.

42Next, we sweep over the given context prefix length n of FDT and sparsification steps as depicted in Fig. 3 on the y-and x-axis, respectively.The heatmap shows the overall standard deviation of FDT 75 on 5k probes.For simplicity, we fixed the prefix length to 100 tokens, as it is most discriminative on average.

43We observed that most of the sparsification steps introduce an error in FDT 75 within the range of 100 completion tokens.Therefore, we selected N = 100.Finally, to determine the number of probes |D|, we compared the mean deviation with a baseline of 5000 probes.As the deviation in the value of M F 75 of 1000 to 5000 probes only differs on average by a value 4, we selected |D| = 1000 (cf.Fig. 20).

44Pruning of LLMs.In Sec.4.2, we will show that FDT improves sparsification procedures to achieve high compression rates on LLama2-13B.To this end, we iterate small unstructured sparsification with continued training steps for the model to attune to the remaining weights and recover performance.Specifically, we apply eight iterations to increase the average model sparsity by 20, 15, 10, 10, 5, 5, 5, and 5 percent, resulting in a final model with 25% total parameters remaining.

45We run this experiment in two configurations,

46uniform and FDT-selective.Uniform sparsification applies the target increase of the current round uniformly to each component, pruning their lowest weights.For FDT, we determine individual component sparsification values to evenly distribute the induced error as depicted in Algorithm 1:

47Based on the previous sparsed model F and for the current target increase step, we probe each component c i separately with an additional step±step/2 percent of the lowest weights pruned, denoted by F c i +s , to determine its M F DT 75 value.We further add the constant extrema, that is, step sparsity 0 and 100% with values of 100 and 0. Given these four data points, we segment-wise interpolate linearly to achieve the highest value of M F DT 75 possible across all components, but on average yielding the target sparsity.Specifically, we find the set of component-sparsities {s i } that optimize for

48such that i si = step using si to represent the normalized sparsity of s i relative to the individual parameters of component c i .

49We further follow the findings of AC/DC (Peste et al., 2021) and alternate compressed and decompressed iterations as follows: Each round we train a total of 500 steps, of which the first 450 are with the sparsification mask applied and the following 50 without any masks.We found that this alternation produces smaller spikes in training loss after sparsification steps.

50This yields a total of 4000 training steps.During training, we apply a weight decay of 0.01, batch size 256, and sequence length 2048.Note that throughout this series of experiments, we only apply pure magnitude pruning per iteration.Other pruning methods, such as wanda (Sun et al., 2023), can also be straightforwardly augmented by this probing strategy.

51Quantization of LLMs.For model quantization, we compare the performance of the proposed metrics on the task of sorting the model's components by their lowest introduced error.To this end, we build a search tree to find the best model configuration as follows: We build a parallel depth-first search tree with a branching width of 10, which relates to a beam search with beam width 10.In particular, at each level of the tree, we simultaneously explore all possible successor configurations for the currently top-10 performing nodes, with one more component naively quantized using AbsMax.From this newly identified set of nodes, we again select the best performing 10 nodes for the next iteration.Starting with the unquantized base model Llama2-7B, each node contains exactly the number of quantized components respective to its depth, while the final node is a fully AbsMax quantized model.We further apply deduplication to prevent redundant computations.

Sparsification reveals:

52Attention is not all you need!

53We applied stepwise uniform magnitude pruning, and our balanced componentwise pruning using FDT, to achieve 75% model sparsity.A summary of the results is shown in Fig. 4. Attention almost erased.Fig. 4b visualizes the converged sparsity values when applying our balanced pruning using FDT.Notably, the model favors pruning attention over MLP.In total 40 of 160 attention components are sparsed beyond 90% and 15 even completely removed.In general, the second half of the model appears to be more prunable than the first half.The value matrices are overall the least pruned of the attention matrices.Finally, significant outliers appear in the first and last layers.This finding indicates that attention is not utilized efficiently throughout model inference.

54In fact, only layers 3 to 20 and layer 40 appear to be of significant relevance for the model's final prediction.This observation might be attributed to an evolving shift in distributions and, with that, the concepts processed in embeddings.Notably, in the first layer Attention Value and MLP Down remain significantly dense, while all others are comparably sparse.This observation indicates an incomplete shift of token embeddings.

55General Observations.As shown in Fig. 4a, FDT based balanced pruning significantly lowers the introduced error between sparsification rounds.Uniform pruning, on the other hand, substantially diverged, and in particular does not regain performance with the given amount of compute.Generally speaking, what is lost can hardly be recovered.

56The standard evaluation of FDT and PPL on Wikitext2, is found in Tab. 1.The 75% compressed 13B model, with several components pruned away, scored PPL 8.1, compared to PPL 4.8 of the base model.Note that no other model sparsed beyond 70% has yet been reported, in particular, achieving single-digit PPL.Uniform pruning achieved 13.5.Further note, that we almost doubled the mean FDT value when compared to uniform pruning.However, as the generally low FDT value suggests, it still diverged substantially from the base model.

57FDT is more discriminative.In practice, FDT is better able to discriminate subtle changes than PPL.We demonstrate this with the following experiment: On each component of the model, we prune 0.1% of the weights either randomly or from the lowest weights.The resulting model is probed for 1000 trials with all the discussed metrics used to distinguish the cases.The results in Fig. 2 clearly indicate that FDT is capable of distinguishing the cases, while they remain indifferent for PPL-based comparison.We therefore omit using PPL as a metric to determine step-sizes for the described sparsification experiment.

Quantization: Outliers can be prevented

58Finally, we demonstrate the impact of selecting the right components for quantization.We compare the proposed metrics PPL, DPPL, and FDT as ranking criteria to showcase their discrimation capabilities.

59Quantization without outlier-handling.Fig. 5 shows the average performance of the top 10 nodes occuring in the respective search tree depth (x-axis).FDT continuously outperforms the other metrics on the SDT value (y-axis).Notably, this is on par with the total number of outliers occurring for the respective configurations (second y-axis).Certain components appear to significantly influence the decline observed in both measures.Although DPPL enhances some aspects of performance, neither variant of PPL effectively distinguishes these components and tends to select those prematurely.

60With FDT, we can cast 80%, i.e. 150, of the model's components directly into int8 using only naive AbsMax-and without further outlier handling-still outperforming the full LLM.int8()conversion in model performance.Selecting those 150 components with DPPL and FDT leads to close perplexity scores 5.490 and 5.489 on Wikitext2, cf.Tab. 1.However, the resulting mean FDT improves by almost 50% when also selecting the components by this metric.The larger generation of the same sequences suggests a model closer to the orig- inal when choosing FDT as a selection criterion.Fig. 5b) shows the selected components at each depth in relation to a).Most outliers occur when the Attention Key is selected early on.Notably, we observed in Sec.4.2, that this is one of the matrices most suitable to sparsify.16 components in 4-bit.Figure 6a) presents a comprehensive assessment of the quantization techniques discussed.First, it is noticeable that the LLM.int8() method slightly improves the lower quantile scores of FDT in comparison to Abs-Max.However, GPTQ (8bit) demonstrates superior performance, outshining both plain AbsMax and LLM.int8().This method achieves a more balanced error distribution across all components (cf.App.Fig. 17).On the contrary, GPTQ (4-bit) shows noticeable deviations in the generation process, with only a limited number of components achieving FDT scores greater than 400.Despite this, the discriminative power of FDT enabled us to identify and merge the top 16 components that minimally compromised the integrity of the model, as illustrated in Fig. 6b).

Conclusion

61We introduced the Divergent Token Metrics (DTMs), a tailored approach to evaluate the performance differences of compressed generative models.In particular, DTMs respect the usually applied greedy sampling procedure to generate predictions.We proved that DTMs achieve appropriate metric bounds and are not affected from catastrophic artefacts that perplexity-based metrics encounter.We constructed algorithms for iterative sparsification and quantization processes based on DTM probing of individual components.Using DTMs, we achieved an outperforming 75% sparse version of Llama2-13B and successfully converted 80% of the LLama2-7B components naively to int8.

Limitations

62With the proposed DTMs, compression processes can be tailored to use cases-and we can measure their performance degeneration.We hinted with the sparsification experiments, that MLP and Attention can be ascribed varying levels of significance throughout the layers.These studies should be further extended to various model architectures such as BERT or MoE.Moreover, variations of specific datasets to probe or finetune on could lead to interesting observations.For example, multilingual, multitasking and instruction tuned MoE models could be pruned multiple times using FDT to investigate how the information actually is stored and assembled.Note that this work solely relied on English-tailored pruning for a mostly Englishtrained model.Furthermore, augmenting our metrics to probe for (and investigate) specific aspects such as safety alignments, and preserving these elements throughout model compression would be a significant area of study.

63As a pruning strategy, we achieved outperforming results using only naive magnitude pruning.DTMs should be directly applicable to other masking strategies, such as Wanda (Sun et al., 2023), which may further improve results.Finally, the generalizability of the metrics to other sampling strategies should be investigated.when quantizing parts of a model.Often, standard evaluations fail to distinguish between compressed models.Sometimes they even depict better performance-which may be true, when regarding compression as a fine-tuning method and considering the short required token predictions.FDT thoroughly gives discriminative statistics with resprect to the base model, on how much the compressed model equals the original.Note how the error seems to be upper bounded, which suggests that errors may average out throughout the model.Mean zeroshot accuracy denotes the average on the standard NLP-eval harness.

C True positives can be predicted

64Fig. 8 shows several metrics applied to the tokendistributions, in order to estimate on whether the compressed and original model predictions are equal.Notably, L1 and L2 errors on the entire distribution seem to somewhat capture the discriminative capabilities of false predictions.The probability scores themselves are only marginally usable.Using top-2 uncertainty, i.e. the difference between the top-2 tokens as a measure, we obtain a reliable prediction of true positives.True negatives however still remain with a significant overlap.

65D MLP is for knowledge, Attention for relation Finally, we observed that when pruning only attention, prompt-extraction capabilities degenerate severely.When only pruning MLP components, on the other hand, it influences mostly world knowledge QA benchmarks, cf.Fig. 7.

66E Details on Search Tree, Sec.4.3

67Fig. 9 shows the layers (y-axis) of which components are selected at each round (x-axis).While there seems to be a pattern on when using FDT as a criteria (top), selection by PPL (bottom) looks more random.Fig. 15 shows the comparison of search tree as described to greedy search on a single evaluation of all components.Until 150 components, FDT proves more stable over the PPL variants as seen in Fig. 15a.

68F Details on Quantization Sec.4.3 Fig. 17 shows detailed componentwise evaluations aggregated in Fig. 6a.

69Fig. 16 shows the final configurations as compared in Tab. 1.

70Fig. 11 shows the detailed nlp-eval scores of Tab. 1.

71Fig. 12 shows greedy search trees over various context lengths.

72In total the entire search evaluation required 16 GPU-days with A100s to complete all metrics.

73G Details on Sparsification, Sec.4.2 Fig. 18 shows a different aggregated perspective of Fig. 4b, to point out more direct the occuring variances.

74Fig. 19 shows the rank of lowest influence (measured by FDT) of components (x-axis) throughout various sparsity levels (y-axis).I.e.starting with a uniformly pruned model in 5% steps, we measured the rank when adding an additional 2.5% only to a single component.Interestingly, components seem to retain their importance throughout the various levels of sparsity.

75Fig. 13 shows the detailed nlp-eval scores of Tab. 1.

76Note that, despite being often close in relative sparsity, the total number of parameters pruned for MLP is significantly larger than for Attention matrices (ratio 3:1).

77Finally, Fig. 22 shows detailed componentwise pruning experiments.

78In total one sparsification training required 32 GPU-days with A100s for our experiment, and 29 GPU-days for uniform pruning.

H Further Hyperparameters

79Fig. 20 shows that 1k probes are enough to determine a stable M F 75 value.

I Model Completion vs. Ground Truth

80Fig. 21 shows the FDT value that compares the ground truth of the data set with the completion of the model on Wikitext2.Tab. 2 further gives an example for better comparison.It can be observed that, even though Wikitext2 was contained in the training dataset, Llama2-13B does not properly recall it, and as such, the FDT value is close to 0. Therefore, we cannot utilize generic data samples as ground truth alone in such a general-purpose pruning setup.Afterall, our goal is to measure the "deviation" of the compressed model to its baseline.For more specific, e.g.Q/A datasets, it may, however, be more feasible.

Figure 2 :

81Figure 2: Pruning lowest weights, and random weights.FDT is able to discriminate the cases.PPL exactly performs on the level of guessing.Cf.Sec.4.2.

Figure 3 :

82Figure 3: Hyperparameter selection of FDT.Visualized is the standard deviation (std) in FDT 75 over all components when varying prefix length (y-axis) and applying different choices for sparsity-step increases (x-axis), cf.Sec.4.1 and 4.2.

83Converged component config with 75% average sparsity.Layers (x-axis), Component-sparsity (y-axis).

Figure 4 :

84Figure 4: Depiction of the proposed sparsification process that converged to a 75% sparse Llama-2-13B.a) Model training performance throughout all rounds.Our FDT-based sparsification clearly outperforms uniform magnitude pruning.b) Converged sparsity values per component.One quarter of attention components are pruned beyond 90% sparsity.Significant outliers appear in first and last layers.

85Selected Components FDT (top) vs PPL (bottom).

Figure 5 :

86Figure 5: Evaluation of the Tree Search as described in text.a) Comparison of Tree Search based componentwise quantization.Different numbers of components (x-axis) lead to different token divergence scores (y-axis, normalized to [0, 1]), and in particular correlates early on to introduced outliers (second y-axis).Throughout the entire search, FDT is able to rank components by their potential errors and, coincidentally, outliers.b) Selected components at respective depth.A.Key and A.Value induce most error.

87Quantization methods evaluated on Components.

Figure 6 :

88Figure 6: Evaluation of FDT performance.a) evaluates components separately on all quantization methods.Clear outliers in performance are A. Value and MLP Up.GPTQ (8bit) is able to evenly amortize the induced error.b) Selecting top-k components of GPTQ (4bit).FDT is suited to rank components one-shot.

Fig. 10

89Fig.10shows a comparison of standard benchmarks (middle) to FDT (right) andPPL (left)

Figure 7 :

90Figure 7: Pruning MLP and Attn only indeed compromises remaining model capabilities.

Figure 8 :Figure 9 :

91Figure 8: Top-2 uncertainty is discriminative enough to give clear true-positives estimates on compressed models.

Figure 17 :

92Figure 17: Full view of the influence of individual componentwise quantization measured by FDT.

Figure 18 :

93Figure 18: Distribution of 75% average model sparsity.A. denotes Attention.Top: Aggregated by layers.The first and last layer have highest variance (MLP most important, cf.Fig. 4b).Second half reaches sparsities close component removal.Bottom: Per component aggregation.In the second half of layers, the importance of attention drops drastically.MLP almost remains, with outliers to larger importance.

Figure 19 :Figure 20 :

94Figure19: Trends during sparsification.We plot the ranking of the components FDT value through various sparsity levels (y-axis) for all components (x-axis).Interestingly, there is a clear trend of components retaining "their importance".

Figure 21 :

95Figure 21: Boxplot shows FDT value (y-axis) for 1000 samples of the original Wikitext2 completions and LLama2-13b completions.

Figure 22 :

96Figure 22: In style of Fig. 17, Boxplots of the FDT value for all components, when pruning the lowest 60% weights of a single at once for Llama-13B.Almost depicting a sinus curve, "most equal" relevance of components appear in the middle of the model.The first and last layers are dominated by outliers, i.p., MLP Up and A. Dense.

97Algorithm 1 Iteration of pruning algorithm input: F, step ▷ current model, target sparsity fdt_sparse_map ← {} for c i ∈ Components do fdt_sparse_map[c i ] ← [100, M FDT 75 (F, F c i +step/2 ), M FDT 75 (F, F c i +step+step/2 ), 0]

Table 1 :

98Evaluations of the final Compressed Models.

참고문헌

참고문헌 정보가 없습니다.