Accelerated CNN Training through Gradient Approximation

Sree Harsha Nelaturu, Ziheng Wang, Saman P. Amarasinghe

Abstract

Training deep convolutional neural networks such as VGG and ResNet by gradient descent is an expensive exercise requiring specialized hardware such as GPUs. Recent works have examined the possibility of approximating the gradient computation while maintaining the same convergence properties. While promising, the approximations only work on relatively small datasets such as MNIST. They also fail to achieve real wall-clock speedups due to lack of efficient GPU implementations of the proposed approximation methods. In this work, we explore three alternative methods to approximate gradients, with an efficient GPU kernel implementation for one of them. We achieve wall-clock speedup with ResNet-20 and VGG-19 on the CIFAR-10 dataset upwards of 7 percent, with a minimal loss in validation accuracy.

Introduction

The computational burden of training deep convolutional neural networks (CNNs) is a significant bottleneck in machine learning research and deployment. In a standard training loop, each layer requires three primary convolutional operations: the forward pass, the backward pass for activation gradients, and the backward pass for weight gradients. Notably, the weight gradient calculation alone accounts for approximately one-third of the total training time.

While mathematical approximations of these gradients have been proposed to reduce this burden, they often fail to deliver practical "wall-clock" speedups. This is primarily because standard deep learning libraries, such as cuDNN, are highly optimized for dense matrix operations, making sparse or approximated computations slower in practice. This paper addresses this gap by introducing robust approximation strategies coupled with a high-performance custom GPU kernel.

Gradient Approximation Methods

We propose three distinct strategies for approximating weight gradients during backpropagation:

  • Zero Gradient: This approach temporarily "freezes" weights by passing back a gradient of zero for specific layers and batches, skipping the associated computation entirely.
  • Random Gradient: Gradients are replaced with values sampled from a normal distribution. This method acts as a form of regularization, often aiding convergence despite the introduced noise.
  • Approximated Gradient (Top-K): For each output channel, the algorithm retains only the single largest-magnitude gradient value, setting others to zero. This creates a high sparsity ratio ($1 - 1/HW$), significantly reducing the data processed.

Approximation Schedules

To balance computational efficiency with model accuracy, we employ approximation schedules. Rather than approximating every layer continuously, these schedules determine when and where to apply approximations. For example, a schedule might skip the sensitive first layer or apply approximations to every other training batch.

Figure 2: Visualization of approximation schedules across layers and training batches, showing the distribution of full, zero, random, and approximated gradients.

Custom CUDA Kernel Implementation

A key contribution of this work is a custom CUDA kernel designed to make the Top-K method computationally viable. Unlike standard im2col approaches used for dense math, our kernel interprets sparse convolution as a direct "patch extraction" procedure. This optimization allows the GPU to handle sparse gradients much more efficiently, overcoming the memory and arithmetic bottlenecks of traditional libraries.

Experimental Results

The proposed methods were evaluated on the CIFAR-10 dataset using ResNet-20 and VGG-19 architectures. Our experiments reveal that deep networks are remarkably resilient to gradient noise and sparsity.

Figure 6: Training loss (a) and validation accuracy (b) for various gradient approximation methods compared to the full gradient baseline.

As illustrated in Figure 6, the training process remains stable, with all approximation methods converging similarly to the full gradient baseline. Key findings include:

  • Speedup: We achieved a real-world training speedup of over 7% for ResNet-20 and VGG-19.
  • Accuracy: The speedup comes with a minimal hit to validation accuracy, often less than 1%. In some cases, the Random Gradient method even improved generalization in smaller models.
  • Kernel Performance: The custom CUDA kernel outperformed the cuDNN baseline by at least 3x for the required sparse operations.

Conclusion

This work demonstrates that "cheating" during backpropagation through gradient approximation is an effective way to accelerate CNN training. By leveraging specialized schedules and custom GPU kernels, we can achieve meaningful wall-clock speedups with negligible impact on model performance. Future work will explore scaling these techniques to larger datasets like ImageNet and further optimizing the kernel by fusing data transposition operations.

Summary updated

BibTeX
@misc{nelaturu2019accelerated,
  author = {Sree Harsha Nelaturu and Ziheng Wang and Saman P. Amarasinghe},
  title = {{Accelerated CNN Training through Gradient Approximation}},
  year = {2019},
  eprint = {1908.05460},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1908.05460},
}
Figure