Abstract: The tensor network, as a factorization of tensors, aims at performing the operations that are common for normal tensors, such as addition, contraction and stacking. However, due to its non-unique network structure, only the tensor network contraction is so far well defined. In this paper, we propose a mathematically rigorous definition for the tensor network stack approach, that compress a large amount of tensor networks into a single one without changing their structures and configurations. We illustrate the main ideas with the matrix product states based machine learning as an example. Our results are compared with the for loop and the efficient coding method on both CPU and GPU.
Introduction
In modern deep learning, batching is essential for computational efficiency. While standard tensors are easily stacked into higher-dimensional structures for parallel processing on GPUs, Tensor Networks (TNs)—efficient factorizations of massive tensors—have lacked a standardized "stack" operation. This limitation often forces researchers to rely on sequential "for-loops," which fail to exploit the parallel processing power of modern hardware. This paper fills that gap by defining how to mathematically stack multiple TNs into one "Batched Tensor Network" (BTN) without changing their internal configuration.
The Batched Tensor Network (BTN) Method
The core innovation of the BTN approach is the representation of a stack of tensor networks through the creation of larger local tensors that are block-diagonal.
As illustrated in the figure above, the goal is to transform a collection of $n$ individual Matrix Product States (MPS) into a single network. This transformation turns a batch of many small contractions into a single large contraction, which is significantly more efficient on parallel hardware.
The mathematical implementation utilizes block-diagonal matrices where each sample's data occupies a specific block along the diagonal. This structure ensures that the information from different samples remains independent during contraction, while allowing the GPU to process the entire batch in a single mathematical operation.
Experimental Results
The researchers evaluated the BTN method using the MNIST handwritten digit database. They compared the training speed and accuracy of the BTN approach against naive loops (LP) and "efficient coding" (EC) tricks.
- Speedup: On an NVIDIA 1080Ti GPU, for a batch size of 100, the LP method took roughly an hour, while BTN took 300 seconds and EC took only 60 seconds.
- Hardware Synergy: The BTN method achieves constant time complexity on GPUs as batch size increases, successfully leveraging parallel architecture. In contrast, performance on CPUs scales linearly, similar to a standard loop.
- Accuracy: All three methods produced identical accuracy results (~92%), confirming that the stack operation is mathematically sound and information-preserving.
Conclusion and Future Directions
The BTN framework provides a rigorous foundation for batching in tensor networks. While memory consumption remains a challenge—due to the $O(B^2)$ scaling of dense block-diagonal tensors in certain configurations—this work opens doors for future optimizations. Key areas for future research include the development of "batch Singular Value Decomposition" (SVD) for network compression and the extension of these concepts to 2D structures like Projected Entangled Pair States (PEPS).
Summary updated