NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Improving the Performance of Fully Connected Neural Networks by Out-of-Place Matrix Transpose

Shaohuai Shi, Pengfei Xu, Xiaowen Chu

Abstract

Modern deep learning frameworks often rely on libraries like cuBLAS for GPU-accelerated matrix operations. However, standard library implementations for matrix-transpose (NT) multiplications—which account for nearly half of the training time in fully connected layers—can be suboptimal. This paper introduces MTNN, a supervised learning-based selection framework that intelligently chooses between standard cuBLAS calls and a custom "transpose-then-multiply" (TNN) algorithm. By utilizing a gradient-boosted decision tree, MTNN achieves 96.39% prediction accuracy with negligible overhead, leading to an average 54% performance gain in NT operations and a 28% overall speedup in training large-scale neural networks.

Introduction: The NT Bottleneck

Training deep neural networks (DNNs) is a computationally intensive process. While libraries like NVIDIA’s cuBLAS provide highly optimized kernels for standard matrix multiplications ($A \times B$), they often struggle with "NT" operations ($A \times B^T$). In fully connected layers, these operations are critical, yet cuBLAS frequently defaults to "in-place" transpositions to conserve memory. This approach can lead to uncoalesced memory access and significant performance degradation. The challenge is that no single algorithm is the fastest for every possible matrix size or GPU architecture.

The MTNN Framework: Intelligence over Brute Force

The researchers propose a two-pronged approach to address this inefficiency:

  1. TNN (Transpose before Multiply): This alternative algorithm performs an explicit "out-of-place" matrix transpose of $B$ followed by a standard "no-transpose" multiplication. While it requires additional memory, the resulting coalesced memory access patterns make it significantly faster for many matrix configurations.
  2. MTNN (The Selection Framework): Because neither cuBLAS nor TNN is universally superior across all matrix dimensions ($M, N, K$) and GPU architectures, MTNN uses a Gradient Boosted Decision Tree (GBDT) to predict the optimal algorithm at runtime.
Figure 4: Performance comparison between cuBLAS (NT) and TNN across various matrix dimensions (M, N, K) on GTX1080 and TitanX GPUs. Red squares indicate where TNN is faster, while green circles favor cuBLAS.

As shown in the figure above, the performance landscape is complex. TNN tends to outperform cuBLAS for smaller $K$ values or specific $M, N$ combinations, whereas cuBLAS remains more efficient for very large $K$ values. MTNN uses eight features—including GPU hardware specifications and matrix dimensions—to make high-accuracy predictions in approximately 0.005 ms, making the selection process essentially free in terms of overhead.

Experimental Evaluation

The authors evaluated MTNN on NVIDIA GTX 1080 and Titan X (Pascal) GPUs using a benchmarking dataset of 1,000 matrix size combinations.

Figure 5: Frequency distribution of performance ratios (TNN vs. cuBLAS NT) on the NVIDIA GTX 1080. Values below 1.0 represent scenarios where the proposed TNN algorithm outperforms the standard cuBLAS implementation.

Key results from the evaluation include:

  • High Accuracy: The GBDT model achieved a prediction accuracy of 96.39% in selecting the faster algorithm.
  • Raw Speedup: MTNN delivered an average 54% improvement across NT operations. In extreme cases, TNN was up to 15.39x faster than the standard cuBLAS implementation.
  • System Integration: When integrated into the Caffe framework, MTNN reduced the training time of large-scale fully connected networks by an average of 28.2%.

Conclusion

MTNN demonstrates that treating algorithm selection as a machine learning problem can yield substantial performance gains in deep learning workloads. While the out-of-place transpose requires extra memory, the trade-off is highly beneficial for speed-critical training tasks. Future work will explore optimizing in-place transpose algorithms to provide similar speedups without the increased memory footprint, making these optimizations applicable even when GPU memory is scarce.

Summary updated

BibTeX
@inproceedings{shi2017improving,
  author = {Shaohuai Shi and Pengfei Xu and Xiaowen Chu},
  title = {{Improving the Performance of Fully Connected Neural Networks by Out-of-Place Matrix Transpose}},
  booktitle = {ICPADS},
  year = {2017},
  doi = {10.1109/icpads.2017.00053},
}
Figure