Quantum circuits on top of tensor network
English | 简体中文
TensorCircuit is the next generation of quantum circuit simulators with support for automatic differentiation, just-in-time compiling, hardware acceleration, and vectorized parallelism.
TensorCircuit is built on top of modern machine learning frameworks and is machine learning backend agnostic. It is specifically suitable for highly efficient simulations of quantum-classical hybrid paradigm and variational quantum algorithms.
Please begin with Quick Start.
The following are some minimal demos.
- Circuit manipulation:
import tensorcircuit as tc c = tc.Circuit(2) c.H(0) c.CNOT(0,1) c.rx(1, theta=0.2) print(c.wavefunction()) print(c.expectation_ps(z=[0, 1])) print(c.sample())
- Runtime behavior customization:
tc.set_backend("tensorflow") tc.set_dtype("complex128") tc.set_contractor("greedy")
- Automatic differentiations with jit:
def forward(theta): c = tc.Circuit(2) c.R(0, theta=theta, alpha=0.5, phi=0.8) return tc.backend.real(c.expectation((tc.gates.z(), ))) g = tc.backend.grad(forward) g = tc.backend.jit(g) theta = tc.array_to_tensor(1.0) print(g(theta))
The package is purely written in Python and can be obtained via pip as:
pip install tensorcircuit
And we recommend you install this package with tensorflow also installed as:
pip install tensorcircuit[tensorflow]
Other optional dependencies include
For nightly build of tensorcircuit with new features, try:
pip uninstall tensorcircuit pip install tensorcircuit-nightly
We also have Docker support.
Tensor network simulation engine based
JIT, AD, vectorized parallelism compatible, GPU support
Time: 10 to 10^6 times acceleration compared to tfq or qiskit
Space: 600+ qubits 1D VQE workflow (converged energy inaccuracy: < 1%)
Flexibility: customized contraction, multiple ML backend/interface choices, multiple dtype precisions
API design: quantum for humans, less code, more power
If this project helps in your research, please cite our software whitepaper:
which is also a good introduction for the software.
For contribution guidelines and notes, see CONTRIBUTING.
Researches and Applications
VQEX - MBL
Release history Release notifications | RSS feed
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Hashes for tensorcircuit-0.3.1-py3-none-any.whl