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:
- 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.
- 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.
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.
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