SPT: Fine-Tuning Transformer-based Language Models Efficiently with Sparsification

Yuntao Gui, Xiao Yan, Peiqi Yin, Han Yang, James Cheng
12/16/2023
cs.DCcs.AI

No confident code implementation found for this paper.

Abstract

Transformer-based large language models (e.g., BERT and GPT) achieve great success, and fine-tuning, which tunes a pre-trained model on a task-specific dataset, is the standard practice to utilize these models for downstream tasks. However, Transformer fine-tuning has long running time and high memory consumption due to the large size of the models. We propose the SPT system to fine-tune Transformer-based models efficiently by introducing sparsity. We observe that the memory consumption of Transformer mainly comes from storing attention weights for multi-head attention (MHA), and the majority of running time is spent on feed-forward network (FFN). Thus, we design the sparse MHA module, which computes and stores only large attention weights to reduce memory consumption, and the routed FFN module, which dynamically activates a subset of model parameters for each token to reduce computation cost. We implement SPT on PyTorch and customize CUDA kernels to run sparse MHA and routed FFN efficiently. Specifically, we use product quantization to identify the large attention weights and compute attention via sparse matrix multiplication for sparse MHA. For routed FFN, we batch the tokens according to their activated model parameters for efficient computation. We conduct extensive experiments to evaluate SPT on various model configurations. The results show that SPT consistently outperforms well-optimized baselines, reducing the peak memory consumption by up to 50% and accelerating fine-tuning by up to 2.2x.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. Any repos shown below are weak matches — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{gui2023spt,
  title  = {SPT: Fine-Tuning Transformer-based Language Models Efficiently with Sparsification},
  author = {Yuntao Gui and Xiao Yan and Peiqi Yin and Han Yang and James Cheng},
  year   = {2023},
  eprint = {2312.10365},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2312.10365v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2312.10365.svg)](https://codeofpaper.com/paper/2312.10365)

Discussion