Abstract: Simulation is essential for developing quantum hardware and algorithms. However, simulating quantum circuits on classical hardware is challenging due to the exponential scaling of quantum state space. While factorized tensors can greatly reduce this overhead, tensor network-based simulators are relatively few and often lack crucial functionalities. To address this deficiency, we created TensorLy-Quantum, a Python library for quantum circuit simulation that adopts the PyTorch API. Our library leverages the optimized tensor methods of the existing TensorLy ecosystem to represent, simulate, and manipulate large-scale quantum circuits. Through compact tensor representations and efficient operations, TensorLy-Quantum can scale to hundreds of qubits on a single GPU and thousands of qubits on multiple GPUs. TensorLy-Quantum is open-source and accessible at https://github.com/tensorly/quantum
Introduction
Simulating quantum systems on classical computers is notoriously difficult because the state space—the amount of information needed to describe the system—grows exponentially with the number of qubits. Traditional methods using dense vectors and matrices hit a "memory wall" very quickly, usually around 25–30 qubits. For instance, a traditional matrix-encoded simulation of just 25 qubits would require roughly 1,000,000 GB of memory.
While tensor networks (a method of factorizing large tensors into smaller, interconnected pieces) can bypass this limit, existing tensor-based simulators often operate in isolation. They frequently lack the "quality of life" features that machine learning researchers require, such as automatic differentiation and high-level APIs that integrate with deep learning frameworks like PyTorch. TensorLy-Quantum aims to bridge this gap between the quantum computing and machine learning communities.
Methods
The authors developed TensorLy-Quantum as an extension of the existing TensorLy ecosystem. Key technical features include:
- Factorized Representations: Instead of storing a massive state vector, the library uses compact formats like Matrix Product States (MPS), also known as tensor-trains. This allows the library to represent complex states using significantly less memory by focusing on "relevant ranks."
- PyTorch Integration: The library adopts the PyTorch API, meaning quantum circuits are treated as standard
nn.Moduleobjects. This allows for end-to-end training where gradients flow from a quantum expectation value back through classical neural network layers. - Optimized Contractions: The library leverages
opt_einsumto find the most efficient mathematical path to perform tensor operations, minimizing both runtime and memory usage. - GPU Acceleration: By inheriting the backend flexibility of TensorLy, the library can run seamlessly on CPUs or NVIDIA GPUs.
Key Results and Performance
TensorLy-Quantum demonstrates massive scalability and efficiency across several benchmarks:
- Scalability: The library successfully simulated a 500-qubit Ising model with 5,000 gates. This represents a significant leap in the size of quantum systems that can be modeled on classical hardware.
- Speedups: In density operator experiments, TensorLy-Quantum outperformed QuTiP by two orders of magnitude on CPU and four orders of magnitude on GPU for partial trace operations. Additionally, the library showed a 20x speedup on GPU compared to CPU for large-scale tensor contractions.
- Optimization: The library held records for the largest single-GPU implementation of the MaxCut optimization algorithm at the time of its release.
Conclusion and Future Work
By treating quantum computing as a specialized layer in a broader machine learning architecture, TensorLy-Quantum enables researchers to simulate systems that were previously thought to be classically intractable. Future development will focus on automated state compression to maintain efficiency as entanglement grows, supporting more complex tensor network topologies like PEPS or MERA, and integrating noise modeling for more realistic simulations.
Summary updated