TensorCircuit Next Generation¶
Welcome and congratulations! You have found TensorCircuit: the Next Generation. 👏
Introduction¶
TensorCircuit-NG is an industrial-grade, open-source high-performance quantum software framework in Python. It is designed for researchers and engineers who demand Speed, Flexibility, and Elegance.
Intuitive API that feels like natural quantum physics. Focus on your research, not the boilerplate.
Achieve 10-100x GPU speedup. Powered by JIT compilation and optimized tensor engines.
Native integration with JAX, TensorFlow, and PyTorch. Seamlessly combine AD with quantum kernels.
State-of-the-art support for Noisy, Analog, Approximate and Stabilizer simulations.
Run your code anywhere: from local CPUs to distributed GPUs/TPUs and QPU providers via a unified interface.
Committed to stability and performance. Long-term support and proven by extensive research and industrial applications.
Important
Please cite our published whitepaper when using TensorCircuit or TensorCircuit-NG in your research. The bibtex information is provided by tc.cite().
Note
TensorCircuit-NG is the active continuation of TensorCircuit project.
We recommend upgrading to TensorCircuit-NG for the latest features and improvements.
You can upgrade by running the following command:
pip uninstall tensorcircuit && pip install tensorcircuit-ng
Get Started in Seconds¶
Install with one line:
pip install tensorcircuit-ng
Simulate your first circuit:
import tensorcircuit as tc
c = tc.Circuit(2)
c.h(0)
c.cnot(0, 1)
print(c.state()) # Ideal Bell state: [0.707, 0, 0, 0.707]
print(c.expectation_ps(z=[0, 1])) # ZZ expectation: 1.0
Useful Links¶
TensorCircuit is created and now maintained as TensorCircuit-NG by Shi-Xin Zhang.
The current core authors of TensorCircuit-NG are Shi-Xin Zhang and Yu-Qin Chen. We also thank contributions from the open source community.
If you have any further questions or collaboration ideas, please use the issue tracker or forum below, or send email to shixinzhang#iphy.ac.cn
GitHub
pip install tensorcircuit-ng
Readthedocs
Quantum journal
GitHub Issues
GitHub Discussions
docker pull
Research using TC
Unified Quantum Programming¶
TensorCircuit-NG is building the future of unified quantum computing infrastructures.
JAX, TensorFlow, PyTorch, Numpy, Cupy
CPU, GPU, and TPU support
QPUs from major vendors
Local, Cloud, and HPC environments
Numerical sim and hardware experiments
Ideal, Noisy, Analog, and Stabilizer
Qiskit, OpenQASM, Cirq, and IR
Neural Nets, Tensor Nets, and Circuits
Reference Documentation¶
The following documentation sections briefly introduce TensorCircuit-NG to the users and developpers.
- Quick Start
- Agentic Development
- Advanced Usage
- MPS Simulator
- Stacked gates syntax
- Split Two-qubit Gates
- Analog circuit simulation
- Time Evolution
- Jitted Function Save/Load
- Parameterized Measurements
- Sparse Matrix
- Hamiltonian Matrix Building
- Stabilizer Circuit Simulator
- Fermion Gaussian State Simulator
- Randoms, Jit, Backend Agnostic, and Their Interplay
- Frequently Asked Questions
- What is the relation between TensorCircuit and TensorCircuit-NG?
- How can I run TensorCircuit-NG on GPU?
- When should I use GPU?
- How can I use multiple GPUs?
- When should I jit the function?
- General tips of good performance for circuit simulation?
- Which ML framework backend should I use?
- What is the counterpart of
QuantumLayerfor PyTorch and Jax backend? - When do I need to customize the contractor and how?
- Is there some API less cumbersome than
expectationfor Pauli string? - How to efficiently evaluate expectations for large systems?
- Can I apply quantum operation based on previous classical measurement results?
- How to understand the difference between different measurement methods for
Circuit? - How to understand difference between
tc.array_to_tensorandtc.backend.convert_to_tensor? - How to arrange the circuit gate placement in the visualization from
c.tex()? - How many different formats for the circuit sample results?
- How to get the entanglement entropy from the circuit output?
- What is the long-term support (LTS) commitment for TensorCircuit-NG?
- TensorCircuit: The Sharp Bits 🔪
- TensorCircuit-NG: What is inside?
- Guide for Contributors
Tutorials¶
The following documentation sections include integrated examples in the form of Jupyter Notebook.
- Jupyter Tutorials
- Circuit Basics
- Qudit Circuit Basics
- Quantum Approximation Optimization Algorithm (QAOA)
- Optimizing QAOA by Bayesian Optimization (BO)
- Quantum Approximation Optimization Algorithm (QAOA) for Not-all-equal 3-satisfiability (NAE3SAT)
- Quantum Dropout for QAOA
- VQE on 1D TFIM
- QML on MNIST Classification
- QML in PyTorch
- Quantum Machine Learning for Classification Task
- Variational Quantum Eigensolver (VQE) on Molecules
- VQE on 1D TFIM with Different Hamiltonian Representation
- MERA
- Gradient Evaluation Efficiency Comparison
- The usage of contractor
- Simulation of Clifford Circuits
- Fermion Gaussian State (FGS) Simulator
- Operator spreading
- Optimization vs. expressibility of the circuit
- Probing Many-body Localization by Excited-state VQE
- Differentiable Quantum Architecture Search
- Barren Plateaus
- Solving QUBO Problem using QAOA
- Lattice Geometries in TensorCircuit
- Further Reading and Resources
- Portfolio Optimization
- Solving the Ground State of Hamiltonian by Imaginary-time Evolution
- Classical Shadows in Pauli Basis
- Support Vector Classification with SKLearn
- Distributed Circuit Simulation and TensorNetwork Contraction
- Demo on TensorCircuit SDK for Tencent Quantum Cloud
- Whitepaper Tutorials
API References¶
- tensorcircuit
- tensorcircuit.about
- tensorcircuit.abstractcircuit
- tensorcircuit.analogcircuit
- tensorcircuit.applications
- tensorcircuit.backends
- tensorcircuit.basecircuit
- tensorcircuit.channels
- tensorcircuit.circuit
- tensorcircuit.cloud
- tensorcircuit.compiler
- tensorcircuit.cons
- tensorcircuit.densitymatrix
- tensorcircuit.experimental
- tensorcircuit.fgs
- tensorcircuit.gates
- tensorcircuit.interfaces
- tensorcircuit.keras
- tensorcircuit.mps_base
- tensorcircuit.mpscircuit
- tensorcircuit.noisemodel
- tensorcircuit.pauliprop
- tensorcircuit.quantum
- tensorcircuit.quditcircuit
- tensorcircuit.quditgates
- tensorcircuit.results
- tensorcircuit.shadows
- tensorcircuit.simplify
- tensorcircuit.stabilizercircuit
- tensorcircuit.symbolcircuit
- tensorcircuit.symbolgates
- tensorcircuit.templates
- tensorcircuit.timeevol
- tensorcircuit.torchnn
- tensorcircuit.translation
- tensorcircuit.u1circuit
- tensorcircuit.utils
- tensorcircuit.vis
- tensorcircuit.zx
Indices and Tables¶
Join the Community¶
We are always looking for contributors and collaborators!
Check out our GitHub Discussions for questions and show-and-tell.
Report bugs or request features via GitHub Issues.
Star the repository to stay updated! ⭐