---
# System prepended metadata

title: 'Scalpel: Customizing DNN Pruning to the Underlying Hardware Parallelism'

---

# Scalpel: Customizing DNN Pruning to the Underlying Hardware Parallelism
###### paper origin: ISCA 2017
###### Link: [Paper](https://cgi.luddy.indiana.edu/~lukefahr/papers/jiecaoyu_isca17.pdf)


## Motivation: 
As DNNs continue to grow in size and complexity, their energy footprint also increases. Weight pruning is a common technique for reducing model size and computation, but it can lead to network sparsity that affects performance.

## Main Challenge:
How can we customize DNN pruning to underlying hardware parallelism to improve performance and reduce energy consumption?

## Solution: 
The Scalpel approach proposes two techniques for customizing DNN pruning to different hardware platforms based on their parallelism: SIMD-aware weight pruning and node pruning. 
* **SIMD-aware weight pruning** is applied to low-parallelism hardware to fully utilize SIMD units.
* **Node pruning** removes redundant nodes on high-parallelism hardware. This approach improves overall performance and reduces energy consumption.












### DNN Struture
![](https://hackmd.io/_uploads/Ske5QR-Sh.png)
In FC layers, all input values are connected to every neuron. For CONV layers, as shown in Figure 1, they consist of a stack of 2D matrices named feature maps.

FC layers perform matrix-vector multiplication, and CONV layers perform matrix-matrix multiplication


## Challenge
### 1.sparse weight matrix spends too much extra data to record the sparse matrix format
![](https://hackmd.io/_uploads/S1icXCZS2.png)

* A holds all the nonzero values. 
* IA records the index into A of the first nonzero element in each row of W. 
* JA stores the column indexes of the nonzero elements. 
Since the index array JA has the same size with the data array A, more than half of the data in the CSR format is used to store the sparse matrix format.
### 2. Weight pruning can hurt the DNN computation performance
![](https://hackmd.io/_uploads/r1oo7AZH2.png)




###  A breakdown of the execution time for the dense and the sparse DNN models on the CPU
![](https://hackmd.io/_uploads/SymhQRZB2.png)


### The numbers of cache accesses and cache misses for this layer broken down by loads and stores
![](https://hackmd.io/_uploads/SJh2QCZB2.png)


## Approach

### Overview of Scalpel
![](https://hackmd.io/_uploads/BJva7A-Bn.png)
* All general-purpose hardware platforms are divided into three categories based on their internal parallelism: low parallelism, moderate parallelism, and high parallelism.
* For low-parallelism hardware, SIMD-aware weight pruning is applied.
* For high-parallelism hardware, node pruning is applied. 
* For hardware with moderate parallelism, we use a combination of SIMD-aware weight pruning and node pruning.

### SIMD-Aware Weight Pruning
![](https://hackmd.io/_uploads/B1TC7RWHh.png)
![](https://hackmd.io/_uploads/S1IkN0brh.png)
* A' stores all the nonzero weight groups with the original order.
* IA' records the index into A' of the first nonzero element in each row of W. 
* JA' stores the column index of each group.

###  The peak performance benefit from SIMD-aware weight pruning. 
![](https://hackmd.io/_uploads/HkbeV0ZB2.png)

### Node Prunning
### The relative execution time of sparse matrix-matrix multiplication on GPU against the pruning rate.
![](https://hackmd.io/_uploads/rkcx4R-rn.png)
To avoid this performance decrease, node pruning removes DNN redundancy by removing entire nodes instead of weights. It uses mask layers to dynamically find out unimportant nodes and block their outputs. The blocked nodes are removed after the training of mask layers. After removing all redundant nodes, mask layers are removed, and the network is retrained to get the pruned DNN model.
### Main steps of node pruning
![](https://hackmd.io/_uploads/rkQbNAbrh.png)
### Mask layers
![](https://hackmd.io/_uploads/r19WNRZrh.png)

### Combined Prunning

###  The relative execution time for sparse matrix-vector and matrix-matrix multiplication on Intel Core i7-6700 CPU, respectively. 
![](https://hackmd.io/_uploads/H1XykMfBn.png)

## Experiment Methodology

### Hardware platforms
1. Microcontroller - low parallelism. We use ARM Cortex-M4 microcontroller which has a 3-stage in-order pipeline and 2-way SIMD units for 16-bit fixed-point numbers.

3. CPU - moderate parallelism. We use Intel Core i7-6700 CPU, which is a Skylake class core. It supports 8-way SIMD instructions for 32-bit floating-point numbers

5. GPU - high parallelism. We use NVIDIA GTX Titan X which is a state-of-the-art GPU for deep learning and included in the NVIDIA Digits Deep Learning DevBox machine. 
### Benchmarks
![](https://hackmd.io/_uploads/SkyLJfMHn.png)
### Experiment baselines
We use the original dense DNN models as the baseline. 
1. Traditional
2. Optimal
3. Scaple

## Evaluation Result

### Overview
![](https://hackmd.io/_uploads/rJ-4bGMB3.png)



### 5.1 Microcontroller - Low Parallelism

#### The relative performance speedups and relative model sizes of the original models, traditional pruning, optimized pruning and Scalpel.
![](https://hackmd.io/_uploads/rkyWWMzBh.png =50%x)![](https://hackmd.io/_uploads/BJNAefGr2.png =50%x)

#### The curves of relative accuracy against pruning rate for the three metrics
![](https://hackmd.io/_uploads/B1owWzzr2.png)

###  CPU - Moderate Parallelism

#### The relative performance speedups and relative model sizes of the original models, traditional pruning and Scalpel.
![](https://hackmd.io/_uploads/S1x9bMzBn.png =360x) ![](https://hackmd.io/_uploads/rJ69bGGHh.png =360x)

### GPU - High Parallelism

#### The relative performanc speedups of the original models, traditional pruning, optimized pruning and Scalpel.
![](https://hackmd.io/_uploads/SymQzffHn.png =360x)![](https://hackmd.io/_uploads/SJ7rzMzSh.png =360x)

Models generated by Scalpel, except ConvNet and NIN, have higher model sizes than those generated by traditional and optimized pruning.

#### The percentage of nodes we can remove from each layer in DNNs
![](https://hackmd.io/_uploads/Bkv5GGfH2.png)

## Related Work
In the Scalpel paper, the authors provided a survey of existing DNN pruning methods. They pointed out that existing pruning methods often suffer from the following issues: 1) they may destroy the structure of DNNs, leading to performance degradation; 2) they may introduce sparsity, increasing storage and computation overheads; 3) they may not fully exploit the parallelism and computational power of hardware platforms. To address these issues, the authors proposed the Scalpel method.

## Conclusion:
In the Scalpel paper, the authors proposed a new DNN pruning method, namely Scalpel. Scalpel customizes DNN pruning through two methods (SIMD-aware weight pruning and node pruning) to improve performance and reduce energy consumption. The authors also compared Scalpel with traditional pruning and Optimal Brain Surgeon (OBS) on different hardware platforms. The experimental results showed that Scalpel achieved better performance and efficiency on all three hardware platforms. Therefore, Scalpel is a promising DNN pruning method that deserves further exploration and application in future research.