SLoPe: Double-Pruned Sparse Plus Lazy Low-Rank Adapter Pretraining of LLMs

## Abstract

Abstract We propose SLoPe , a Double-Pruned S parse Plus Lazy Lo w-rank Adapter P r e training method for LLMs that improves the accuracy of sparse LLMs while accelerating their pretraining and inference and reducing their memory footprint.
Sparse pretraining of LLMs reduces the accuracy of the model, to overcome this, prior work uses dense models during fine-tuning. SLoPe improves the accuracy of sparsely pretrained models by adding low-rank adapters in the final 1% iterations of pretraining without adding significant overheads to the model pretraining and inference. In addition, SLoPe uses a double-pruned backward pass formulation that prunes the transposed weight matrix using N:M sparsity structures to enable an accelerated sparse backward pass. SLoPe accelerates the training and inference of models with billions of parameters up to 1.14 × 1.14\times 1.14 × and 1.34 × 1.34\times 1.34 × respectively (OPT-33B and OPT-66B) while reducing their memory usage by up to 0.77 × 0.77\times 0.77 × and 0.51 × 0.51\times 0.51 × for training and inference respectively. 1 1 1 Code and data for SLoPe is available at: https://bit.ly/slope-llm

### 1 Introduction

Large Language Models (LLMs) demonstrate significant potential for natural language understanding and generation;
however, they are expensive to train and execute because of their extensive parameter count and the substantial volume of training data required. The training process of LLMs include a pretraining [] and a fine-tuning stage. In the pretraining phase, the model is trained on a large high-quality text [, ] and then fine-tuned on different downstream tasks [, ]. Both phases require significant amounts of computation, memory, and communication.

Model sparsity, in which the less important parts of the model are pruned, can reduce the computation and memory overheads of LLM pretraining []. Sparsity is unstructured if elements are removed from arbitrary locations in the tensors. Unstructured sparsity is hard to accelerate due to non-existing hardware/software support []. To resolve this, structured sparsity imposes constraints on where the zero elements can appear [, ], creating dense blocks of nonzeros in the matrix to leverage dense compute routines.
The drawback of the structured sparse methods is that they limit the choice for sparsity patterns leading to a reduction in accuracy in the sparse model when compared to dense [].
NVIDIA has recently introduced sparse tensor cores [] to their hardware that accelerate more flexible structured sparsity patterns, i.e. 2:4 sparsity; hardware support for N:M sparsity where at most N out of M consecutive elements are zero is not yet available but machine learning practitioners are developing algorithms for these patterns [, , ] .

Applying N:M sparse masks to a model leads to accuracy loss because of their limited choice of sparsity patterns.
Changing the sparsity mask dynamically throughout pretraining is one of the approaches proposed to address this issue [].
Zhou et al. [] proposes a novel metric for finding the N:M sparsity patterns that lead to higher accuracy in each iteration. [] suggest the use of decaying masks to further improve the accuracy of the models. STEP [] proposes a new optimizer that improves the convergence of models with adaptive masks. While the adaptive methods can improve the accuracy of the models, they require storing the dense weights and possibly additional metrics for updating the new sparsity patterns, while wasting a portion of the training computations to train the weights that will be pruned in later iterations. SPDF [] and Sparse-Dense Pretraining (SD-P) [], one can compensate for the loss imposed by sparsity with a dense fine-tuning. But the dense fine-tuning stage will disable the memory and compute savings of sparse methods at inference.
Inspired by this, we introduce additional non-zeros to the weight in the last steps of pretraining. To avoid storing a dense model during inference while getting the same capabilities of a dense weight, we add the non-zeros in the form of low-rank adapters []. Our experiments show that using low rank adaptors leads to noticeably faster convergence compared to when the same number of learnable parameters are added to the sparse weights.

The use of N:M sparsity in LLM pretraining is limited to accelerating the forward pass in the training loop because the row-wise N:M structure in the weight sparsity pattern will be lost when the weights are transposed in the backward pass.
Prior work [, , ] attempt to leverage sparsity in both forward and backward passes by finding transposable masks through various methods: greedy search algorithms, searching among random permutations, and searching among the results of convolution.
However, these transposable masks reduce model accuracy and add significant runtime overheads [], often resulting to slow-downs (up to $\texttt{8.4}\times$).
To address these issues, we propose a double-pruned backward pass formulation with theoretical convergence guarantees.
Instead of enforcing the weight transpose to be N:M sparse, our approach transposes the N:M weight matrix first and then imposes N:M sparsity.
This allows the weight matrices to exhibit a wider range of sparsity patterns, leading to improved accuracy.

Our method, SLoPe, is a Double-Pruned Sparse Plus Lazy Low-rank Adapter Pretraining method for LLMs. It employs a *static* N:M sparsity mask with a double-pruned backward pass formulation to accelerate both the forward and backward passes. Key contributions of SLoPe are:

- •
Double-Pruned backward pass $\rightarrow$ We propose to transpose an already sparsifiedd N:M weight matrix (forward pass) before imposing another round of N:M sparsity (backward pass), improving model quality and reducing mask search overheads.
- •
Lazy Low-Rank adapters $\rightarrow$ We introduce additional parameters with minimal compute and memory overheads, merely for the last 1% iterations of pretraining, improving model capacity (see Figure 1).
- •
Optimized CUDA kernels $\rightarrow$ We jointly optimize Nvidia 2:4 sparse kernels and low-rank calls through efficient tiling and scheduling. Our highly-optimized CUDA kernels result to $\texttt{1.14}\times$ end-to-end training speedup and $\texttt{1.34}\times$ inference speedup on LLMs with billions of parameters, while reducing training and inference memory footprint by up to $\texttt{0.77}\times$ and $\texttt{0.51}\times$, respectively.

Figure: Figure 1: The sparse training pipeline in SLoPe. Here, $\mathcal{X}$, $\mathcal{Y}$, and $\mathcal{W}$ denote the input, output, and the weight tensors for a specific layer, respectively. $\nabla_{\cdot}\mathcal{L}$ represents the gradient of the loss function. $\mathcal{L}$ and $\mathcal{R}$ are the low-rank terms that are introduced only in the final 1% iterations. Superscript $R$ shows row-wise pruning using $N$:$M$ scheme and $R,C$ shows both column and row-wise $N$:$M$ sparsification, leading to extra imposed zeros. Blue elements represent non-zero values, while white elements represent pruned values, and red elements indicate additional zeros introduced during the backward pass.
Refer to caption: x1.png

### 2 Sparse plus low-rank pretraining of LLMs

Equation 1, 2, and 3 depict the formulas for the forward and backward pass of the $i$-th linear layer in a neural network. Here, the weight tensor is denoted as $\mathcal{W}_{i}\in\mathbb{R}^{d_{out}\times d_{in}}$ and the input tensor is denoted as $\mathcal{X}_{i}\in\mathbb{R}^{b\times d_{in}}$. The forward pass generates an output tensor represented as $\mathcal{Y}_{i}\in\mathbb{R}^{b\times d_{out}}$. In all equations, $d_{in}$ and $d_{out}$ refer to the input and output dimensions of the respective layer.

$$ $\mathrm{FWD}\mathrel{\ooalign{$\rightarrow$\cr\kern-0.6458pt\raise 1.18399pt \hbox{\scalebox{1.0}[0.522]{$\mid$}}\cr}}\mathcal{Y}_{i}=\mathcal{X}_{i} \mathcal{W}_{i}^{T}$ (1) $$

$$ $\mathrm{BWD-1}\mathrel{\ooalign{$\rightarrow$\cr\kern-0.6458pt\raise 1.18399pt \hbox{\scalebox{1.0}[0.522]{$\mid$}}\cr}}\nabla_{W_{i}}\mathcal{L}=\nabla_{Y_{ i}}\mathcal{L}^{T}\mathcal{X}_{i}$ (2) $$

$$ $\mathrm{BWD-2}\mathrel{\ooalign{$\rightarrow$\cr\kern-0.6458pt\raise 1.18399pt \hbox{\scalebox{1.0}[0.522]{$\mid$}}\cr}}\nabla_{X_{i}}\mathcal{L}=\nabla_{Y_{ i}}\mathcal{L}\mathcal{W}_{i}$ (3) $$

The dimension along which N:M pruning occurs corresponds to the reduction dimension in Matrix-Matrix multiplication. Without this restriction, the sparse Matrix-Matrix operation can not be accelerated on GPU [].
With this restriction in mind, to leverage weight sparsity in forward and backward pass, one needs to prune elements along the columns of $\mathcal{W}_{i}^{T}$ in Equation 1 (FWD) and $\mathcal{W}_{i}$ in Equation 3.
To satisfy this requirement, it is necessary to prune elements of the weight tensor $\mathcal{W}_{i}$ along both row and column dimensions.

#### 2.1 Double-pruned backward pass

Various approaches can be used to exploit N:M sparsity during both the forward and backward passes. For example, one may prune the activation tensor $\mathcal{X}_{i}$
in FWD along the row dimension and $\mathcal{W}_{i}$ in BWD-2 along the column dimension.
Although diverse combinations exist for pruning, our focus in this study is primarily on the sparsification of weight tensors for two reasons: (a) the sparsification of weight tensors directly impact the resource required for model storage and serving, and (b) our initial findings indicate that pruning weight tensors during both forward and backward passes has a comparatively lesser adverse impact on the overall end-to-end model quality. More details on our experiments can be found in J.
As such, we posit a double-pruned backward pass formulation that can productively accelerate FWD and BWD-2 computations.

In addition, we prove that such materialization of pruned weight tensors, despite being lossy(^2^22We term this formulation “lossy” because the weight matrix undergoes information loss during the backward pass compare to its state in the forward pass.), exhibits convergence properties.
For the rest of this paper, we represent the weight tensor subjected to row-wise pruning as $\mathcal{W}_{i}^{R}$, while the concurrent row-wise and column-wise pruning (double-pruned) is presented as $\mathcal{W}_{i}^{R,C}$.
We rewrite the training equations to accommodate these modifications, with proposed changes highlighted in blue:

$$ $\mathrm{FWD}\mathrel{\ooalign{$\rightarrow$\cr\kern-0.6458pt\raise 1.18399pt \hbox{\scalebox{1.0}[0.522]{$\mid$}}\cr}}\mathcal{Y}_{i}=\mathcal{X}_{i}{ \color[rgb]{0,0,1}{{{\mathcal{W}_{i}^{R}}}^{T}}}$ (4) $$

$$ $\mathrm{BWD-1}\mathrel{\ooalign{$\rightarrow$\cr\kern-0.6458pt\raise 1.18399pt \hbox{\scalebox{1.0}[0.522]{$\mid$}}\cr}}\nabla_{W_{i}}\mathcal{L}=\nabla_{Y_{ i}}\mathcal{L}^{T}\mathcal{X}_{i}$ (5) $$

$$ $\mathrm{BWD-2}\mathrel{\ooalign{$\rightarrow$\cr\kern-0.6458pt\raise 1.18399pt \hbox{\scalebox{1.0}[0.522]{$\mid$}}\cr}}\nabla_{X_{i}}\mathcal{L}=\nabla_{Y_{ i}}\mathcal{L}{\color[rgb]{0,0,1}{{\mathcal{W}_{i}^{R,C}}}}$ (6) $$

Using this formulation for training, we can accelerate both forward and backward passes owing to the existence of N:M sparsity along both dimensions of weight tensors.

Memory footprint analysis.
Inducing N:M structured sparsity not only improves computational efficiency of GEMM operations but also reduces the memory footprint for storing sparse tensors.
It is noteworthy, however, that the storage of auxiliary meta-data becomes necessary, containing information about the locations of non-zero elements in a supporting matrix.
Equation 7 delineates the requisite number of bits for storing the indices in the N:M sparsity format, where $\lceil.\rceil$ denoting the ceiling function. We present the detailed results on the memory footprint reduction in section 3.

$$ $n^{N:M}_{index}=\left\lceil{log\left({\binom{M}{N}}\right)}\right\rceil$ (7) $$

Convergence analysis.
2.1 (proof in  subsection O.1) shows the additional sparsity resulting from double pruning to an initially row-wise N:M pruned matrix.
Following this lemma, we quantify the increased sparsity induced by double pruning with 1:2, 2:4, and 2:8 sparsity patterns as $12.5\%$, $9.375\%$, and $3.39\%$, respectively.
This observation underscores that as the value of M in N:M increases, the surplus of zero elements in a double-pruned matrix diminishes.
This reduction in zero elements consequently implies a decrease in computational errors, enhancing the robustness of the computations.
We expound further insights into this phenomenon in Appendix I.

###### Lemma 2.1 .

Consider a randomly initialized matrix $A$. Following our notations, we denote the row-wise pruned version of $A$ by $A^{R}$ and the joint column- and row-wise pruned version of $A$ by $A^{R,C}$. We use $D(.)$ to present the density ratio of a matrix. Equation 8 shows the additional zero elements in matrix $A$ that are introduced by double-pruning, where $s=\frac{N}{M}$.

$$ $D(A^{R})-D(A^{R,C})=\sum_{j=N+1}^{M}{\binom{M}{j}}s^{j}(1-s)^{M-j}\frac{j-N}{M}$ (8) $$

Theorem 2.2 states that the dynamic alteration of the column-wise mask in Equation 5 during each training iteration does not exert a detrimental impact on the convergence of the optimizer.
This phenomenon can be attributed to the equivalence between the left-hand side of Equation 9, which corresponds to Equation 3 [BWD-2], and the averaging effect achieved through multiple training iterations of backpropagation with distinct sparsity mask.
However, for arbitrary values of N and M, 4 and 5 can be used in the training with convergence guarantee (proof in  subsection O.1).

###### Theorem 2.2 .

Assuming a loss function $\mathcal{L(W_{i},X_{i}})$ for a random sample $X_{i}$, and considering a random mask $M_{i}$, Equation 9 holds, where $E[.]$ is the expectation operator and $\odot$ is the element-wise multiplication.

$$ $E_{X_{i}}[\nabla_{X_{i}}\mathcal{L}(W_{i},X_{i})]=\frac{M}{N}E_{M_{i}}[E_{X_{i }}[\nabla_{Y_{i}}\mathcal{L}(W_{i},X_{i})(M\odot W_{i})]]$ (9) $$

###### Lemma 2.1 .

###### Theorem 2.2 .

#### 2.2 Lazy low-rank adapters

Pruning weight tensors in FWD and BWD-2 computations is desirable for computational efficiency but may have detrimental impact on quality.
To mitigate this adverse impact on model quality, we augment the doubly-pruned weight matrix with a low-rank matrix.
The decomposition of the doubly-pruned weight matrix, combined with the low-rank matrix, maintains the computational efficiency of spare Matrix-Matrix multiplication during forward and backward passes.
Simultaneously, this approach holds promise in alleviating the adverse effects of double pruning on overall model quality.

Considering the dense weight matrix, denoted by $W_{dense}\in\mathbb{R}^{d_{out}\times d_{in}}$, Equation 10 illustrates the proposed matrix decomposition.
In this expression, $W_{sparse}\in\mathbb{R}^{d_{out}\times d_{in}}$ signifies a doubly-pruned matrix and $L\in\mathbb{R}^{d_{out}\times r}$ and $R\in\mathbb{R}^{r\times d_{in}}$ are components of the low-rank approximation.
The variable $r$ denotes the rank of this low-rank approximation.
$r$ functions as a hyperparameter that controls the trade-offs between memory footprint, computational efficiency, and model quality.

$$ $\mathcal{W}_{dense}=\mathcal{W}_{sparse}+\mathcal{L}\mathcal{R}$ (10) $$

The matrix decomposition of doubly-pruned matrix combined with a low-rank matrix approximation reduces the memory footprint of $\mathcal{W}$ from $d_{in}d_{out}$ to $d_{in}d_{out}\frac{N}{M}+(d_{in}+d_{out})r$, where $r<<min(d_{in},d_{out})$.
The computational complexity of dense Matrix-Matrix multiplication, however, changes from $bd_{in}d_{out}$ to $bd_{in}d_{out}\frac{N}{M}+b(d_{in}+d_{out})r$.
Given the substantially smaller value of $r$ in comparison to $b$, $d_{in}$, and $d_{out}$, our formulation effectively reduces both memory footprint and computational complexity of Matrix-Matrix multiplication by a factor of $\frac{M}{N}\times$.

We empirically show that the convergence rate of low-rank adapters surpasses that of sparse weights. We attribute this behavior to the notably lower parameter counts inherent in low-rank adapters.
Leveraging this observation, we incorporate low-rank adapters exclusively during the final 1% of the training iterations.
This confined usages of low-rank adapters results in additional reduction of training cost, specifically in terms of total number of operations.
We term the proposed usage of low-rank adapters in the final steps of the training as lazy low-rank adapters.

#### 2.3 Sparse kernels

cuSPARSELt is a CUDA library designed explicitly for sparse Matrix-Matrix multiplication, where one operand undergoes pruning with the 2:4 sparsity pattern.
However, this library does not offer APIs for other algebraic routines such as addition and assignment for sparse tensors.
We now delve into the details of different kernels for training and overview our implementation methodology.

Algorithm 1 shows the training process of a single linear layer taken from an attention-based model.
We assume the use of weight decay in the optimizers, and subsequently design the requisite sparse APIs to facilitate the optimizer operations.
The training starts with matrix initialization (line 2) and setting up sparse formats to store weight tensors and their corresponding transpose (line 3 and 4).
Then, for every mini-batch in the training set, we compute the forward pass following Equation 4 (line 8).
As part of the backward pass, the derivative of the loss function with respect to the output activation is computed (line 10). Subsequently, the gradients of the loss function with respect to the weight tensor (line 11) and the input activation (line 12) are computed using Equation 2 and Equation 5, respectively.
In order to circumvent the necessity of updating weights with zero values and mitigate the associated memory footprint overhead, we employ a strategy wherein we mask the gradients for pruned weights.
The computed values are stored in a sparse format (line 13).
Next, in order to implement weight decay in the optimizer and mitigate the impact of gradient scaling, we compute the value of $\frac{1}{\gamma}\nabla_{W}\mathcal{L}+\alpha W$ (line 15). Here, $\alpha$ is the weight decay applied in the optimizer, while $\gamma$ denotes the gradient scaling factor for numerical stability during the half-precision backward pass.
The updated values for the weight tensor are calculated according to the optimizer update rule (line 16).
Finally, the value of weight tensor and its transpose are updated directly in a sparse format (line 17 and line 18).
More details about the implementation of the custom kernels used in Algorithm 1 can be found in Appendix K.

Figure: Algorithm 1 Accelerated Sparse Pretraining Algorithm for a Linear Layer

#### 2.4 SLoPe runtime optimization

While SLoPe improves the training and inference of LLMs by introducing sparse weights and low-rank adapters, a naïve implementation can hinder its full performance improvement.
Specifically, cuSPARSELt [] SpMM kernels exhibit sensitivity to input and weight tensor shapes, and introducing low-rank adapters at inference increases can increase the number of calls during the forward pass of each linear layer.
This section covers our approach to optimize SLoPe’s implementation and further improve model performance.

Efficient tiling of upsample tensors.
Figure 3-(a) showcases the speedup achieved by the cuSPARSELt backend across a range of tensor shapes commonly used in LLMs.
While the speedup of SpMM in downsample tensors increases gradually as their sizes increase, the speedup of upsample tensor drops off at around hidden dimension = 4000.
To overcome this limitation, we tile the upsample tensor into multiple smaller matrices of equal size, each of which benefits from improved speedup when multiplied by the input using 2:4 sparsity. By tuning the size of the tiles, we figured that the best performance can be achieved by using square tiles.
The results of these multiplications are then concatenated. This optimization, as detailed in Appendix E, leads to a 12% improvement in inference speed and a 4% increase in training speed with SLoPe.

Efficient kernel for combined SpMM+low-rank adapters.
A straightforward implementation of low-rank adapters requires four kernel calls: one for sparse matrix multiplication, two for low-rank computations, and one for adding the results.
In addition, our experiments demonstrate that multiplying matrices with low-rank adapters does not scale proportionally with the adapter’s rank, leading to significant overheads due to their low arithmetic intensity (see Appendix C).
To address this, we introduce two optimizations: (1) concatenating the downsample tensor to the sparse weight tensor, reducing kernel calls and increasing arithmetic intensity as in Equation 11-left, and (2) leveraging a cuBLAS fused matrix multiplication and addition kernel, minimizing cache access and kernel calls as in Equation 11-right.
As demonstrated in Appendix D, these optimizations collectively contribute to a speedup improvement of up to 6% in the end-to-end inference speed.

$$ $[Y_{1}|Y_{2}]=X[W^{T}|L];\hskip 40.0ptY=Y_{2}R+Y_{1}$ (11) $$

### 3 Experimental results

This section evaluates the efficacy of SLoPe in accelerating the pretraining while achieving memory savings.
Due to the substantial computational resources required for LLM pretraining, our accuracy evaluation is primarily focused on smaller-scale LLMs up to 774M parameters.
However, the speedup and memory reduction results extend to a wider range of models, from 2.6B up to 66B parameters.

#### 3.1 End-to-end speedup and memory saving: pretraining and inference

We evaluate the speedup and memory reduction by SLoPe during pretraining and inference across LLMs with different model parameter sizes.
To demonstrate the scalability and efficiency of SLoPe, we conducted extensive benchmarking on OPT models (2.6 B to 66 B). In each of the speedup experiments, we have run the code for 1000 iterations, and reported the median to reduce the effect of outliers. We have run each memory reduction experiment five times and reported the median.(^3^33Since benchmarking speedup and memory savings require fewer resources than complete pretraining accuracy experiments, we use the class of OPT models that offers different model parameter sizes.)

We compared our method against dense pretraining and inference directly in PyTorch, which uses efficient cuBLAS backend. As the sparse pretraining benchmark, we compare our work against Sparse-Dense Pretraining (SD-P) [], the state-of-the-art 2:4 pretraining method and the only semi-structured sparse pretraining work that provides end-to-end speedups.
Note that methods targeting LLM pretraining with N:M sparsity often suffer from inefficiency due to mask search overheads and/or compression setup.
Appendix H and Appendix B detail the profiling in Bi-Mask [] and SD-P [], which similarly use N:M sparsity on both forward and backward passes.

Notably, our approach, SLoPe, diverges significantly from recent work Sparse-Dense Pretraining (SD-P) [] in two key aspects. Firstly, we comprehensively prune all weights in the model, encompassing both MLP-Mixer and Self-Attention modules, whereas SD-P only prunes weights in the MLP-Mixer modules. Secondly, SD-P employs dynamic transposable weights, which introduce additional computation and memory overhead during training. Finally, SD-P  necessitates dense fine-tuning, thereby negating their speedup advantages during inference. In contrast, our approach achieves efficient and accurate large language models during both training and inference without such limitations.

SLoPe speedup for pretraining and inference.
Table 1 summarizes the speedups achieved by our method during both training and inference.
Since over 99% of training occurs without low-rank adapters, the training speedup is largely independent of the adapter rank.
Conversely, inference speedup is directly influenced by the adapter rank.
Given the varying hidden dimensions across different model sizes, we report the inference speedup for various adapter rank ratios: $\frac{adapter-rank}{hidden-dimension}$.

**Table 1: Comparative analysis of end-to-end pretraining and inference speedup ($\times$) comparison between SLoPe and the latest work (SD-P) on accelerating pretraining with 2:4 sparsity (ICML 2024) []. Note that the lack of inference speedup in SD-P is because of the final dense pretraining during the final iterations, resulting in a dense model for inference.**
| Model | Method | Training | Inference |  |  |
| --- | --- | --- | --- | --- | --- |
| No Adapter ($r$ = 0) | No Adapter ($r$ = 0) | 1.56% Adapter | 6.25% Adapter |  |  |
| OPT-66B | SLoPe | 1.13 | 1.34 | 1.31 | 1.30 |
| SD-P | 1.07 | 1.00 | 1.00 | 1.00 |  |
| OPT-30B | SLoPe | 1.14 | 1.32 | 1.28 | 1.27 |
| SD-P | 1.05 | 1.00 | 1.00 | 1.00 |  |
| OPT-13B | SLoPe | 1.12 | 1.30 | 1.30 | 1.12 |
| SD-P | 1.08 | 1.00 | 1.00 | 1.00 |  |
| OPT-6.6B | SLoPe | 1.08 | 1.21 | 1.13 | 1.12 |
| SD-P | 1.08 | 1.00 | 1.00 | 1.00 |  |
| OPT-2.6B | SLoPe | 1.03 | 1.07 | 1.05 | 1.00 |
| SD-P | 1.05 | 1.00 | 1.00 | 1.00 |  |

**Table 2: Comparative analysis of end-to-end memory reductions ($\times$) during training and inference between SLoPe and the latest work (SD-P) on accelerating pretraining with 2:4 sparsity (ICML 2024) []. Values greater than $1.00\times$ show memory overhead.**
| Model | Method | Training | Inference |  |  |
| --- | --- | --- | --- | --- | --- |
| No Adapter ($r$ = 0) | No Adapter ($r$ = 0) | 1.56% Adapter | 6.25% Adapter |  |  |
| OPT-66B | SLoPe | 0.77 | 0.63 | 0.65 | 0.70 |
| SD-P | 1.27 | 1.00 | 1.00 | 1.00 |  |
| OPT-30B | SLoPe | 0.77 | 0.61 | 0.63 | 0.69 |
| SD-P | 1.25 | 1.00 | 1.00 | 1.00 |  |
| OPT-13B | SLoPe | 0.78 | 0.51 | 0.62 | 0.68 |
| SD-P | 1.25 | 1.00 | 1.00 | 1.00 |  |
| OPT-6.6B | SLoPe | 0.77 | 0.60 | 0.62 | 0.68 |
| SD-P | 1.28 | 1.00 | 1.00 | 1.00 |  |
| OPT-2.6B | SLoPe | 0.77 | 0.62 | 0.64 | 0.70 |
| SD-P | 1.27 | 1.00 | 1.00 | 1.00 |  |

Figure 3-(a) illustrates that cuSPARSELt achieves higher speedups for large matrices until it reaches its maximum performance capacity ($2\times$).
A similar trend is observed in the pretraining and inference speedups of the models.
For small matrices used in low-rank adapters, the lower arithmetic intensity of low-rank adapter multiplication results in higher overhead relative to sparse multiplication.
This is because low arithmetic intensity limits the full utilization of GPU resources, leading to inefficiencies.

SLoPe memory reduction in pretraining and inference.
During pretraining, the size of the gradients and optimizer states is halved (2:4 sparsity), although there is still an overhead for storing the binary masks.
For weight matrices (See Equation 7), the indexing overhead is $n^{2:4}_{index}=3$.
Consequently, for every 4 half-precision floating-point dense numbers (total 64 bits), we store 2 half-precision floating-point non-zero values (total 32 bits) with 3-bit indexing metadata.
This results in an overall memory reduction of 1.83$\times$.
Assuming the optimizer requires two metadata matrices (similar to ADAMW []) and disregarding other parameters and overheads, the expected pretraining and inference memory reductions are roughly 1.37$\times$ and 1.83$\times$, respectively.

Table 2 presents the memory reduction for different low-rank adapter ranks and OPT model variants.
The memory reduction is slightly less than the theoretical expectation, primarily because of additional memory usage from other model components, such as layer norms, and dense model parameters.

#### 3.2 Pretraining accuracy results

To assess the impact of SLoPe on model accuracy, we conducted pretraining experiments across various models and datasets (details in Appendix N).
In all experiments, the classifications heads and the first linear layer following the input are dense.

GPT2 (Small/Large). We pretrained both the small (117 M parameters) and large (774 M parameters) variants of GPT2 [] on the OpenWebText dataset [].
For a fair comparison, we evaluate the validation perplexity following the same experimental settings described in FlashAttention [, ].
We compare SLoPe against two state-of-the-art sparse pretraining methods, including (a) WANDA [] $\rightarrow$ a one-shot pruning technique, (b) SR-STE [] $\rightarrow$ a dynamic mask pretraining method for N:M sparsity, which serves as the foundation of follow-up work [, , ].

Figure: Figure 2: Validation perplexity of GPT2-Small and GPT2-Large on OpenWebText.
Refer to caption: x2.png

Figure 2 compares the validation perplexity of GPT2-Small and GPT2-Large across a range of sparse pretraining methods.
While a gap in perplexity consistently exists between sparse and dense models, SLoPe achieves a lower perplexity compared to WANDA [] and SR-STE [].
This improved accuracy stems from SLoPe’s efficient allocation of the training budget.
Specifically, SR-STE, with its dynamic pruning masks, expends a significant portion of its training budget (e.g. gradient updates) updating weights that may be ultimately pruned and not used at inference, leading to wasted resources. Appendix A provides further details and supporting evidence for this observation.

BERT-Large-Uncased.
We pretrain BERT-Large-Uncased [] (355 M parameters) and fine-tune it for various question-answering and text classification tasks, following a similar approach to [, , ] for both pretraining and fine-tuning. Appendix G provides details on the pretraining and fine-tuning process.
We evaluate the performance of BERT-Large-Uncased on the SQuAD v1.1 [] and GLUE [] tasks. We report the average metric score for GLUE and present the task-specific metrics in Appendix L.

Effects of low-rank adapters.
To understand the impact of low-rank adapters on pretraining performance, we conducted ablations using low-rank adapter ranks of 4, 16, and 64 for 1% of the total number of iterations.
These ranks represent up to 6.25% of the model’s hidden dimension.
Table 3 shows the results of these settings on SQuAD and GLUE downstream tasks. We present per-task metrics for GLUE in Appendix L.
As expected, adding low-rank adapters improve the model’s final accuracy across all tasks.
Additionally, higher ranks improve the model’s performance at the cost of increased computational requirements.
It is also worth to note that incorporating low-rank adapters only in the final iterations (1% of total iterations) is sufficient to recover pretraining accuracy.

Convergence rate of low-rank adapters.
We hypothesized that low-rank adapters would converge faster due to their significantly fewer learnable parameters. To test this, we introduced low-rank adapters in the second phase of BERT-Large-Uncased pretraining and monitored their convergence rate. Figure 3 shows the cosine similarity of the adapters, with the downsample adapter converging rapidly within 100 iterations and the upsample adapter converging slightly slower. Despite this, limiting training to 100 iterations still yields comparable results on downstream tasks.

**Table 3: SQuADv1.1 and GLUE results on BERT-Large-Uncased with different adapter ranks. $r$ denotes the ratio of the low-rank adapter to the hidden dimension (1024).**
| Dataset | Dense | $r=0$ | $r=0.39\%$ | $r=1.56\%$ | $r=6.25\%$ |
| --- | --- | --- | --- | --- | --- |
| SQuAD | 90.44 | 89.1 | 89.1 | 89.2 | 89.5 |
| GLUE | 80.22 | 77.4 | 77.7 | 77.8 | 78.2 |

Figure: Figure 3: (a) The speedup achieved using cuSPARSELt backend in PyTorch for Attention ($d_{out}=d_{in}$), Upsample ($d_{out}=4d_{in}$) and Downsample ($d_{out}=\frac{d_{in}}{4}$) matrices with a batch size of 2048. (b) The cosine similarity of the low-rank adapters and the converged adapters for different layers in the model. The cosine similarities are averaged among the 24 layers of BERT-Large-Uncased.
Refer to caption: x4.png

Effects of mixed N:M sparsity.
To study the sensitivity of different blocks to varying sparsity ratios and to assess their relative importance, we experiment across a range of configurations: (a) [2:4-2:4] $\rightarrow$ uniformly applying 2:4 sparsity across all layers (b) [2:4-2:8] $\rightarrow$ applying 2:4 sparsity pattern to the first 12 blocks and a 2:8 sparsity pattern to the last 12 blocks and (c) [2:8-2:4] $\rightarrow$ we reverse the sparsity ratios for the first and last 12 blocks.
Note that, to reduce computational costs, we use the same dense checkpoint for Phase-1 in all settings and a low-rank adapter of rank 40 for all models.
We also replicate this experiment using WANDA [] and report the comparison results.

**Table 4: SQuADv1.1 results on BERT-Large-Uncased for different sparsity settings.**
| Sparsity Pattern | SQuAD | SQuAD | GLUE | GLUE |
| --- | --- | --- | --- | --- |
| (First 12 blocks - Last 12 blocks) | SLoPe | WANDA | SLoPe | WANDA |
| 2:4-2:4 | 90.17 | 89.93 | 79.08 | 78.84 |
| 2:4-2:8 | 89.85 | 89.55 | 79.03 | 77.24 |
| 2:8-2:4 | 89.67 | 86.57 | 75.92 | 69.08 |

Table 4 summarizes the GLUE and SQuAD results for these settings.
As the results show, increasing the sparsity ratio reduces the accuracy of the model on all tasks.
But when the first 12 blocks of the model are pruned, the accuracy drop is significantly higher, especially on the GLUE dataset.
We conclude that the first blocks of the model are more sensitive to sparsity during pretraining, but one can sparsify the last blocks of LLMs more aggressively.
We observe a similar pattern in WANDA results as well, but WANDA performs consistently worse than SLoPe in these cases.

Effects of sparsification on different modules.
Each block in LLMs consists of a self-attention module and an MLP mixer module, each containing multiple linear layers. We have analyzed the sensitivity of SLoPe to pruning each of those modules. Our results in Appendix F demonstrate that SLoPe can sustain competitive quality results while pruning all modules in the model.

### 4 Conclusion

In conclusion, SLoPe improves both pretraining and inference times while reducing memory footprint with negligible impact on model performance.
SLoPe achieves these benefits by effectively using N:M sparsity and lazy low-rank adapters in both forward and backward passes, supported by an efficient design of CUDA kernels.
Additionally, the use of lazy low-rank adapters allows for balancing memory footprint and model accuracy across a wide range models.
The results show that SLoPe achieve up to 1.14$\times$ and 1.34$\times$ speedup for pretraining and inference, respectively.
These speedups achieved while our method reduces the effective memory footprint by up to 0.77$\times$ (pretraining) and 0.51$\times$ (inference).

### Acknowledgments and Disclosure of Funding

This work was also supported in part by NSERC Discovery Grants (RGPIN-06516, DGECR00303), the Canada Research Chairs program, Ontario Early Researcher award, the Canada Research Chairs program, the Ontario Early Researcher Award, and the Digital Research Alliance of Canada
([www.alliancecan.ca](www.alliancecan.ca)). Work of Zhao Zhang was supported by National Science Foundation OAC-2401246. We also acknowledge the Texas Advanced Computing Center (TACC) at The University of Texas at Austin for providing HPC resources that have contributed to the research results reported within this paper ([http://www.tacc.utexas.edu](http://www.tacc.utexas.edu)). We extend our gratitude towards David Fleet, Karolina Dziugaite, Suvinay Subramanian, Cliff Young, and Faraz Shahsavan for reviewing the paper and providing insightful feedback. We also thank the extended team
at Google DeepMind who enabled and supported this research direction.

## Appendix

### Appendix A Comparison with Dynamic Sparsity: SR-STE

We pretrained GPT2-Small (Section 3.2) using the SR-STE method [] and reported the perplexity results in Figure 2.
SR-STE aims to mitigate the Sparse Architecture Divergence (SAD) by dynamically adjusting the sparsity mask throughout training. We choose the hyperparameters in SR-STE, so that the update rule of the gradient follows Equation 12, where $M$ denotes the sparsity mask and $\odot$ denotes the element-wise multiplication.

$$ $\nabla_{W}\mathcal{L}\xleftarrow{}M\odot\nabla_{W}\mathcal{L}$ (12) $$

To understand the performance gap between SR-STE and SLoPe (our method) for the same training budget, we analyzed the mask dynamics in SR-STE. We plotted the average number of mask elements changes during training compared to the final converged mask sparsity pattern.
High mask change values indicate that training resources are spent on updating weights that ultimately get pruned and do not necessarily contribute to the final model accuracy.

Figure 4 shows this average mask difference per iteration relative to the converged model.
As training progresses, the mask difference decreases, demonstrating SR-STE’s convergence to a specific sparsity pattern. However, in SLoPe, where all resources are dedicated to optimizing weights under a static mask(^4^44We determine the pruning mask at the very first iteration and maintain it for the rest of training.), SR-STE’s dynamic approach leads to wasted computation (represented by the area under the curve in Figure 4). Consequently, for the same training budget, SLoPe achieves a lower perplexity in comparison to SR-STE due to its static mask approach.

Figure: Figure 4: Average mask difference between each iteration and the converged sparsity pattern in GPT2-Small pretraining using SR-STE. The highlighted area shows the ratio of the resources used for updating weights that are pruned and not used in the inference of the model.
Refer to caption: x6.png

### Appendix B cuSPARSELt Initialization Overhead: Static vs. Dynamic Sparsity

This section analyzes the time breakdown of the cuSPARSELt SpMM pipeline, highlighting the significant overheads associated with dynamically changing sparsity masks.
The cuSPARSELt SpMM operation consists of two main phases: (1) Setup and (2) Matrix Multiplication. The setup phase involves initializing matrix handles and compressing the 2:4 sparse matrix. This compression copies non-zero values into a contiguous memory layout and generates indices for those values. The matrix multiplication phase leverages this metadata to perform the sparse matrix-matrix multiplication.

Figure 5 shows the setup and multiplication time for square matrices using the cuSPARSELt SpMM backend. As evident from the figure, the setup overhead is significantly larger than the actual matrix multiplication time.
For SLoPe, which employs static sparsity masks, the setup cost is incurred only once and becomes negligible compared to the numerous matrix multiplications performed during training and inference. However, for dynamic sparsity patterns, such as Sparse-Dense Pretraining [], Bidirectional Masks [], and other similar methods[, , , ], this setup overhead can be substantial, leading to reduced speedup (as observed in Section 3.1 for Sparse-Dense Pretraining) or slowdowns in some configurations (as discussed in Appendix H).(^5^55A recent work observed a similar overhead using dynamic sparsity in cuSPARSELt SpMM pipeline [].)

Figure: Figure 5: The setup and multiplication time for square matrices using the cuSPARSELt SpMM backend.
Refer to caption: x7.png

### Appendix C Low-Rank Adapter Performance: Scaling and Arithmetic Intensity

As discussed in Section 2.4, the computation time of low-rank adapters does *not* scale linearly with their rank. This section provides experimental results to illustrate this behavior in more detail.
The computational complexity of low-rank matrix multiplications is $\mathcal{O}(brd)$, where $b$, $r$, and $d$ represent the batch size, low-rank, and input/output dimensions of the layer, respectively.
Based on this complexity, we expect the computation time to be a linear function of $r$. In other words, reducing $r$ by a factor of $\alpha$ should result in a corresponding $\alpha$-fold reduction in computation time.
However, in practice, this linearity does not hold. This deviation arises because the assumption underlying this expectation – that matrix multiplication is compute-bound – is not always true. Specifically, the arithmetic intensity of the operation can fall below the machine’s balance point, as described in the Roofline model [].
Figure 6 shows the speedup achieved for different low-rank values using PyTorch’s matrix multiplication function, which relies on the CUBLAS backend [].
The figure demonstrates that the achieved speedups are significantly lower than the ideal linear scaling, particularly when reducing the rank. Moreover, it is evident that as the matrix dimensions increase, the gap between the ideal speedup and the observed speedup diminishes. This behavior can be attributed to the increased arithmetic intensity for larger matrices, leading to better utilization of tensor cores.

Figure: Figure 6: The speedup achieved by low-rank adapters in comparison to a dense matrix-multiplication.
Refer to caption: x8.png

### Appendix D Efficient low-rank adapter implementation

As discussed in Section 2.4, a naïve implementation of low-rank adapters can lead to significant performance overheads due to the increased number of kernel launches and the low arithmetic intensity of their multiplications.
To address these issues, we introduced two key optimizations: (1) concatenating one of the low-rank adapters with the sparse weights, and (2) fusing the multiplication of the other low-rank adapter with the subsequent result addition.
These optimizations reduce kernel calls and increase arithmetic intensity, leading to more efficient utilization of GPU resources. Table 5 summarizes the speedup improvements achieved with these optimizations, demonstrating an inference speedup increase of up to 6%.

**Table 5: End-to-end speedup ($\times$) before (left) and after (right) efficient implementation of low-rank adapters.**
| Model | Inference | Inference |
| --- | --- | --- |
|  | 1.56% Adapter | 6.25% Adapter |
| OPT-66B | 1.15-1.20 | 1.12-1.19 |
| OPT-30B | 1.13-1.18 | 1.10-1.16 |
| OPT-13B | 1.11-1.10 | 1.09-1.10 |
| OPT-6.6B | 1.07-1.12 | 1.06-1.11 |
| OPT-2.6B | 1.01-1.06 | 0.97-1.00 |

### Appendix E Efficient weight tiling implementation

We observed that the dimensions and aspect ratios of matrices significantly influence system speedup (Section 2.4).
To mitigate this, we implemented a matrix tiling strategy, dividing upsample matrices into multiple square matrices.
This approach significantly improves performance, as shown in Table 6.
Our results demonstrate that matrix tiling can enhance training speed by up to 4% and inference speed by up to 12%, highlighting its effectiveness in optimizing system performance.

**Table 6: End-to-end speedup ($\times$) before (left) and after (right) splitting the upsample matrix. In both cases, the optimization discussed in 5 is used.**
| Model | Training | Inference | Inference | Inference |
| --- | --- | --- | --- | --- |
|  |  | No Adapter | 1.56% Adapter | 6.25% Adapter |
| OPT-66B | 1.10-1.13 | 1.22-1.34 | 1.20-1.31 | 1.19-1.30 |
| OPT-30B | 1.09-1.14 | 1.23-1.32 | 1.18-1.28 | 1.16-1.27 |
| OPT-13B | 1.10-1.12 | 1.23-1.30 | 1.10-1.30 | 1.10-1.12 |
| OPT-6.6B | 1.08-1.08 | 1.21-1.19 | 1.12-1.13 | 1.11-1.12 |
| OPT-2.6B | 1.03-1.02 | 1.02-1.07 | 1.06-1.05 | 1.00-1.00 |

### Appendix F SLoPe sensitivity to pruning different module in transformer

LLMs typically consist of two main modules: the MLP mixer and the self-attention.
The attention module’s weights are represented as a matrix in $\mathbb{R}^{d\times 3d}$, while the MLP mixer uses weights in $\mathbb{R}^{d\times 4d}$ and $\mathbb{R}^{4d\times d}$, where $d$ denotes the hidden dimension.
To investigate the impact of sparsity on these modules, we conducted two experiments during Phase-2 of BERT-Large-Uncased pretraining: (a) [MLP Mixer] $\rightarrow$ pruning both MLP mixer and self-attention modules.
Table 7 presents the SQuAD and GLUE results for these settings.
As expected, we observe a consistent, albeit slight, decrease in model quality as more modules are sparsified. The marginal decrease in performance suggests that models are relatively insensitive to the specific modules being pruned when using our SLoPe pretraining method. This observation underscores the robustness of our approach and its ability to maintain competitive quality across diverse sparsity configurations.

**Table 7: SQuADv1.1 results on BERT-Large-Uncased for different pruned modules.**
| Pruned Modules | SQuAD | GLUE |
| --- | --- | --- |
| Dense | 90.44 | 80.22 |
| MLP Mixer | 90.28 | 79.03 |
| MLP Mixer + Self-Attention | 89.35 | 77.72 |

### Appendix G BERT-Large-Uncased: Pretraining and Downstream Evaluation

BERT-Large-Uncased pretraining consists of two phases, as illustrated in Figure 7. Phase 1 comprises 7,038 iterations with a global batch size of 65,536 and a sequence length of 128. Phase 2 includes 1,563 iterations with a global batch size of 32,768 and a sequence length of 512.

Figure 7 shows the training loss for both phases under different sparsity settings. We observe that higher sparsity ratios generally lead to higher training loss in both phases. Interestingly, the loss/perplexity gap does not directly correlate with the observed accuracy drops in downstream tasks [, , ].

Figure: Figure 7: Training loss of BERT-Large-Uncased on WikiCorpus dataset for phase 1 and 2.
Refer to caption: x9.png

We evaluated the pretrained BERT-Large-Uncased models on the SQuAD v1.1 [] and GLUE [] benchmarks.
SQuAD v1.1, a comprehensive question-answering dataset based on Wikipedia, is widely used for LLM training. We report the F1 score for SQuAD throughout the paper.
GLUE, a diverse benchmark for natural language understanding tasks, provides a single aggregated score across various challenges, facilitating model comparisons. The paper presents the average metric score for GLUE, while task-specific metrics are detailed in Appendix L.

### Appendix H Performance overhead of bidirectional mask

Table 8 presents the runtime results of Bidirectional Masks [], a state-of-the-art N:M sparsity method.
Our analysis demonstrates that the mask search and associated overheads of this approach result in significant slowdowns compared to dense baselines. For these experiments, we utilized the repository provided in [] and employed the same models used in their evaluation.

**Table 8: End-to-end slow-down of Bi-directional Mask [] in comparison to the dense baseline.**
| Model | Dataset | Slow-down ($\times$) |
| --- | --- | --- |
| MobileNet v2 | CIFAR10 | 5.08 |
| ResNet-32 | CIFAR10 | 5.07 |
| VGG19 | CIFAR10 | 8.41 |
| ReNet-18 | ImageNet | 3.66 |
| ResNet-50 | ImageNet | 3.01 |

### Appendix I Sparsity ratio analysis of double-pruned backward pass

As described in Section 2.1, our proposed sparse pretraining approach involves pruning weights in both the forward and backward passes.
During the backward pass, we apply both row-wise and column-wise pruning, which introduces additional zero values to the column-wise pruned weight matrices used in the forward pass.
Theorem 2.1 demonstrates that the resulting sparsity ratio can be calculated using Equation 8.
Figure 8 visualizes the imposed sparsity ratios for various N:M sparsity patterns. As expected, smaller N/M ratios lead to lower imposed sparsity ratios. Moreover, in most cases, the imposed sparsity ratio is significantly smaller than the original matrix’s density ratio.

Figure: Figure 8: The imposed sparsity ratio when pruning the weight matrices in the backward pass.
Refer to caption: x11.png

### Appendix J Sensitivity to the choice of pruning matrix

In linear layers, three matrices are involved in the forward and backward passes: the input, the output gradient, and the weights. Pruning each of these matrices can have distinct effects on model performance.

To identify the optimal pruning strategy, we conducted an experiment where we pretrained GPT2-Small for 100,000 iterations (a quarter of the full pretraining) while systematically applying both static and dynamic pruning to each of the three matrices.
Static pruning involves generating a random mask at initialization and applying it throughout training. Dynamic pruning, on the other hand, prunes matrices based on their magnitude at each iteration. For dynamic pruning, the dense matrix values are computed and stored, and then pruned at every step.

Figure 9 presents the validation perplexity for these experiments. Notably, pruning the output gradient led to model divergence after a few iterations and is not shown in the figure.

Figure: Figure 9: Validation perplexity on GPT2-Small pretraining for 100,000 iterations for different matrix pruning settings. Pruning the output gradients leads to divergence within the few iterations and hence is not reported.
Refer to caption: x12.png

Analysis.
As shown in Figure 9, static pruning consistently achieved lower perplexities. This behavior suggests that focusing computational resources on elements that remain active throughout training can lead to improved performance. Furthermore, pruning weights resulted in lower perplexities compared to pruning inputs, indicating that weights are generally a better target for pruning.

Intuition.
Pruning weights is analogous to removing connections between neurons. Pruning activation tensors is similar to introducing a non-linear function (akin to max-pooling) before each linear layer. Pruning output gradients, however, lacks practical justification and introduces errors into the backward pass, leading to model divergence.

### Appendix K Implementation details

This section details the implementation of the custom functions and CUDA kernels used in Algorithm 1 to facilitate efficient sparse training.

Initialization, sparse matrix setup, and SpMM kernels.
Before utilizing the cuSPARSELt APIs, a crucial initialization phase ensures proper configuration of essential variables for our computational task.
Following initialization, we configure the sparse data formats tailored for sparse matrices. This involves initializing matrix descriptors, pruning the matrices, and compressing them into a more compact representation.
cuSPARSELt employs an automated search to determine the optimal kernel for executing SpMM.
While setting up these sparse data formats incurs a non-negligible computational cost, this overhead is mitigated by the repetitive nature of matrix multiplications during the training process.

Prune and compress.
The gradient of the loss function with respect to the weights requires pruning using the same mask as the weight matrix.
Consequently, it contains 50% extra zero values in the dense format.
To address this redundancy, we developed an optimized CUDA kernel, integrated into PyTorch, that masks the gradients accordingly, eliminating the storage of unnecessary data and reducing memory usage.
The output of this operation is a new matrix in $\mathbb{R}^{d_{out}\times\frac{d_{in}}{2}}$.

Sparse matrix addition.
The cuSPARSELt sparse data format does not natively support addition operations. However, for matrices $A$ and $B$ sharing the same sparsity patterns, we developed an optimized CUDA kernel seamlessly integrated into the PyTorch training workflow. This kernel efficiently computes linear combinations of the form $\beta A+\gamma B$, where $\beta$ and $\gamma$ are arbitrary user-defined constants. This functionality is particularly useful for adding sparse weights to gradients in optimizers that utilize weight decay.

Update Sparse Matrix.
After the optimizer updates the weight tensor values based on its rules, we need to update the sparse matrix format to reflect these changes. We implemented an optimized CUDA kernel that copies the weight tensors from the PyTorch format into the cuSPARSELt data type, enabling efficient storage and manipulation of sparse weights.

### Appendix L Task-specific GLUE results

The GLUE benchmark [] comprises eight distinct natural language understanding classification tasks. While Section 3 presented the average GLUE score as a measure of overall model performance, this section provides a more detailed analysis by presenting the complete task-specific results for each training setting in Table 9.

**Table 9: GLUE results for each task in the experiments discussed in section 3.**
|  |  |  | First | Last |  |  |  |  |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| Method | Phase | Rank | 12 | 12 | CoLA | SST-2 | MRPC | STS-B | QQP | RTE | MNLI | QNLI |
|  |  |  | Blocks | Blocks | (mcc) | (acc) | (f1) | (corr) | (f1) | (acc) | (acc) | (acc) |
| Dense | 1,2 | 0 | 2:4 | 2:4 | 51.6 | 91.9 | 81.2 | 87.5 | 87.8 | 66.4 | 84.1 | 91.3 |
| SLoPe |  |  |  |  |  |  |  |  |  |  |  |  |
| MLP Mixer | 2 | 0 | 2:4 | 2:4 | 41.8 | 91.4 | 88.7 | 87.2 | 85.9 | 65 | 82.1 | 90.1 |
| Only |  |  |  |  |  |  |  |  |  |  |  |  |
| SLoPe |  |  |  |  |  |  |  |  |  |  |  |  |
| MLP Mixer + | 2 | 0 | 2:4 | 2:4 | 38.8 | 90.4 | 85.9 | 86.4 | 85.9 | 63.5 | 81.5 | 89.3 |
| Self-Attention |  |  |  |  |  |  |  |  |  |  |  |  |
| SLoPe with |  |  |  |  |  |  |  |  |  |  |  |  |
| Non-Lazy | 2 | 40 | 2:4 | 2:4 | 43.3 | 90.8 | 89 | 87 | 86 | 64.6 | 82.3 | 89.6 |
| Adapters |  |  |  |  |  |  |  |  |  |  |  |  |
| SLoPe with |  |  |  |  |  |  |  |  |  |  |  |  |
| Non-Lazy | 2 | 40 | 2:8 | 2:4 | 29 | 89.7 | 83.7 | 85.6 | 85.2 | 66.8 | 79.9 | 87.4 |
| Adapters |  |  |  |  |  |  |  |  |  |  |  |  |
| SLoPe with |  |  |  |  |  |  |  |  |  |  |  |  |
| Non-Lazy | 2 | 40 | 2:4 | 2:8 | 44.1 | 91.1 | 89.8 | 86.6 | 86.3 | 62.5 | 82.3 | 89.6 |
| Adapters |  |  |  |  |  |  |  |  |  |  |  |  |
| SLoPe | 1,2 | 0 | 2:4 | 2:4 | 37.9 | 91.4 | 85.4 | 86.6 | 85.8 | 62.5 | 80.7 | 88.6 |
| SLoPe | 1,2 | 4 | 2:4 | 2:4 | 38.5 | 91.4 | 85.8 | 86.8 | 85.8 | 63.9 | 80.8 | 88.4 |
| SLoPe | 1,2 | 16 | 2:4 | 2:4 | 39.2 | 91.3 | 86.4 | 86.6 | 86 | 63.5 | 80.8 | 88.2 |
| SLoPe | 1,2 | 64 | 2:4 | 2:4 | 42.7 | 90.3 | 85.1 | 86.8 | 85.7 | 66.4 | 80.3 | 88.5 |
| WANDA | N/A | 0 | 2:4 | 2:4 | 43.0 | 91.4 | 88.3 | 86.9 | 86.1 | 63.5 | 81.9 | 89.6 |
| WANDA | N/A | 0 | 2:8 | 2:4 | 4.6 | 0.88 | 81.3 | 81 | 83.3 | 53.8 | 76.7 | 83.9 |
| WANDA | N/A | 0 | 2:4 | 2:8 | 42.1 | 91.7 | 84.4 | 87.2 | 85.6 | 63.5 | 81.5 | 81.9 |

### Appendix M Additional related work

Model pruning.
Pruning the models has been one of the most effective methods to reduce the complexity of LLMs []. One can pretrain the LLMs sparsely [] or the pruning can happen after a dense pretraining [, ], possibly followed by a fine-tuning stage to recover part of the lost accuracy [, ].
Pruning the models after pretraining can be costly [, ] and typically fails to maintain their accuracy [, ].
While the sparse pretraining methods improve the accuracy of the model, they either use unstructured sparsity patterns that cannot be accelerated with the current hardware [] or have significant overheads when searching for and applying their structured sparse masks [, , ].

Low-rank adapters.
Low-rank adapters have emerged as a promising method to reduce the fine-tuning costs associated with pre-trained LLMs and enable more efficient task switching [].
Different quantization and initialization schemes have been proposed to reduce their overheads in LLM fine-tuning [, ].
Adding low-rank factors to sparse matrices is a low-weight mechanism widely used to improve the accuracy of approximations of dense matrices [].
In machine learning, the sparse plus low-rank approximations are limited to attention heads [, ] and pruning after pretraining [, ], and the sparse plus low-rank pretraining has not been investigated.

### Appendix N Experiment setup, hyperparameters, compute resources

Our experiments were conducted on the Narval and Mist clusters at Compute Canada [] and the Lonestar 6 cluster at the Texas Advanced Computing Center [].
Each Narval node is equipped with four Nvidia A100 GPUs, each with 40GB of memory. Mist nodes feature four Nvidia V100 GPUs, each with 32GB of memory, while Lonestar 6 nodes have three Nvidia A100 GPUs, each with 40GB of memory.
For our accuracy experiments, we emulated 2:4 and N:M sparsity using custom-designed, low-overhead CUDA kernels to prune weights in both the forward and backward passes. We utilized a mixture of available resources across the clusters, as model accuracy is not hardware-dependent.

Our speedup and memory saving experiments were conducted on a single A100 GPU in the Narval cluster. We ran 1000 iterations of training or inference to gather the necessary statistics. For speedup experiments, we reported the median of the 1000 samples to mitigate the effects of outliers. Each memory reduction experiment was run five times, and the median value was reported.
We employed the default hyperparameters found in the NVIDIA BERT codebase [] and the FlashAttention GPT codebase [, ]. Further tuning of hyperparameters for sparse pretraining is left as a future direction. Training BERT-Large-Uncased required approximately 32 hours on 64 A100-64GB GPUs.
The pretraining of GPT2-Small/Large took 32 and 111 hours, respectively, on 64 V100-32GB GPUs.

### Appendix O Proofs

#### O.1 Lemma 2.1

Proof. Considering a matrix with $N:M$ column-wise pruned sparsity pattern, we want to prune the matrix using $N:M$ sparsity pattern row-wise as well. Let’s define random variable $X$ as the number of added non-zeros to $M$ row-wise consecutive elements and $Y$ as the number of non-zeros in $M$ row-wise consecutive elements.

$$ $E[X]=\sum_{i=1}^{M-N}Pr[X=i]i$ (13) $$

Replacing $Pr[X=i]=Pr[Y=N+i]$ in Equation 13, we will get Equation 14, where we used a change in dummy variable $j=N+i$.

$$ $E[X]=\sum_{i=1}^{M-N}Pr[Y=N+i]i=\sum_{j=N+1}^{M}Pr[Y=j](j-N)$ (14) $$

Considering the definition of $Y$, it can be inferred that random variable $Y$ has binomial distribution with a success probability of $\frac{N}{M}$. As a result Equation 15 shows the probability mass distribution of $Y$.

$$ $Pr[Y=j]={\binom{M}{j}}s^{j}(1-s)^{M-j};s\triangleq\frac{N}{M}$ (15) $$

By replacing Equation 15 in Equation 14, we will get Equation 16.

$$ $E[X]=\sum_{j=N+1}^{M}{\binom{M}{j}]}s^{j}(1-s)^{M-j}(j-N)$ (16) $$

Let’s define random variable $Z$ as the added sparsity ratio to the matrix by the extra pruning. Since $X$ was the number of added non-zeros in $M$ consecutive elements, $E[Z]=\frac{1}{M}E[X]$, and hence Equation

$$ $E[Z]=D(A^{R})-D(A^{R,C})=\sum_{j=N+1}^{M}{\binom{M}{j}}s^{j}(1-s)^{M-j}\frac{j -N}{M}$ (17) $$

#### O.2 Theorem 2.2

Proof. In an optimization problem, we are aiming to find the optimal solution to Equation 18.

$$ $\min_{W_{i}}E_{X}[\mathcal{L}(X,W_{i})]$ (18) $$

When using backpropagation, which is based on the chain rule in derivation, we compute the gradient in Equation 19.

$$ $.E_{X}[\nabla_{X_{i}}\mathcal{L}(X,W_{i})]=E_{X}[\nabla_{Y_{i}}\mathcal{L}W]$ (19) $$

Let’s define random variable $M$ as a uniformly random mask of 0’s and 1’s. The mask will be $1$ at each point with a probability of $\frac{N}{M}$. Let’s define $O\triangleq E[M]$. $O$ is a matrix of all $\frac{N}{M}$’s. As a result $O\odot W=\frac{N}{M}A$ for an arbitrary matrix $A$.

$$ $E_{X}[\nabla_{Y_{i}}\mathcal{L}W]=E_{X}[\nabla_{Y_{i}}\mathcal{L}(\frac{M}{N}O \odot W)]=E_{X}[\nabla_{Y_{i}}\mathcal{L}(\frac{M}{N}E_{M}{M}\odot W)]$ (20) $$

By using the linearity of derivation and expectation operators, we can get the result in Equation 21, which proves the theorem.

$$ $E_{X}[\nabla_{X_{i}}\mathcal{L}(X,W_{i})]=\frac{M}{N}E_{M}[E_{X}[\nabla_{Y_{i} }\mathcal{L}(M\odot W)]]$ (21) $$

## Peer Reviews

confidence: 2
contribution: 3
initial_rating: 6
presentation: 3
questions: Please see the weakness.
soundness: 3
strengths: 1. This is a technical solid article that designs optimized CUDA kernels that jointly optimize Nvidia 2:4 sparse kernels and low-rank calls through efficient tiling and scheduling.

2. SLOPE yields up to 1.25x faster training and 1.54x faster inference on models with billions of parameters, with a memory reduction of up to 63% during training.
summary: This paper introduces SLOPE, a novel pretraining method aimed at improving the efficiency of large language models (LLMs) by combining sparsity and low-rank approximations. SLOPE employs double-pruning techniques—applying N:M sparsity masks during both forward and backward passes—and introduces lazy low-rank adapters in the final training stages. The double-pruning approach reduces memory and computational overheads, while the lazy low-rank adapters help maintain model accuracy by mitigating the quality loss from sparsity.
weaknesses: 1. Structured and semi-structured sparsity with low-rank adapters, are not new concepts in the literature (e.g., see Losparse [1]).

2. This article lacks an introduction to related work and baseline methods, such as FST. Readers unfamiliar with the field may find it challenging to follow the content.

3. Could you provide results on additional zero-shot datasets in GLUE beyond MMLU, ARC-c, and OpenBookQA for GPT-2 when comparing SR-STE?


[1] Li, Yixiao, et al. "Losparse: Structured compression of large language models based on low-rank and sparse approximation." In International Conference on Machine Learning, pp. 20336-20350. PMLR, 2023.

Minor: 
1. L 430 typo of "accuracy"

2. The bold values in the Tables are misleading:

Table 1: Why are some values of FST also bolded?

Table 3: Why are the values of SR-STE not bolded on the MMLU dataset?

---

confidence: 4
contribution: 2
initial_rating: 5
presentation: 3
questions: 1-The authors show that their method is faster than FST during pre-training, which is expected since FST dynamically searches for a mask, whereas their method uses a static one, making the training column in Table 1 clear. However, the inference column of Table 1 suggests that their method is also faster than FST for inference. All sparse pre-training methods use the full model for inference. Does this imply that their method uses the sparse matrix for inference (e.g., during zero-shot evaluations)? Then what is the point of sparse pre-training? In the table caption, it’s mentioned that "the lack of inference speedup in FST is due to the final dense pre-training during the final iterations, resulting in a dense model for inference." Could the authors clarify if you have included fine-tuning on a downstream task as inference? and how are the SLOPE values in the inference columns calculated?

2-Is flash attention used for the baselines as well (line 312)?
soundness: 2
strengths: 1-The proposed double-pruned N:M sparsity for both forward and backward acceleration offers a novel perspective on N:M
sparsity, improving flexibility compared to existing transposable N:M masks.

2-The tiling and kernel fusion solution that integrates LoRAs with sparse weights for enhanced efficiency is interesting.
The authors effectively demonstrate the acceleration and memory reduction benefits of their approach across various models, outperforming FST [1].

3- The method achieves performance surpassing SR-RTE[2] and approaches that of a densely pre-trained model in tasks like MMLU, Arch Challenge, and OpenQA.

[1] Accelerating Transformer Pre-Training with 2:4 Sparsity, Hu et all, ICML 2024

[2] Learning N:M Fine-grained Structured Sparse Neural Networks from Scratch, Zhou et. all, ICLR 2021
summary: This paper introduces double-pruned sparsity, a technique that applies two rounds of N:M sparsity to the weight matrices of a neural network: one for accelerated forward pass and another on the transpose of the already N:M sparse matrix for an accelerated backward pass. The proposed method is combined with LoRA-tuning in the final 0.01 iterations of pre-training resulting in the method termed Double-Pruned Sparse Plus Lazy Low-rank Adapter Pre-training (SLoPE). The authors use efficient tiling of upsample tensors and kernel fusion to reduce overhead, resulting in further boost in training and inference speed. They show that their approach results in speedup and memory reduction of pre-training LLMs of various sizes. They also show their method improves zero-shot accuracy of GPT2-small compared to a sparse pre-training baseline.
weaknesses: 1- The most significant weakness is the limited evaluation of how the proposed sparsity impacts performance. The sparse pre-training method negatively affects performance, and the use of a static sparse matrix further limits flexibility. While the authors claim this does not hinder flexibility, more evidence across a broader range of downstream tasks is needed to support this claim. Given the inherent trade-off between speed and performance, the current experiments do not sufficiently demonstrate the method's effectiveness. Table 3 should include more tasks (tasks in FST[1]) to give the reader a clearer understanding of the impact.

2- Even in the limited downstream task evaluation, some important baselines are missing. The authors put FST in parentheses after SR-STE in the text, although these are distinct methods: FST refers to [1] while ST-RTE is [2]. Zero-shot FST results in their own setting on these tasks are not reported. Additionally, while comparing their method to a larger dense model may be unfair, it would be informative to see how a smaller dense model performs without sparse pre-training.

3- The impact of LoRA fine-tuning in the final iterations appears minimal. The benchmarks (MMLU, Arch Challenge, and OpenQA) are not reported for the LoRA ablations. Since a major contribution of this work is the tiling and kernel fusion solution designed to mitigate issues caused by adding LoRAs, it is concerning that adding LoRAs seems to have little effect, especially based on the current results.

[1] Accelerating Transformer Pre-Training with 2:4 Sparsity, Hu et. all, ICML 2024

[2] Learning N:M Fine-grained Structured Sparse Neural Networks from Scratch, Zhou et. all, ICLR 2021

---

confidence: 4
contribution: 3
initial_rating: 6
presentation: 2
questions: Please see above.
soundness: 3
strengths: 1. The authors propose a double-pruned backward pass to improve model quality and reduce mask search overhead. They introduce additional low-rank adapters in the final 1% iterations of pretraining and improving model capacity.

2. The paper is well-written and easy to follow up. The finding of adding low-rank adapter in the last 1% iterations achieving better performance is interesting!
summary: This paper proposes SLoPE, a Double-Pruned Sparse Plus Lazy Low-rank Adapter pretraining method that improves the accuracy and accelerates training and inference of sparse LLMs. By incorporating a low-rank adapter during the final 1% of pretraining iterations, the model accuracy is well maintained. Experimental results show that the proposed method significantly speedups in both pretraining and inference phases and efficiently reduces memory footprint.
weaknesses: 1. Why does introducing additional zeros in an N:M pattern during the computation of the input gradient in the backward pass of the first 99% of iterations not severely affect accuracy?

2. The memory footprint for the pretraining should be higher than for inference, so why are the memory footprint reduction multiples similar? In the backward pass, calculating weight gradient involves a dense computation. While double-pruning reduces the computation of input gradients, the overall memory reduction should be more substantial.

3. As discussed in section 2.2, the authors introduce a hyperparameter to balance the memory footprint, computational efficiency, and model quality. In the experiments on the effects of low-rank adapters, ranks are set to 4,16, and 64. Why weren’t larger ranks used? Since the low-rank adapter is only applied in the final 1% of iterations, the computational overhead should be minimal.

Meta-review: This paper introduces a novel pruning technique based on double-direction masks, which is further combined with LoRA in the final stages, resulting in the Double-Pruned Sparse Plus Lazy Low-rank Adapter Pre-training (SLoPE). The reviewers recognized the solid technical contributions of this work. However, there are lingering concerns about the experiments, particularly regarding the use of a dense training baseline and static masks. While some of the reviewers' questions were addressed during the rebuttal, the responses only partially resolved their concerns. As a result, the overall scores are generally positive, though one reviewer with a score of 5 noted that they might increase their score if other reviewers had no remaining doubts about the experiments.

Overall, I believe this is a borderline paper: it offers technical contributions, but they are not highly significant. I suggest acceptance, but I am open to any decision made by the PC/SAC.

Decision: Accept (Poster)