Skip to main content
QUICK REVIEW

[Paper Review] Automatic Kernel Generation for Volta Tensor Cores

Somashekaracharya G. Bhaskaracharya, Julien Demouth|arXiv (Cornell University)|Jun 22, 2020
Parallel Computing and Optimization TechniquesComputer Science19 references13 citations
TL;DR

This paper presents a polyhedral compilation approach to automatically generate highly optimized CUDA kernels for NVIDIA Volta tensor cores, targeting matrix multiplication fused with pointwise operations like ReLU and bias addition. By leveraging the mma.sync.m8n8k4 PTX instruction and macro-MMA compositions, the method achieves up to 2.55× speedup over manually tuned library implementations, demonstrating the effectiveness of automated kernel generation for tensor core workloads.

ABSTRACT

A commonly occurring computation idiom in neural networks is to perform some pointwise operations on the result of a matrix multiplication. Such a sequence of operations is typically represented as a computation graph in deep learning compilers. When compiling to a GPU target, these computations can be individually mapped to manually tuned implementations provided by libraries such as cuBLAS and cuDNN. These libraries also provide off-the-shelf support for targeting tensor cores in NVIDIA GPUs, which can lead to huge performance boosts through their specialized support for mixed-precision matrix math. Alternatively, tensor cores can be programmed directly using CUDA APIs or inline assembly instructions, which opens up the possibility of generating efficient CUDA kernels automatically for such computations. Automatic kernel generation is particularly crucial when it is beneficial to generate efficient code for an entire computation graph by fusing several operations into a single device function instead of invoking a separate kernel for each of them. Polyhedral compilation techniques provide a systematic approach for the analysis and transformation of a sequence of affine loop-nests. In this paper, we describe a polyhedral approach to generate efficient CUDA kernels for matrix multiplication using inline assembly instructions for programming tensor cores on NVIDIA Volta GPUs. Furthermore, we build on this approach to generate fused kernels for computation sequences involving matrix multiplication and pointwise operations such as bias addition, ReLU activation etc. Experimental evaluation of these techniques show that automatically generated kernels can provide significantly better performance than manually tuned library implementations, with speedups ranging up to 2.55X.

Motivation & Objective

  • To address the performance bottleneck of repeated global memory access when executing deep learning computation graphs with separate kernels for each operation.
  • To enable automatic generation of efficient CUDA kernels that exploit Volta tensor cores for mixed-precision matrix multiplication and fused pointwise operations.
  • To extend polyhedral compilation techniques to directly target the mma.sync.m8n8k4 PTX instruction for fine-grained control over tensor core usage.
  • To demonstrate that automatically generated kernels can outperform manually tuned library implementations (e.g., cuBLAS, cuDNN) in fused computation scenarios.
  • To provide a systematic, reusable framework for generating high-performance kernels for tensor core-accelerated deep learning workloads.

Proposed method

  • The method uses a polyhedral framework to analyze and transform affine loop-nests representing matrix multiplication and pointwise operations.
  • It generates kernels that directly program Volta tensor cores using the mma.sync.m8n8k4 PTX instruction, which operates on 8×8×8 matrix fragments across thread quads.
  • The approach composes lower-level mma.sync.m8n8k4 operations into higher-order macro-MMA operations of size 16×16×8 and 32×32×8 to improve memory bandwidth utilization.
  • It supports fusion of matmul with upstream (prologue) and downstream (epilogue) pointwise operations such as ReLU, Sigmoid, and bias addition.
  • The framework integrates with the Diesel DSL compiler and uses a custom schedule to optimize tile sizes and register usage for tensor core kernels.
  • It employs a systematic code generation pipeline that maps high-level computation graphs to optimized CUDA kernels with minimal manual tuning.

Experimental results

Research questions

  • RQ1Can polyhedral compilation techniques be effectively applied to generate high-performance CUDA kernels for Volta tensor cores?
  • RQ2To what extent can automatic kernel generation outperform manually tuned libraries like cuBLAS and cuDNN for fused matmul and pointwise operations?
  • RQ3How effective is the use of mma.sync.m8n8k4 PTX instructions for achieving high arithmetic intensity and memory bandwidth efficiency in fused kernels?
  • RQ4What are the performance trade-offs of different tile sizes and fusion strategies in tensor core kernels under varying workloads?
  • RQ5Can macro-MMA compositions (16×16×8 and 32×32×8) be automatically generated and optimized using polyhedral analysis to improve performance over atomic mma operations?

Key findings

  • The proposed method achieved up to 2.55× speedup over cuBLAS and cuDNN for fused matmul and pointwise operations, particularly on larger problem sizes.
  • For single matmul kernels, the automatic generation achieved 1.46× speedup over cuBLAS and 1.35× over cuDNN, demonstrating effectiveness even without fusion.
  • Fused kernels with multiple matmuls showed higher register pressure, requiring smaller tile sizes that reduced but did not eliminate performance gains.
  • The method outperformed existing frameworks like Halide and TVM in tensor core kernel generation, particularly due to direct mma.sync.m8n8k4 usage and macro-MMA composition.
  • The approach achieved significant performance improvements across a wide range of problem sizes, with the largest gains observed in fused computation graphs involving matmul and ReLU or bias addition.
  • The work demonstrates that polyhedral compilation can be effectively extended to target low-level tensor core instructions, enabling automatic generation of highly optimized kernels.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.