Efficient and Generic 1D Dilated Convolution Layer for Deep Learning

Narendra Chaudhary, Sanchit Misra, Dhiraj D. Kalamkar, Alexander Heinecke, Evangelos Georganas, Barukh Ziv, Menachem Adelman, Bharat KaularXiv 2021

TL;DR

This paper presents a highly optimized 1D dilated convolution layer for CPUs, leveraging Intel's AVX-512 instructions and the LIBXSMM library's BRGEMM kernel. The implementation achieves significant speedups (up to 6.86x) over existing libraries like oneDNN in end-to-end genomics tasks and demonstrates impressive scalability across multiple CPU sockets, even outperforming multi-GPU setups in certain scenarios.

What Problem Does This Paper Address?

While 2D convolution layers have seen extensive optimization for image-related tasks, many critical applications in fields like genomics, speech recognition, and audio processing deal with one-dimensional (1D) data. Existing 1D convolution implementations, particularly those in libraries like Intel's oneDNN, become inefficient when dealing with larger input tensor widths and filter sizes, limiting the performance of deep learning models in these domains. This paper aims to bridge this gap by providing an efficient and generic 1D dilated convolution layer optimized for modern x86 CPU architectures.

Methods

The core of the paper's contribution lies in its novel implementation strategy for the 1D dilated convolution layer. Instead of relying on traditional approaches, the authors reframe the convolution operation as a series of matrix multiplications. They achieve this by:

  • Leveraging LIBXSMM's BRGEMM: The batch-reduce General Matrix Multiplication (BRGEMM) kernel from the LIBXSMM library is used as the primary computational engine. BRGEMM is known for its ability to efficiently handle matrix operations by breaking them into smaller blocks and utilizing SIMD instructions.
  • Cache Blocking: To further optimize performance, the authors employ cache blocking techniques, specifically along the width dimension of the tensors, with a block size of 64 elements. This ensures that data remains within the CPU's cache hierarchy for faster access.
  • JIT Code Generation: LIBXSMM's Just-In-Time (JIT) code generation capabilities are utilized to produce highly optimized assembly code tailored to the specific CPU architecture, including support for Intel AVX-512 and AVX-512 BFloat16 instructions.
  • Precision Support: The implementation supports both single-precision (FP32) and BFloat16 precision, allowing for flexibility and potential performance gains with the latter.
  • Algorithm Reframing: The forward and backward passes of the 1D dilated convolution are expressed in terms of GEMM operations, which are then mapped to BRGEMM. The backward weight pass utilizes small GEMM kernels.

Datasets

The paper uses synthetic datasets for initial efficiency and generality experiments. For end-to-end evaluation, they utilize real genomics (ATAC-Seq) datasets. Specifically, they train a 1D ResNet CNN model named "AtacWorks" on chromosome 20 of the ATAC-seq dataset for training and validation, and chromosome 10 for testing. The training set consists of 32,000 1D ATAC-seq signal track segments, each with an initial width of 50,000, padded to 60,000.

Key Insights and Ideas

  • The Power of BRGEMM for 1D Convolutions: The paper convincingly demonstrates that by reframing 1D convolutions as matrix multiplications and leveraging optimized BRGEMM kernels, significant performance improvements can be achieved on CPUs, even for tasks traditionally dominated by GPUs.
  • Generality Through Optimization: The authors highlight that their BRGEMM-based approach, combined with cache blocking and JIT compilation, leads to a generic implementation that maintains high efficiency across a wide range of parameters (input width, filter width, channels, dilation), a key advantage over specialized kernels.
  • BFloat16 for Performance Gains: The inclusion of BFloat16 precision support shows a notable performance boost, indicating its growing importance for deep learning workloads on modern hardware.
  • CPU Scalability is Crucial: The experiments showcasing near-linear scaling across multiple CPU sockets underscore the potential of highly optimized CPU implementations to compete with, and in some cases surpass, multi-GPU solutions, especially within similar power envelopes.

Key Results

  • Efficiency: The optimized 1D convolution layer achieves up to 80% efficiency on Intel Xeon Cascade Lake and Cooper Lake CPUs.
  • Speedup over oneDNN: The implementation consistently outperforms Intel's oneDNN library for 1D convolution layers, especially when dealing with larger input tensor widths and filter sizes (filter size >= 5).
  • End-to-End Genomics Speedup: In end-to-end neural network training on real genomics datasets (AtacWorks), the optimized layer achieves up to 6.86x speedup over the oneDNN-based implementation on Cascade Lake CPUs.
  • Multi-Socket Scaling: The implementation scales nearly linearly from 1 to 16 CPU sockets.
  • Comparison with Multi-GPU:
    • On 16 sockets of Cascade Lake (FP32), a 1.41x speedup is achieved compared to eight V100 GPUs.
  • On 16 sockets of Cooper Lake (FP32), a 1.57x speedup is achieved compared to eight V100 GPUs.
  • On 16 sockets of Cooper Lake (BFloat16), a 2.27x speedup is achieved compared to eight V100 GPUs.
  • BFloat16 Performance: The BFloat16 implementation shows a significant performance increase, with up to a 1.6x speedup over FP32 for similar configurations.

Limitations and Future Work

  • Hardware Specificity: While optimized for Intel x86 architectures with AVX-512, the implementation's direct applicability to other architectures might be limited without further adaptation.
  • Even Number Requirement for BFloat16: The BFloat16 precision implementation has a constraint that the input tensor width, number of channels, and number of filters must be even numbers.
  • Future Work: The authors suggest that future progress in applications like genomics will depend on computing costs, implying that continued optimization efforts are crucial. They also mention ongoing work, though specific details are not elaborated upon in the provided text. The paper implicitly suggests that further exploration of BFloat16 optimizations and broader application of their BRGEMM-based approach to other deep learning kernels could be fruitful.

Summary updated

Abstract

Convolutional neural networks (CNNs) have found many applications in tasks involving two-dimensional (2D) data, such as image classification and image processing. Therefore, 2D convolution layers have been heavily optimized on CPUs and GPUs. However, in many applications - for example genomics and speech recognition, the data can be one-dimensional (1D). Such applications can benefit from optimized 1D convolution layers. In this work, we introduce our efficient implementation of a generic 1D convolution layer covering a wide range of parameters. It is optimized for x86 CPU architectures, in particular, for architectures containing Intel AVX-512 and AVX-512 BFloat16 instructions. We use the LIBXSMM library's batch-reduce General Matrix Multiplication (BRGEMM) kernel for FP32 and BFloat16 precision. We demonstrate that our implementation can achieve up to 80% efficiency on Intel Xeon Cascade Lake and Cooper Lake CPUs. Additionally, we show the generalization capability of our BRGEMM based approach by achieving high efficiency across a range of parameters. We consistently achieve higher efficiency than the 1D convolution layer with Intel oneDNN library backend for varying input tensor widths, filter widths, number of channels, filters, and dilation parameters. Finally, we demonstrate the performance of our optimized 1D convolution layer by utilizing it in the end-to-end neural network training with real genomics datasets and achieve up to 6.86x speedup over the oneDNN library-based implementation on Cascade Lake CPUs. We also demonstrate the scaling with 16 sockets of Cascade/Cooper Lake CPUs and achieve significant speedup over eight V100 GPUs using a similar power envelop. In the end-to-end training, we get a speedup of 1.41x on Cascade Lake with FP32, 1.57x on Cooper Lake with FP32, and 2.27x on Cooper Lake with BFloat16 over eight V100 GPUs with FP32.
BibTeX
@misc{chaudhary2021efficient,
  author = {Narendra Chaudhary and Sanchit Misra and Dhiraj D. Kalamkar and Alexander Heinecke and Evangelos Georganas and Barukh Ziv and Menachem Adelman and Bharat Kaul},
  title = {{Efficient and Generic 1D Dilated Convolution Layer for Deep Learning}},
  year = {2021},
  eprint = {2104.08002},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2104.08002},
}
Figure