CPU上でのTransformerベース言語モデル向け効率的なスパース推論ソフトウェアアクセラレータ
An Efficient Sparse Inference Software Accelerator for Transformer-based Language Models on CPUs
June 28, 2023
著者: Haihao Shen, Hengyu Meng, Bo Dong, Zhe Wang, Ofir Zafrir, Yi Ding, Yu Luo, Hanwen Chang, Qun Gao, Ziheng Wang, Guy Boudoukh, Moshe Wasserblat
cs.AI
要旨
近年、Transformerベースの言語モデルは自然言語処理タスクにおける標準的なアプローチとなっています。しかし、産業アプリケーションにおける厳格なスループットとレイテンシの要件が、その採用を制限しています。このギャップを緩和するため、構造化プルーニングなどのモデル圧縮技術が推論効率の向上に使用されています。しかし、既存のニューラルネットワーク推論ランタイムの多くは、構造化スパース性に対する十分なサポートを欠いています。本論文では、重みが一定のブロックサイズでプルーニングされたTransformerベースの言語モデル向けの効率的なスパースディープラーニング推論ソフトウェアスタックを提案します。私たちのスパースソフトウェアアクセラレータは、Intel Deep Learning Boostを活用して、CPU上でのスパース行列-密行列乗算(一般的にSpMMと略される)の性能を最大化します。私たちのSpMMカーネルは、5つの代表的なスパース率(70%、75%、80%、85%、90%)において、広範なGEMM形状に対して既存のスパースライブラリ(oneMKL、TVM、LIBXSMM)を1桁上回る性能を示します。さらに、私たちのSpMMカーネルは、業界で広く使用されている最適化された密ライブラリであるoneDNNの密GEMMカーネルに対して最大5倍の高速化を示します。私たちは、Bert-Mini、DistilBERT、Bert-Base、BERT-Largeなどの広く使用されているTransformerベースの言語モデルに私たちのスパースアクセラレータを適用します。私たちのスパース推論ソフトウェアは、Amazon Web Services上のXeonにおいて、プロキシ生産レイテンシ制約下で、Neural MagicのDeepsparseと同等の設定で最大1.5倍の高速化を示します。また、私たちのソリューションを、ONNX RuntimeとPyTorchという2つのフレームワークベースの推論ソリューションと比較し、Xeon上でのレイテンシ制約下で、ONNX Runtimeに対して最大37倍、PyTorchに対して最大345倍の高速化を実証します。すべてのソースコードはGithubで公開されています: https://github.com/intel/intel-extension-for-transformers。
English
In recent years, Transformer-based language models have become the standard
approach for natural language processing tasks. However, stringent throughput
and latency requirements in industrial applications are limiting their
adoption. To mitigate the gap, model compression techniques such as structured
pruning are being used to improve inference efficiency. However, most existing
neural network inference runtimes lack adequate support for structured
sparsity. In this paper, we propose an efficient sparse deep learning inference
software stack for Transformer-based language models where the weights are
pruned with constant block size. Our sparse software accelerator leverages
Intel Deep Learning Boost to maximize the performance of sparse matrix - dense
matrix multiplication (commonly abbreviated as SpMM) on CPUs. Our SpMM kernel
outperforms the existing sparse libraries (oneMKL, TVM, and LIBXSMM) by an
order of magnitude on a wide range of GEMM shapes under 5 representative
sparsity ratios (70%, 75%, 80%, 85%, 90%). Moreover, our SpMM kernel shows up
to 5x speedup over dense GEMM kernel of oneDNN, a well-optimized dense library
widely used in industry. We apply our sparse accelerator on widely-used
Transformer-based language models including Bert-Mini, DistilBERT, Bert-Base,
and BERT-Large. Our sparse inference software shows up to 1.5x speedup over
Neural Magic's Deepsparse under same configurations on Xeon on Amazon Web
Services under proxy production latency constraints. We also compare our
solution with two framework-based inference solutions, ONNX Runtime and
PyTorch, and demonstrate up to 37x speedup over ONNX Runtime and 345x over
PyTorch on Xeon under the latency constraints. All the source code is publicly
available on Github: https://github.com/intel/intel-extension-for-transformers.