Basis Sharing: Cross-Layer Parameter Sharing for Large Language Model Compression

## Abstract

Abstract Large Language Models (LLMs) have achieved remarkable breakthroughs. However, the huge number of parameters in LLMs require significant amount of memory storage in inference, which prevents their practical deployment in many applications.
To reduce memory storage of LLMs, singular value decomposition (SVD) provides a promising solution to approximate weight matrices for compressing LLMs. In this paper, we take a step further to explore parameter sharing across different layers with SVD to achieve more effective compression for LLMs. Specifically, weight matrices in different layers are decomposed and represented as a linear combination of a set of shared basis vectors and unique coefficients. The types of weight matrices and the layer selection for basis sharing are examined when compressing LLMs to maintain the performance. Comprehensive experiments demonstrate that
Basis Sharing outperforms state-of-the-art SVD-based compression approaches and parameter sharing techniques, especially under large compression ratios. Code is available at: https://github.com/TUDa-HWAI/Basis_Sharing

## 1 Introduction

Large Language Models (LLMs) have revolutionized natural language processing by enabling machines to understand human language more accurately. Although these models have remarkable capabilities, they are computation- and memory-intensive, making their deployment on resource-constrained devices challenging. To address this challenge, model compression has become a widely adopted technique to reduce model size and complexity.

Common compression techniques, such as model distillation (Gu et al., , Magister et al., , Jiang et al., , Huang et al., , Qiu et al., ),
pruning (Frantar & Alistarh, ; , Ma et al., , Sun et al., , Jiang et al., , Petri et al., ),
and quantization (Lin et al., , Zhao et al., , Ashkboos et al., , Xiao et al., , Sun et al., ), early-exit (Pan et al., , Wang et al., ) etc. have been extensively studied.
While such techniques are effective in many scenarios, these methods often require hardware modification and expensive retraining. Compression techniques based on low-rank approximation with, e.g., Singular Value Decomposition (SVD) (Yuan et al., , Hsu et al., , Wang et al., ), provide a promising alternative since they are not restricted by such constraints. In SVD-based weight compression, a weight matrix in a layer is processed individually by decomposing it into three matrices. By removing small singular values in the decomposed diagonal matrix, the original weight matrix can be approximated with fewer number of weight values.

Despite the benefits of SVD-based weight compression, the potential of grouping layers for weight approximation and compression has not been explored thoroughly. Since weight matrices in different layers of an LLM might share similarity, parameter sharing across layers can be exploited to further compress weight matrices for LLMs. In sharing parameters across layers, Hay & Wolf ()
trained a small language model by restricting weight matrices in some layers to be the same. On the one hand, this brute-force method leads to significant performance degradation since weight matrices in different layers should vary to maintain their functionalities. On the other hand, it is impractical to train LLMs from scratch due to limited training data or high training costs.

Contrary to previous work, in this paper, we use pretrained LLMs to enable weight matrices across layers to share a common set of basis vectors but still retain their different functionalities with unique coefficients. Our method, called Basis Sharing, can compress LLMs effectively.
In summary, our contributions are as follows:

- 1.
We propose to represent weight matrices across different layers in a pretrained LLM with a linear combination of a set of shared basis vectors and coefficients unique to specific layers. This basis sharing can effectively reduce the number of parameters in LLMs while only affecting the performance of LLMs slightly.
- 2.
We examine cross-layer basis sharing for different types of weight matrices in LLMs according to the incurred compression errors. The types of weight matrices whose sharing across layers does not incur significant compression error are selected for compressing LLMs.
- 3.
For the selected types of weight matrices, we also develop a criterion to group layers to share a set of basis vectors but have individual coefficients to
preserve the performance of LLMs.
- 4.
We conduct extensive experiments on a variety of LLMs, including the LLaMA family (Touvron et al., ; ), OPT-6.7B (Zhang et al., ), Mistral-7B (Jiang et al., ), and GPT-2 (Radford et al., ). Our Basis Sharing can surpasses the state-of-the-art SVD-based methods in both generation tasks and downstream reasoning tasks without any fine-tuning under compression ratios from 20% to 50%. Specifically, compared with state-of-the-art SVD-based compression approaches, Basis Sharing can further reduce the perplexity by up to 25% on generation tasks and improve accuracy by up to 4% on downstream reasoning tasks under the same compression ratio.

## 2 Related Work

#### Large Language Model Compression

LLM compression techniques include model distillation, pruning and quantization, etc.
Gu et al. (), Huang et al. (), Magister et al. (), Jiang et al. () successfully applied model distillation to LLM by retraining,
which incurs high computational cost.
Frantar & Alistarh (; ), Sun et al. (), Ma et al. () pruned weights that are less sensitive to outliers. However,
the resulting unstructured weight matrices do not provide meaningful compression benefits on real hardware. Structured pruning techniques, such as 2:4 or 4:8 pruning, can achieve effective compression but restrict a fixed 50% pruning ratio, which limits flexibility in balancing performance and compression ratio.
Zhao et al. (), Ashkboos et al. (), Lin et al. (), Xiao et al. ()
allocated higher quantization bits to weights with larger influence on outliers,
but it does not reduce the number of parameters, limiting its impact on overall compression.

#### SVD-based Weight Compression

SVD-based weight compression has a flexible compression ratio to maintain performance without retraining.
Golub et al. () were the first to apply SVD for neural network compression, and Lv et al. (), Wu et al. () extended this approach to shallow transformer models (Vaswani, ). However, in LLM compression, these methods incur significant errors since they do not consider outliers in activations.
FWSVD (Hsu et al., ) addresses this issue by incorporating the impact of outliers through the Fisher information analysis of weight matrices. However, this method requires gradient information during training process, which is computationally prohibitive for LLMs.
ASVD (Yuan et al., ) alleviates this problem by selecting key channels in the weight matrix based on their sensitivity to outliers and minimizing compression error in these channels. While it avoids the need for gradients, ASVD still lacks a direct connection between SVD truncation error and the overall model compression error.
SVD-LLM (Wang et al., ) improves this by introducing a whitening matrix that captures outlier information, effectively reducing compression error.
However, all of these methods focus only on compressing individual weight matrices within a single layer, missing the opportunity to exploit weight compression across multiple layers.

#### Parameter Sharing

Parameter sharing reduces model size by reusing weight matrices across different layers. Inspired by recurrent neural networks, Dehghani et al. () explored this concept within transformers by restricting all layers in the encoder and decoder to share the same weights. Similarly, Reid et al. () divided transformer parameters into two groups (attention-related and feedforward-related) and compressed the model by sharing weights within each group.
Takase & Kiyono () applied selective weight sharing, where specific layers shared the same weights rather than all layers. Beyond direct weight sharing, Xiao et al. (), Bhojanapalli et al. () introduced the idea of sharing attention scores between layers. By reusing attention scores, some weight matrices for attention computation could be discarded. Dynamic Tying (Hay & Wolf, ) determines layer-wise weight sharing during training using reinforcement learning, which is still time-consuming for large LLMs.
All of these approaches have been tested only on smaller transformer models and typically require training from scratch or full parameter fine-tuning, which makes them impractical for LLMs.

## 3 Methodology

Figure: Figure 1: (a) Two layers share the same weight matrix in previous work. (b) Two layers share the same basis matrix but have their individual coefficients in our work.
Refer to caption: x1.png

Contrary to the previous techniques that require training from scratch and weights in some layers are restricted to be the same during training,
we adopt a pretrained LLM to explore
representing weights across different layers with combinations of a set of shared basis vectors and individual coefficients. Since the set of basis vectors can be shared across several layers, the number of parameters in the LLM can thus be reduced effectively. The difference between the previous weight sharing method and our Basis Sharing is illustrated in Figure 1.

To exploit the cross-layer parameter sharing to compress LLMs, the subsequent subsections address the following challenges: 1) What methodologies can be used to process the weight matrices across layers in an LLM to determine a set of shared basis vectors and individual coefficients? 2) Which types of weight matrices across layers in an LLM can take advantage of parameter sharing without affecting its performance significantly? 3) Which layers can share a set of basis vectors in an LLM without affecting its performance significantly?

### 3.1 Representing Weight Matrices across Layers with Combinations of Basis Vectors and Coefficients

Suppose that we have weight matrices across $n$ layers, denoted as $\displaystyle\displaystyle{\bm{W}}^{(1)}\dots\displaystyle{\bm{W}}^{(n)},
\displaystyle{\bm{W}}^{(i)}\in\mathbb{R}^{d_{1}\times d_{2}}$. To derive a set of shared basis vectors and coefficients to represent such weight matrices, intuitively, such matrices can be horizontally concatenated into one matrix, denoted as $\displaystyle{\bm{W}}\in\mathbb{R}^{d_{1}\times nd_{2}}$, and singular value decomposition (SVD) can be applied to decompose this matrix into three matrices: ${\bm{U}},{\bm{\Sigma}},{\bm{V}}^{T}$. ${\bm{\Sigma}}$ is a $d_{1}\times nd_{2}$ diagonal matrix consisting of singular values of $\displaystyle{\bm{W}}$.

By selecting the top $k$ singular values in $\displaystyle{\bm{\Sigma}}$, $\displaystyle{\bm{W}}$ can be approximated as $\displaystyle{\bm{W}}\approx\displaystyle{\bm{W}}_{k}={\bm{U}}_{k}{\bm{\Sigma}
}_{k}{\bm{V}}^{T}_{k}$, where the dimensions of $\displaystyle{\bm{U}}_{k}$, $\displaystyle{\bm{\Sigma}}_{k}$ and ${\bm{V}}^{T}_{k}$ are $d_{1}\times k$, $k\times k$, and $k\times nd_{2}$, respectively.
The value of $k$ should be determined to balance the compression ratio and the performance of the compressed LLM (Appendix A.1 shows the evaluation of $k$ under a given compression ratio).
$\displaystyle{\bm{W}}_{k}$ can be rewritten as $\displaystyle{\bm{W}}_{k}={\bm{B}}{\bm{V}}^{T}_{k}$, where $\displaystyle{\bm{B}}$ is the multiplication result of $\displaystyle{\bm{U}}_{k}$ and $\displaystyle{\bm{\Sigma}}_{k}$. We call $\displaystyle{\bm{B}}$ a basis matrix and a column of $\displaystyle{\bm{B}}$ is a basis vector, denoted as ${\bm{B}}_{:,i}$. $\displaystyle{\bm{V}}^{T}_{k}$ can be considered as a coefficient matrix, i.e., $\displaystyle{\bm{V}}^{T}_{k}=\displaystyle{\bm{C}}$. Accordingly, the $\displaystyle j^{th}$ column of the original weight matrix
$\displaystyle{\bm{W}}^{(i)}$ in the $i^{th}$ layer
can be approximated as a liner combination of
$k$ basis vectors and individual coefficients as follows.

$$ $\displaystyle{\bm{W}}^{(i)}_{:,j}\approx\sum_{m=1}^{k}{\bm{B}}_{:,m}{\bm{C}}^{ (i)}_{m,j}.$ (1) $$

where ${\bm{C}}^{(i)}$ is the coefficient matrix in $i^{th}$ layer.
The process of weight matrix approximation and representation is illustrated in Figure 3.

Figure: Figure 2: Weight matrices across $n$ layers are concatenated horizontally into a weight matrix, which is processed by SVD. The $j^{th}$ column of the original weight matrix in a layer can be represented as a linear combination of $k$ shared basis vectors and coefficients.
Refer to caption: x2.png

In the weight matrix approximation with SVD above, input data, denoted as $\displaystyle{\bm{X}}$, are not considered. In fact, the result of $\displaystyle{\bm{X}}{\bm{W}}$ instead of $\displaystyle{\bm{W}}$ is used in inference.
Accordingly, applying SVD directly onto weight matrices
without incorporating input data might lead to significant computation loss and potentially affect the performance of the LLM. Figure 3 illustrates an example, where a weight matrix approximated with SVD leads to a large compression loss in the form of Frobenius loss, denoted as $\displaystyle||{\bm{X}}\Delta{\bm{W}}||_{F}$.
Since the second element in the input data affects the computation accuracy significantly, the second column of the weight matrix should be approximated more accurately compared with other columns to reduce the overall computation loss. Yuan et al. (), Wang et al. () also pointed out similar results.

To incorporate the effect of input data into the weight approximation with SVD to maintain the performance of the LLM, we will scale the concatenated weight matrix $\displaystyle{\bm{W}}$ with a matrix $\displaystyle{\bm{S}}\in\mathbb{R}^{d_{1}\times d_{1}}$ as follows

$$ $\displaystyle{\bm{W}}={\bm{S}}^{-1}{\bm{S}}{\bm{W}}={\bm{S}}^{-1}({\bm{S}}{\bm {W}}).$ (2) $$

The matrix $\displaystyle{\bm{S}}$ should be evaluated to represent the impact of input data on the weights, so that it can adjust $\displaystyle{\bm{W}}$ accordingly to reflect the significance of
different input data. To obtain appropriate $\displaystyle{\bm{S}}$,
we will adapt the techniques developed in Wang et al. (), where $\displaystyle{\bm{S}}$ can be evaluated with $\displaystyle{\bm{S}}({\bm{S}})^{T}=cholesky(({\bm{X}})^{T}{\bm{X}})$. However, $\displaystyle{\bm{X}}$ in their technique refers to input data of a layer instead of several layers in our method. To evaluate $\displaystyle{\bm{S}}$ considering several layers, we will vertically concatenate the input matrices in such layers, denoted as, ${\bm{X}}^{(1)},\dots,{\bm{X}}^{(n)}$, and compute the ${\bm{S}}$ with the concatenated ${\bm{X}}$.
In our experiments, we use 256 samples from WikiText-2 (Merity et al., ) with each 2048 tokens to evaluate ${\bm{X}}$, similar to that in Wang et al. ().

Instead of applying SVD directly on the concatenated weight matrix $\displaystyle{\bm{W}}$, we will decompose $\displaystyle{\bm{S}}{\bm{W}}$ with SVD and approximate this scaled weight matrix $\displaystyle{\bm{S}}{\bm{W}}\approx{\bm{U}}^{\prime}_{k}{\bm{\Sigma}}^{\prime
}_{k}{\bm{V}}^{\prime}_{k}={\bm{B}}^{\prime}{\bm{C}}^{\prime}$, where $\displaystyle{\bm{B}}^{\prime}$ and $\displaystyle{\bm{C}}^{\prime}$ are the revised basis matrix and coefficient matrix, respectively.
To recover the approximated weight matrix for computation in inference, $\displaystyle{\bm{S}}^{-1}$ will be multiplied with $\displaystyle{\bm{B}}^{\prime}$, the result of which will be the final adjusted basis matrix, i.e.,

$$ $\displaystyle{\bm{W}}\approx{\bm{S}}^{-1}{\bm{U}}^{\prime}_{k}{\bm{\Sigma}}^{ \prime}_{k}{\bm{V}}^{\prime}_{k}={\bm{S}}^{-1}{\bm{B}}^{\prime}{\bm{C}}^{ \prime}={\bm{B}}^{\prime\prime}{\bm{C}}^{\prime},$ (3) $$

where ${\bm{B}}^{\prime\prime}$ is the final adjusted basis matrix in our paper.

### 3.2 Selection of Weight Matrices in LLMs for Cross-Layer Parameter Sharing

Modern LLMs are constructed based on the decoder-only transformer architecture. A layer in such an architecture includes several types of weight matrices, which have different functions. ${\bm{W}}_{K}$, ${\bm{W}}_{Q}$ and ${\bm{W}}_{V}$ are three types of projection matrices, which are used to generate the key, the query and the value matrices. ${\bm{W}}_{O}$, another type of weight matrices, further transforms the attention result to build a new representation for an input embedding.
${\bm{W}}_{Up}$ and ${\bm{W}}_{Gate}$(used in LLaMA and LLaMA2), further types of weight matrices,
represent this transformation result into a high-dimension embedding.
Afterwards, ${\bm{W}}_{Down}$, the last type of weight matrices, projects the high dimension embedding back to the low dimension embedding.
The types of weight matrices above have different functions, so that we need to determine which type of weight matrices can take advantage of cross-layer basis sharing with SVD described in Section 3.1 without affecting the performance of the LLM significantly.

First of all, the type of matrices whose function are to project a high-dimension embedding into a low-dimension embedding such as ${\bm{W}}_{Down}$ cannot take advantage of the cross-layer parameter sharing. The reason is that after the horizontal concatenation of such matrices,
the rank of the concatenated matrix will be larger than that of an individual matrix.
Under the same compression ratio, compressing the concatenated matrix with SVD incurs a larger Frobenius loss than the original weight matrix.

For the remaining types of weight matrices including ${\bm{W}}_{K}$, ${\bm{W}}_{Q}$, ${\bm{W}}_{V}$, ${\bm{W}}_{O}$, ${\bm{W}}_{Up}$ and ${\bm{W}}_{Gate}$, we will determine whether each of them can use cross-layer basis sharing by examining the Frobenius loss resulted from this sharing.
To explain this concept, we use basis sharing
across two layers for ${\bm{W}}_{K}$ in LLaMA2-7B as an example. Assume that we remove small singular values by applying SVD on ${\bm{S}}^{(i)}_{K}{\bm{W}}^{(i)}_{K}$ to achieve a compression ratio of 20%, where ${\bm{W}}_{K}^{(i)}$ is ${\bm{W}}_{K}$ matrix in the $i^{th}$ layer ($i\in[1,32]$) and ${\bm{S}}_{K}^{(i)}$ is the corresponding ${\bm{S}}$ matrix for ${\bm{W}}_{K}^{(i)}$. The resulting Frobenius loss of each layer under this compression ratio will be evaluated.
To evaluate the Frobenius
loss incurred by basis sharing,
we horizontally concatenate ${\bm{W}}_{K}^{(i)}$ of the $i^{th}$ layer and ${\bm{W}}_{K}^{(j)}$ of the $j^{th}$layer as ${\bm{W}}_{K}^{(i,j)}$ where $j\not=i$, $i,j\in[1,32]$. SVD is applied on ${\bm{S}}^{(i,j)}_{K}{\bm{W}}_{K}^{(i,j)}$ to remove small singular values to achieve the same compression ratio, where ${\bm{S}}^{(i,j)}_{K}$ is the corresponding S matrix for ${\bm{W}}_{K}^{(i,j)}$.
Afterwards,
we evaluate the incurred Frobenius loss of basis sharing across two layers.
Similarly, we repeat the process above for ${\bm{W}}_{O}$.
The results are illustrated in Figure 4, where the number/color in a block represents the resulting Frobenius loss if a basis matrix is shared between two layers and the numbers in the diagonal direction are obtained by applying SVD to the scaled weight matrix of a layer directly.

Figure: Figure 4: Frobenius loss incurred by basis sharing across any two layers. The number/color in a block represents the resulting Frobenius loss if a basis matrix is shared by two layers and the numbers in the diagonal direction are obtained by applying SVD to the scaled weight matrix of a layer directly. (a) Frobenius loss incurred by basis sharing across two layers for ${\bm{W}}_{K}$ in LLaMA2-7B. (b) Frobenius loss incurred by basis sharing across two layers for ${\bm{W}}_{O}$ in LLaMA2-7B.
Refer to caption: x4.png

Figure 4
compares the results of basis sharing for ${\bm{W}}_{K}$ and ${\bm{W}}_{O}$.
Basis sharing across two layers for ${\bm{W}}_{K}$ can reduce the Frobenius loss. For example,
when SVD is applied on ${\bm{S}}_{K}{\bm{W}}_{K}$ for the $9^{th}$ and $10^{th}$ layers separately, the resulting Frobenius loss is evaluated as $33508.2+33174.7=66682.9$. When the $9^{th}$ and $10^{th}$ layers share a common basis matrix, the Frobenius loss resulting from compression becomes smaller, i.e, $61817.3<66682.9$. This indicates that allowing parameter sharing across two layers for ${\bm{W}}_{K}$ can enhance computation accuracy. This trend can be seen in ${\bm{W}}_{K}$, ${\bm{W}}_{Q}$, ${\bm{W}}_{V}$, ${\bm{W}}_{Up}$ and ${\bm{W}}_{Gate}$ (Appendix A.2 show the results). Accordingly, basis sharing across layers can be applied on such matrices.

On the contrary, basis sharing for ${\bm{W}}_{O}$ in $9^{th}$ and $10^{th}$ layers incurs the increase of the Frobenius loss, i.e., $10618.3>4355.1+4895.7$. Accordingly, this parameter sharing should not be applied on ${\bm{W}}_{O}$ to avoid significant computation loss. For such matrices, we will apply SVD to process the individual matrix in each layer separately.

### 3.3 Selection of Layers for Basis Sharing

Section 3.1 determines which types of weight matrices can be shared across layers. This subsection then determines which layers can share basis vectors to represent such types of weight matrices. To select layers for basis sharing, the basis sharing of such layers should not incur Frobenius loss larger than without sharing.
According to Figure 4, the group of two adjacent layers leads to smaller Frobenius loss than the sum of the Frobenius loss of two separate layers. Based on this analysis, we will group adjacent layers with the order from the first layer to the last layer. Take a group of two layers as an example. The first layer and the second layer are grouped for basis sharing, followed by the group of the third layer and the fourth layer, etc.

## 4 Experiments

### 4.1 Settings

#### Baseline

We compare with the work where SVD-based weight approximation in each individual layer is applied without cross-layer parameter sharing. Such work includes ASVD (Yuan et al., ), FWSVD (Hsu et al., ) and SVD-LLM (Wang et al., ). We also compared our method with Dynamic Tying (Hay & Wolf, ), where weights in some layers are restricted to be the same by training from scratch.
Since this method can only be applied on small language models, only GPT2 (Radford et al., ) was used to compared our method and Dynamic Tying.

#### Models and Datasets.

We evaluate our method using several models. For LLMs, many models are evaluated, namely LLaMA family (LLaMA-7B, LLaMA-13B, LLaMA-30B, LLaMA2-7B) (Touvron et al., ; ), OPT-6.7B (Zhang et al., ), Mistral-7B (Jiang et al., ), GPT2. Three language modeling datasets used in our experiment include WikiText-2 (Merity et al., ), PTB (Marcus et al., ) and C4 (Raffel et al., ). Seven reasoning datasets used in the experiments include OpenbookQA (Banerjee et al., ), WinoGrande (Sakaguchi et al., ) HellaSwag (Zellers et al., ), PIQA (Bisk et al., ), MathQA (Amini et al., ), ARC-e, ARC-c (Clark et al., ). All the reasoning tasks are tested in zero-shot setting with the implementation of LM-Evaluation-Harness framework (Gao et al., ).

#### Implementation details

All of our models are based on the model implemented by the Hugging Face. LLaMA-30B are implemented with FP16, the rest models are implemented with FP32. To evaluate ${\bm{S}}$, FP64 is used to maintain the computation precision. All experiments are tested on two NVIDIA A100 80GB GPUs.
${\bm{S}}$ is derived through 256 samples from WikiText-2 with 2048 sequence length.
When the compression
ratio is 40% or larger than 40%
, the incurred compression errors increase, so that the output of a layer as the input of the next layer deviates significantly from its original values. This input deviation affects the evaluations of ${\bm{S}}$ with $\displaystyle{\bm{S}}({\bm{S}})^{T}=cholesky(({\bm{X}})^{T}{\bm{X}})$. To incorporate this input deviation, we update the weights in the next layers for basis sharing with such deviated inputs, similar to that in SVD-LLM.

### 4.2 Results

We evaluate the performance of the proposed cross-layer parameter sharing from four aspects: (a) Performance on generation and reasoning tasks and comparison with state of the art in zero-shot setting. (b) LLM Performance on different LLMs in zero-shot setting. (c) Performance on LLMs with various scales in zero-shot setting. (d) LLM performance with LoRA (Hu et al., ) fine-tuninng. (e) Comparison with training from scratch for weight sharing across layers.

#### Performance on Generation & Reasoning Tasks

**Table 1: PPL($\downarrow$) and Zero-shot($\uparrow$) performance of LLaMA-7B with Basis Sharing and baselines under 20% to 50% compression ratio on three language modeling datasets and seven common sense reasoning datasets. The ${\bm{S}}$ of all tasks is obtained with the dataset WikiText-2.**
| Ratio | Method | WikiText-2$\downarrow$ | PTB$\downarrow$ | C4$\downarrow$ | Openb. | ARC_e | WinoG. | HellaS. | ARC_c | PIQA | MathQA | Average$\uparrow$ |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| 0% | Original | 5.68 | 8.35 | 7.34 | 0.28 | 0.67 | 0.67 | 0.56 | 0.38 | 0.78 | 0.27 | 0.52 |
| 20% | SVD | 20061 | 20306 | 18800 | 0.14 | 0.27 | 0.51 | 0.26 | 0.21 | 0.53 | 0.21 | 0.31 |
| FWSVD | 1727 | 2152 | 1511 | 0.15 | 0.31 | 0.50 | 0.26 | 0.23 | 0.56 | 0.21 | 0.32 |  |
| ASVD | 11.14 | 16.55 | 15.93 | 0.25 | 0.53 | 0.64 | 0.41 | 0.27 | 0.68 | 0.24 | 0.43 |  |
| SVD-LLM | 7.94 | 18.05 | 15.93 | 0.22 | 0.58 | 0.63 | 0.43 | 0.29 | 0.69 | 0.24 | 0.44 |  |
| Basis Sharing | 7.74 | 17.35 | 15.03 | 0.28 | 0.66 | 0.66 | 0.46 | 0.36 | 0.71 | 0.25 | 0.48 |  |
| 30% | SVD | 13103 | 17210 | 20871 | 0.13 | 0.26 | 0.51 | 0.26 | 0.21 | 0.54 | 0.22 | 0.30 |
| FWSVD | 20127 | 11058 | 7240 | 0.17 | 0.26 | 0.49 | 0.26 | 0.22 | 0.51 | 0.19 | 0.30 |  |
| ASVD | 51 | 70 | 41 | 0.18 | 0.43 | 0.53 | 0.37 | 0.25 | 0.65 | 0.21 | 0.38 |  |
| SVD-LLM | 9.56 | 29.44 | 25.11 | 0.20 | 0.48 | 0.59 | 0.40 | 0.26 | 0.65 | 0.22 | 0.40 |  |
| Basis Sharing | 9.25 | 29.12 | 22.46 | 0.27 | 0.63 | 0.63 | 0.40 | 0.30 | 0.68 | 0.24 | 0.45 |  |
| 40% | SVD | 52489 | 59977 | 47774 | 0.15 | 0.26 | 0.52 | 0.26 | 0.22 | 0.53 | 0.20 | 0.30 |
| FWSVD | 18156 | 20990 | 12847 | 0.16 | 0.26 | 0.51 | 0.26 | 0.22 | 0.53 | 0.21 | 0.30 |  |
| ASVD | 1407 | 3292 | 1109 | 0.13 | 0.28 | 0.48 | 0.26 | 0.22 | 0.55 | 0.19 | 0.30 |  |
| SVD-LLM | 13.11 | 63.75 | 49.83 | 0.19 | 0.42 | 0.58 | 0.33 | 0.25 | 0.60 | 0.21 | 0.37 |  |
| Basis Sharing | 12.39 | 55.78 | 41.28 | 0.22 | 0.52 | 0.61 | 0.35 | 0.27 | 0.62 | 0.23 | 0.40 |  |
| 50% | SVD | 131715 | 87227 | 79815 | 0.16 | 0.26 | 0.50 | 0.26 | 0.23 | 0.52 | 0.19 | 0.30 |
| FWSVD | 24391 | 28321 | 23104 | 0.12 | 0.26 | 0.50 | 0.26 | 0.23 | 0.53 | 0.20 | 0.30 |  |
| ASVD | 15358 | 47690 | 27925 | 0.12 | 0.26 | 0.51 | 0.26 | 0.22 | 0.52 | 0.19 | 0.30 |  |
| SVD-LLM | 23.97 | 150.58 | 118.57 | 0.16 | 0.33 | 0.54 | 0.29 | 0.23 | 0.56 | 0.21 | 0.33 |  |
| Basis Sharing | 19.99 | 126.35 | 88.44 | 0.18 | 0.42 | 0.57 | 0.31 | 0.23 | 0.58 | 0.22 | 0.36 |  |

We demonstrate the performance of LLaMA-7B and LLaMA2-7B on ten datasets under different compression ratios from 20% to 50%. In evaluating the LLM performance, we group two consecutive layers in the order from the first layer to the last layer to share a basis matrix, while Basis Sharing with more than two layers will be discussed later. Table 4.2 shows the results of LLaMA-7B. The first three datasets are for text generation tasks and the rest seven datasets are for reasoning tasks. For text generation tasks evaluated by perplexity (PPL), Basis Sharing consistently achieves the lowest PPL among compared with the state-of-the-art methods across all compression ratios and tasks. In reasoning tasks, Basis Sharing achieves an average accuracy at least 3% higher than the state-of-the-art methods. As the compression ratio increases, model performance consistently declines across all the methods due to the incurred larger compression errors. In short,
Basis Sharing outperforms SVD-LLM due to smaller compression errors as discussed in Section 3.

**Table 2: PPL($\downarrow$) and Zero-shot($\uparrow$) performance of LLaMA2-7B with Basis Sharing under 20% to 50% compression ratios on three language modeling datasets and seven common sense reasoning datasets. The ${\bm{S}}$ of all language modeling tasks is evaluated with WikiText-2. For reasoning tasks, the ${\bm{S}}$ of the results outside the bracket is evaluated with WikiText-2, while inside is evaluated with Alpaca.**
| Ratio | WikiText-2$\downarrow$ | PTB$\downarrow$ | C4$\downarrow$ | Openb. | ARC_e | WinoG. | HellaS. | ARC_c | PIQA | MathQA | Average$\uparrow$ |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| 0% | 5.47 | 7.29 | 7.29 | 0.31 | 0.76 | 0.69 | 0.57 | 0.43 | 0.78 | 0.28 | 0.55 |
| 20% | 7.77 | 60.00 | 15.30 | 0.27 (0.28) | 0.66 (0.70) | 0.63 (0.63) | 0.43 (0.46) | 0.33 (0.35) | 0.70 (0.74) | 0.25 (0.25) | 0.47 (0.49) |
| 30% | 9.69 | 97.40 | 23.86 | 0.26 (0.27) | 0.58 (0.65) | 0.62 (0.62) | 0.38 (0.41) | 0.27 (0.32) | 0.66 (0.70) | 0.23 (0.24) | 0.43 (0.46) |
| 40% | 13.62 | 195.95 | 43.89 | 0.19 (0.21) | 0.48 (0.57) | 0.58 (0.57) | 0.33 (0.36) | 0.22 (0.27) | 0.61 (0.66) | 0.23 (0.23) | 0.38 (0.41) |
| 50% | 21.3 | 509.30 | 98.92 | 0.15 (0.17) | 0.36 (0.47) | 0.55 (0.53) | 0.29 (0.31) | 0.20 (0.25) | 0.56 (0.60) | 0.23 (0.22) | 0.33 (0.36) |

Table 4.2 presents the basis sharing results of LLaMA2-7B. For the common reasoning tasks, ${\bm{S}}$ are evaluated with both WikiText-2 and Alpaca (Taori et al., ) to demonstrate the performance difference. The result outside the bracket is based on the evaluation of ${\bm{S}}$ with WikiText-2, while the result within the bracket is based on the evaluation of ${\bm{S}}$ from Alpaca. It can be seen that LLaMA2-7B is more sensitive to parameter compression, especially on the PTB task. When the compression ratio reaches to 50%, the PPL of LLaMA2-7B is four times of the PPL of LLaMA-7B, while the performance on the remaining tasks are still comparable.

According to Table 4.2, the input dataset from which ${\bm{S}}$ is derived plays a crucial role in determining performance on common reasoning tasks in zero-shot settings. Generally, the model where ${\bm{S}}$ is evaluated with Alpaca achieves better accuracy than the model where ${\bm{S}}$ is evaluated with WikiText-2, especially on ARC_e under 50% compression ratio. The accuracy difference can reach 11%. However, on WinoG. the difference is not obvious, the model where ${\bm{S}}$ is evaluated with WikiText-2 achieves even higher accuracy under 40% and 50% compression ratios.

#### Performance on Different LLMs

To evaluate the generalization of Basis Sharing across multiple LLMs, we evaluate its PPL on three distinct models from three LLM families: OPT-6.7B (from the OPT family), LLaMA 2-7B (from the LLaMA family), and Mistral-7B (from the Mistral family). This comparison is conducted under a 20% compression ratio using the WikiText-2 dataset without any fine-tuning. It can be seen from Table 4.2, Basis Sharing consistently achieves the lowest PPL. Especially for OPT-6.7B and Mistral-7B, Basis Sharing achieves a PPL reduction up to 25% compared with SVD-LLM.

Figure: Table 3: PPL ($\downarrow$) of three different LLMs – OPT-6.7B, LLaMA 2-7B, and Mistral-7B – under 20% compression ratio on WikiText-2.

#### Performance on LLMs with Various Scales

Basis Sharing can be applied to LLMs with large scales. To demonstrate this, we apply Basis Sharing on LLaMA with three different scales under 20% compression ratio, namely LLaMA-7B, LLaMA-13B and LLaMA-30B against the state-of-the-art methods.
The result is shown in Table 4.2. According to this table,
Basis Sharing achieves the best performance across all the scales. Since gradient needs to be computed with FWSVD, out of memory error occurs on an A100 GPU. In contrast, Basis Sharing can still be realized with an A100 GPU.

#### Performance with LoRA Fine-Tuning

Figure: Figure 5: LoRA fine-tuning results of LLaMA-7B under 20% compression ratio with different compression methods.
Refer to caption: x5.png

LoRA (Hu et al., ) is one of the most promising fine-tuning techniques to recover performance/accuracy. LoRA can also be applied to Basis Sharing to recover performance/accuracy. We used lora_r = 8, lora_alpha = 32, and learning_rate = 1e-4, and used defaults for all other hyperparameters in the Hugging Face PEFT. Each model is fine tuned with WikiText-2 training dataset for two epochs.

Figure 5 shows the result after applying LoRA on LLaMA-7B with WikiText-2. It can be seen from the figure that all compression methods achieve similar PPL under 20% compression ratio, and PPL difference increases as the compression ratio goes up. Basis Sharing achieves the lowest PPL when the compression ratio reaches 50%.

**Table 5: GPT2 20% compression ratio compared with Dynamic Tying.**
| Method | # Parm. | Time | PPL |
| --- | --- | --- | --- |
| Dynamic Tying | 264M (GPT2-XL) | 13.75h | 49.37 |
| Basis Sharing | 94M (GPT2) | 26.47s | 43.15 |

#### Comparison with Training from Scratch

Table 4.2 compares Basis Sharing with Dynamic Tying(Hay & Wolf, ), where parameter sharing is realized by training from scratch. Instead of training from scratch, Basis Sharing leverages pretrained models that have been trained on large datasets and trained with more computational resources. As a result, Basis Sharing achieves fewer parameters, faster compression, and better PPL on WikiText-2 compared to Dynamic Tying.

### 4.3 Impact of Layer Selection of Basis Sharing on LLM Performance

In section 3, we analyzed the change of Frobenius loss when two layers are grouped to share a set of basis vectors.
In this section, we will demonstrate how grouping more than two consecutive layers affects the LLM performance.

Figure: Table 6: Impact of grouping different numbers of layers on LLaMA-7B under compression ratios from 20% to 50%.

#### Impact on LLM Performance in Zero-Shot Setting

We grouped different numbers of consecutive layers to examine
the impact of the number grouped layers on the LLM performance without any fine-tuning. Table 4.3 shows the result. The number in the first column indicates the number of consecutive layers sharing a common basis matrix. For example, 4 means that every four consecutive layers share a basis matrix in the order from the first layer to the last layer.
Compared with no basis sharing in SVD-LLM (# LAYERS = 1) under 20% compression ratio, Basis Sharing achieves a similar performance. Grouping four or five layers to share a basis matrix is more reasonable when compression ratio is lower than 30%, since they have the lowest PPL. Two layers sharing a basis matrix is a good choice when the
compression ratio is larger than 30%.

#### Impact on LLM Performance with LoRA Fine-Tuning

We also examined the impact of grouping different number of layers on LLM performance after LoRA Fine-Tuning. Table 4.3
shows the result. According to this table,
the performance of LLM can be enhanced compared with that without fine-tuning.
In addition, this table also shows that after LoRA fine-tuning, grouping layers in LLaMA-7B for Basis Sharing can achieve better performance than that without basis sharing in SVD-LLM (# LAYERS = 1).
Even when the number of grouped layer is 32, the performance of Basis Sharing is still better than that without basis sharing in SVD-LLM (# LAYERS = 1).

#### Impact on LLM Peformance with Full Parameter Fine-Tuning

**Table 8: Result of full parameter fine-tuning by grouping different numbers of layers.**
| # Layers | 20% | 30% | 40% | 50% |
| --- | --- | --- | --- | --- |
| 2 | 6.57 | 7.41 | 8.29 | 9.71 |
| 4 | 6.64 | 7.39 | 8.41 | 9.91 |
| 8 | 6.63 | 7.46 | 8.54 | 10.23 |
| 16 | 6.66 | 7.66 | 9.04 | 10.48 |
| 32 | 6.67 | 7.90 | 9.24 | 10.94 |

To examine the full potential of the Basis Sharing, we also conducted the full parameter fine-tuning to examine the impact of grouping different numbers of layers on LLM performance. Due to the high computational cost, we only fine tuned the LLaMA-7B on grouping 2, 4, 8, 16, 32 layers, respectively. The differences from LoRA fine-tuning are that we use here learning_rate = 2e-6 and two A100 GPUs. The results of full parameter fine-tuning can be found in Table 4.3. It can be seen that the performance with full parameter fine-tuning is only a little bit better than the performance with LoRA fine-tuning. The reason could be that WikiText-2 is relatively a small dataset to fine-tune the large model. Directly using this dataset to fine-tune could easily lead to overfitting. Therefore, we reduce the learning_rate from 1e-4 to 2e-6.

### 4.4 Performance on Real Hardware

Basis Sharing not only reduces the memory required for storing parameters, but also enhances inference efficiency on real hardware.
To demonstrate this advantage, we compared the performance of LLaMA-7B with and without Basis Sharing on a single A100 GPU, using a batch size of 512 and a sequence length of 32 to generate
one token for each batch.
With this setting, throughput was evaluated as the total number of tokens that can be processed by the model per second.

Figure: Figure 6: Throughput of dense LLaMA-7B model and the compressed model with Basis Sharing under compression ratios from 20% to 50%.
Refer to caption: x6.png

Figure 6 shows the throughput result. It can be seen that as the compression ratio increases, the throughput of model with Basis Sharing also increases. Under 50% compression ratio, the throughput of Basis Sharing is 1.57 times of the dense model.

## 5 Conclusion

In this paper, we explore parameter sharing across different layers with SVD to achieve effective compression for LLMs. Specifically, weight matrices in different layers are decomposed and represented as a linear combination of a set of shared basis vectors and unique coefficients. The types of weight matrices and the layer selection for Basis Sharing are examined when compressing LLMs to maintain the performance. Comprehensive experiments demonstrate that
Basis Sharing outperforms state-of-the-art SVD-based compression approaches, especially under large compression ratios.

## Appendix A Appendix

### A.1 Relation between compression ratio and number of basis vectors

Consider compressing $n$ weight matrices to x% of their original sizes. Assume each matrix have $d_{1}$ rows and $d_{2}$ columns. The number of basis vectors ($k$) can be calculated as follows:

$$ $d_{1}k+kd_{2}n=d_{1}d_{2}n\times x\%\Rightarrow k=\frac{d_{1}d_{2}n\times x\%} {(d_{1}+d_{2}n)}$ $$

### A.2 Share Error Heat Map

The Frobenius loss inccured by basis sharing for ${\bm{W}}_{Q}$
, ${\bm{W}}_{V}$, ${\bm{W}}_{Up}$ and ${\bm{W}}_{Gate}$.

Figure: Figure 7: Frobenius loss incurred by basis sharing across any two layers. The number/color in a block represents the resulting Frobenius loss if a basis matrix is shared by two layers and the numbers in the diagonal direction are obtained by applying SVD to the scaled weight matrix of a layer directly. (a) Frobenius loss incurred by basis sharing across two layers for ${\bm{W}}_{Q}$ in LLaMA2-7B. (b) Frobenius loss incurred by basis sharing across two layers for ${\bm{W}}_{V}$ in LLaMA2-7B.
Refer to caption: x7.png

Figure: Figure 8: Frobenius loss incurred by basis sharing across any two layers. The number/color in a block represents the resulting Frobenius loss if a basis matrix is shared by two layers and the numbers in the diagonal direction are obtained by applying SVD to the scaled weight matrix of a layer directly. (a) Frobenius loss incurred by basis sharing across two layers for ${\bm{W}}_{Up}$ in LLaMA2-7B. (b) Frobenius loss incurred by basis sharing across two layers for ${\bm{W}}_{Gate}$ in LLaMA2-7B.
Refer to caption: x8.png

## Peer Reviews

confidence: 4
contribution: 3
initial_rating: 6
presentation: 2
questions: Please see the weakness.
soundness: 3
strengths: 1. The concept of concatenating weight matrices from multiple layers and sharing basis is interesting. It potentially increases the number of ranks to achieve a given compression rate.
2. The performance of the proposed method is better than previous methods on SVD like ASVD or SVD-LLM.
summary: The paper introduces "Basis Sharing," a method for compressing Large Language Models (LLMs) by sharing basis vectors across different layers. This approach decomposes weight matrices into shared basis vectors and unique coefficients, aiming to reduce memory requirements.
weaknesses: 1. Seems the paper only considers the two-layer sharing case, it will be stronger if it can be expanded to multi-layers. The key drawback of the previous SVD method is that to achieve a 10% compression rate, for example, it requires pruning 55% of ranks. If more layers can be shared, this challenge can be mitigated to some extent.
2. The paper does not discuss how to allocate non-uniform ranks for SVD decomposition. Non-uniform allocation of ranks has been shown promising in recent works [1]. 
3. The final structure of the model is not presented in the paper. For example, what layers and what operations have been shared in the final compressed model?
4. Compared to pure SVD methods like SVD-LLM, a sharing basis can result in more memory costs or lower throughput since the proposed method can keep a higher rank and thus more active parameters at the inference time. 

[1] Gao, Shangqian, et al. "Adaptive Rank Selections for Low-Rank Approximation of Language Models." Proceedings of the 2024 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies (Volume 1: Long Papers). 2024.

---

confidence: 4
contribution: 3
initial_rating: 5
presentation: 3
questions: Is there any insights on why different layers would share the same SVD basis?
soundness: 3
strengths: - The studies of basis sharing across different layers is interesting.

- The improvements shown in Table 1 is significant compared with previous baselines. 

- End-to-end throughput are reported to demonstrates the effectivenss of the proposed methods.
summary: This work investigates the layer sharing of SVD bases across different layers and, based on these insights, proposes a new low-rank compression method. This method demonstrates improved performance compared to previous approaches under the same compression ratios. Plenty of ablation studies and end-to-end throughput are conducted to demonstrate the effectiveness of the proposed methods.
weaknesses: - As shown in Table 1, while basis sharing can effectively enhance the performance of compressed models, some performance drop remains—such as a 0.04 decrease at 20% compression and a 0.07 decrease at 30%. Additionally, Figure 6 illustrates that only marginal throughput improvement is observed at a 20% compression ratio, which makes the proposed method less practical, as meaningful efficiency gains are accompanied by performance degradation.

- It would be good to show whether LoRA fine-tuning can recover the performance on zero-shot common-sense reasoning tasks, rather than perplexity.

- The evaluted models should contains more recent ones, like llama-3.1/3.2.

- The proposed method seems like a layer-sharing and SVD co-design methods for LLM compression. How does such method compared with direct apply layer-sharing and SVD compression, e.g., applying layer-sharing, then SVD or reversely.

---

confidence: 3
contribution: 3
initial_rating: 8
presentation: 3
questions: * Can this method be used in conjunction with other compression methods (e.g. pruning, quantization, etc.) to go one step further?
soundness: 4
strengths: * This paper analyzes the feasibility of SVD for different modules and outliers in depth, and designs a simpler and more general SVD compression method for LLM: BASIS SHARING.

* The advantages and robustness of the proposed method are fully verified on various tasks, different scales, software and hardware Settings.

* The presentation of the technical discussion is accurate and well-organized.
summary: This paper introduces “Basis Sharing,” a method for compressing large language models by sharing basis vectors of SVD across layers, each with unique coefficients.  Basis Sharing significantly reduces model size while maintaining performance. Experiments demonstrate its superiority over traditional SVD-based techniques across various tasks and settings, achieving enhanced efficiency and accuracy at high compression ratios.
weaknesses: * It looks like BASIS SHARING will also have better acceleration in hardware, which I think would be better if compared to other SVD-based methods.

* In this paper, continuous groups are designed based on the interesting insights in 3.2. However, ablation experiments on discontinuous groups are still missing. Is it possible to realize CROSS-LAYER PARAMETER SHARING of functions (such as W_O) that are not suitable for continuous groups through discontinuous groups?

---

confidence: 3
contribution: 3
initial_rating: 5
presentation: 3
questions: 1. In the experiments section, the paper provides results for different compression ratios. However, I did not see an explanation in the paper on how the specific compression ratios were determined. Could you provide further clarification? And how did the authors determine the cutoff values ​​for different layers?
2. Could the authors analyze the properties of matrices that can be shared across layers, particularly their mathematical properties, and explain why performance is improved? This result seems should be sensitive to the training data and is counterintuitive, as, in theory, not sharing should provide a higher performance ceiling compared to sharing.
3. Could the authors provide the actual number of layers that can be shared in the model and the compression gains achieved through layer sharing?
soundness: 3
strengths: 1. The proposed idea of sharing the left singular matrix between layers is insightful. This approach significantly improves the compression ratio of the model.
2. The finding that model performance can be improved through layer sharing is intriguing.
3. The experiments are comprehensive.
summary: The paper proposes a novel layer-sharing SVD compression strategy for LLMs, building upon previous SVD compression methods. The authors suggest that by sharing the left singular matrix across different layers, the model can achieve better performance. Experiments demonstrate that this method outperforms existing activation-aware SVD compression techniques.
weaknesses: 1. While the paper claims that layer sharing can improve performance, it does not explain why. The paper lacks an explanation of the properties of the weight matrices that enable this improvement, making the conclusion somewhat abrupt and counterintuitive.
2. Sharing left singular vectors may not be applicable to all matrices in the model, which suggests that this is not a general approach. The paper does not provide in-depth analysis of this phenomenon.
3. Using layer sharing implies that the truncated ranks of both layers are identical, which could limit the model's performance.

Meta-review: The paper introduces a novel method, "Basis Sharing," for compressing LLMs through cross-layer parameter sharing using singular value decomposition (SVD). This technique innovatively decomposes weight matrices into shared basis vectors and unique coefficients for each layer, enabling memory-efficient compression without significant performance degradation. Comprehensive experiments validate its efficacy, demonstrating improved performance over state-of-the-art SVD-based methods, particularly under high compression ratios. Additionally, the authors address critical concerns raised during the review process, providing expanded results, analyses, and detailed explanations of the method's underlying properties and practical applications.

Decision: Accept (Poster)