Abstract
Tensorial Neural Networks (TNNs) offer a powerful way to compress massive convolutional models, but they are notoriously difficult to train efficiently because standard libraries lack the capability to optimize the complex sequence of operations they require. This paper introduces conv_einsum, a framework that extends the popular einsum notation to include convolutions and uses a specialized "optimal sequencer" to find the mathematically fastest path to compute these layers. The framework results in up to a 90x reduction in FLOPs and significantly lower memory usage, enabling efficient training and deployment of compressed models.
Introduction: The Challenge of Evaluating Factorized Convolutions
Modern deep learning is characterized by a "size race," with state-of-the-art convolutional networks (ConvNets) reaching billions of parameters. This scale makes them nearly impossible to deploy on edge devices like phones or IoT sensors. Tensorial Neural Networks (TNNs) address this by factorizing giant weight tensors into several much smaller components using methods like CP or Tucker decomposition.
However, while the total number of parameters drops, the number of operations required to perform a forward pass can skyrocket. Evaluating a factorized layer involves a sequence of multilinear operations (MLOs). The order in which these operations are performed drastically changes the size of intermediate results and the total floating-point operations (FLOPs). Existing tools like NumPy’s einsum are optimized for simple contractions but do not support convolutions, leaving researchers to rely on "naive" evaluation paths that are slow and memory-intensive.
The conv_einsum Framework
The authors propose a two-part solution to optimize these operations:
conv_einsumNotation: A new notation that extends the familiareinsumstring. By adding a pipe delimiter (|), users can specify which dimensions should undergo convolution. For example,conv_einsum("bshw,tshw->bthw|hw", X, W)specifies a 2D convolution over height (h) and width (w).- The Optimal Sequencer: The framework extends the
netconalgorithm—originally used in physics for tensor network contractions—to handle convolutions. This sequencer analyzes theconv_einsumstring and tensor dimensions to find a pairwise evaluation path that minimizes FLOPs.
To ensure high performance on GPUs, the framework automatically maps these optimized paths to efficient, low-level PyTorch operations like conv1d and conv2d. Furthermore, it integrates gradient checkpointing to save memory during the backward pass by recomputing intermediate values rather than storing them in VRAM.
Experimental Results
The authors evaluated conv_einsum across image classification (CIFAR-10, ImageNet), video classification (UCF-101), and automatic speech recognition (LibriSpeech).
Performance Gains
The framework demonstrated massive reductions in computational overhead. For a ResNet-34 model, conv_einsum achieved a 90x speedup in FLOPs for the final convolutional layers compared to the naive approach. On ImageNet, this translated to a reduction in training time per epoch from 65 minutes to 41 minutes.
Memory Efficiency
The sequencer avoids creating massive temporary intermediate tensors, which often lead to "Out of Memory" (OOM) errors in naive implementations. In video classification tasks, where standard PyTorch implementations often crashed with a batch size of 1, conv_einsum successfully handled batch sizes of 20-30 on the same hardware.
Conclusion
conv_einsum bridges the gap between theoretical tensor compression and practical deep learning performance by treating convolutions as first-class citizens in tensor networks. It allows for significant model compression (down to 5-10% of original parameters) while maintaining efficient training cycles. Future work will focus on extending support for non-communicative convolutions and deeper integration with specialized hardware acceleration libraries like NVIDIA’s TensorRT.
Summary updated