[Paper Review] tntorch: Tensor Network Learning with PyTorch
tntorch is a PyTorch-integrated tensor network library that unifies support for multiple low-rank tensor decompositions—CP, Tucker, and Tensor Train—under a single, PyTorch-like API. It enables automatic differentiation, GPU acceleration, and seamless differentiable operations, allowing users to learn, manipulate, and compress high-dimensional tensors efficiently while supporting mixed-format networks and advanced features like cross-approximation and differentiable tensor algebra.
We present tntorch, a tensor learning framework that supports multiple decompositions (including Candecomp/Parafac, Tucker, and Tensor Train) under a unified interface. With our library, the user can learn and handle low-rank tensors with automatic differentiation, seamless GPU support, and the convenience of PyTorch's API. Besides decomposition algorithms, tntorch implements differentiable tensor algebra, rank truncation, cross-approximation, batch processing, comprehensive tensor arithmetics, and more.
Motivation & Objective
- To unify multiple tensor decomposition formats (CP, Tucker, TT) into a single, user-friendly interface that abstracts underlying representation differences.
- To provide full compatibility with PyTorch’s automatic differentiation and GPU acceleration for end-to-end differentiable tensor learning.
- To support mixed tensor network architectures combining CP, Tucker, and TT components within a single computational graph.
- To enable efficient, differentiable operations such as cross-approximation, rank truncation, and tensor algebra for machine learning and data analysis.
- To offer a flexible, extensible framework that supports advanced use cases like tensor completion, model compression, and surrogate modeling via black-box sampling.
Proposed method
- Encapsulates all tensor decompositions into a unified `Tensor` class with a PyTorch-compatible API, enabling seamless integration with deep learning workflows.
- Represents tensors as low-rank tensor networks where each node is a core or factor, and operations are performed via tensor contractions with automatic gradient computation.
- Supports mixed-format tensor networks by allowing CP, Tucker, and TT components to coexist and be composed in arbitrary combinations within a single tensor object.
- Implements differentiable cross-approximation using the maxvol algorithm to sample key indices from a black-box tensor function, enabling memory-efficient learning without full tensor storage.
- Provides specialized classes like `TTMatrix` and `CPMatrix` for efficient matrix-vector multiplication in TT and CP formats, avoiding full tensor decompression.
- Leverages PyTorch’s autograd system to enable gradient-based optimization, including global and Riemannian optimization, for learning low-rank tensor structures.
Experimental results
Research questions
- RQ1How can multiple tensor decomposition formats (CP, Tucker, TT) be unified under a single, composable interface that preserves differentiability and GPU support?
- RQ2Can cross-approximation be made differentiable and integrated into a deep learning pipeline for efficient, gradient-based learning of large or in-memory tensors?
- RQ3To what extent can mixed tensor network architectures (e.g., CP-TT-Tucker hybrids) improve expressivity and efficiency in machine learning tasks?
- RQ4How can tensor algebra operations like convolution, padding, and rank truncation be efficiently implemented in a differentiable and scalable manner?
- RQ5Can a PyTorch-native library achieve comparable performance and flexibility to specialized tensor libraries while maintaining ease of use and extensibility?
Key findings
- tntorch successfully unifies CP, Tucker, and TT decompositions under a single `Tensor` class with full support for automatic differentiation and GPU computation.
- The library enables differentiable cross-approximation via the maxvol algorithm, allowing efficient learning of TT tensors from black-box functions without storing the full tensor.
- Mixed tensor network architectures (e.g., CP-TT-Tucker) are natively supported and can be constructed and optimized end-to-end using standard PyTorch operations.
- Differentiable tensor algebra operations—including element-wise functions, convolution, and rank truncation—can be computed efficiently with minimal memory overhead.
- The implementation of `TTMatrix` and `CPMatrix` enables fast matrix-vector multiplication without decompressing the tensor, achieving linear-time complexity in the number of cores.
- tntorch supports advanced features such as sensitivity analysis, statistical moments, and sampling from TT-compressed distributions, enabling broader applications in probabilistic modeling and optimization.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.