TensorCircuit-NG is built upon tensornetwork engines, supporting for automatic differentiation, just-in-time compiling, hardware acceleration, vectorized parallelism and distributed training, providing unified infrastructures and interfaces for quantum programming. It can compose quantum circuits, neural networks and tensor networks seamlessly with high simulation efficiency and flexibility.
TensorCircuit-NG is built on top of modern machine learning frameworks: Jax, TensorFlow, and PyTorch. It is specifically suitable for large-scale simulations of quantum-classical hybrid paradigm and variational quantum algorithms in ideal (), noisy (), Clifford (), qudit (), approximate (), analog (), symmetric () and fermionic () cases. It also supports quantum hardware access and provides CPU/GPU/QPU hybrid deployment solutions.
Circuit
DMCircuit
StabilizerCircuit
QuditCircuit
MPSCircuit
AnalogCircuit
U1Circuit
FGSCircuit
TensorCircuit-NG is the technical successor to TensorCircuit, led and maintained by the original TensorCircuit development team. As a fully compatible drop-in replacement, TensorCircuit-NG delivers next-gen capabilities—including stabilizer/qudit/analog/symmetric circuit simulation and multi-node multi-GPU distributed simulation.
New companion project: We recently launched TenCirPauli, a Python-first, Rust-native companion that brings Pauli-native propagation and fixed-particle-number U(1) circuit execution to TensorCircuit-NG.
For more information on software usage, sota algorithm implementation and engineer paradigm demonstration, please refer to 200+ example scripts and 40+ tutorial notebooks. API docstrings and test cases in tests are also informative. One can also refer to AI-native docs for tensorcircuit-ng: Devin Deepwiki, Google Code Wiki, and Context7 MCP.
For beginners, please refer to quantum computing lectures with TC-NG to learn both quantum computing basics and representative usage of TensorCircuit-NG.
Agentic Quantum Research (Recommended)
TensorCircuit-NG is designed to give AI agents the context, rules, skills, and execution backends required for serious quantum research—not only code generation. To write TC-NG scripts and applications efficiently with AI coding agents (e.g., Claude Code, Cursor, CodeX), we strongly recommend working directly within the local tensorcircuit-ng repository rather than an empty folder.
In the ORBIT-Q benchmark, TensorCircuit-NG leads the evaluated quantum software frameworks on agent solve success and artifact runtime.
Rich Context: The 100+ scripts in examples/ and extensive test cases in tests/ provide essential references that significantly reduce AI hallucinations.
Built-in Rules: We provide a dedicated AGENTS.md file. It serves as the "handbook" (i.e. CLAUDE.md) for AI agents, defining coding standards and best practices to ensure the generated code is idiomatic.
Specialized Agentic Skills: The .agents/skills/ directory contains workflows to guide AI assistants on complex, multi-step tasks.
List of built-in agentic skills (click for details)
arxiv-reproduce: Translates published methods into standardized, runnable, and validated research artifacts.
tutorial-crafter: Transforms raw TC-NG scripts into comprehensive, narrative-driven Markdown or/and HTML educational tutorials.
demo-generator: Transforms TC-NG scripts into interactive, sleek, and high-performance Streamlit GUI applications.
code-reviewer: Autonomously reviews and refactors TC-NG code for mathematical correctness, JAX-native performance, and engineering rigor.
sanity-checker: Systematic audit and refactoring to reduce technical debt, improve abstractions, and ensure codebase health.
meta-explorer: High-intensity autonomous research agent for circuit architecture and optimization strategy discovery (VQE, QML, QAOA, etc.).
Recommended Workflow:
Clone the repository: git clone https://github.com/tensorcircuit/tensorcircuit-ng.git
Switch to a local playground branch: git checkout -b my-playground in case messing up with the original repository.
Open the repository folder in your AI IDE. And you are ready to start writing TC-NG-based scripts.
Now, enjoy exploring quantum research through natural language. By combining extreme performance with an autonomous, intent-driven AI workflow (via embedded .agents/skills/), TC-NG helps researchers move from a research question to implementation, exploration, optimization, validation, and a reusable scientific artifact.
Quick Demos
The following are some minimal demos.
Circuit construction:
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(allow_state=True, batch=1024, format="count_dict_bin"))
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(), [0])))
g = tc.backend.grad(forward)
g = tc.backend.jit(g)
theta = tc.array_to_tensor(1.0)
print(g(theta))
More highlight features for TensorCircuit (click for details)
Sparse Hamiltonian generation and expectation evaluation:
n = 6
pauli_structures = []
weights = []
for i in range(n):
pauli_structures.append(tc.quantum.xyz2ps({"z": [i, (i + 1) % n]}, n=n))
weights.append(1.0)
for i in range(n):
pauli_structures.append(tc.quantum.xyz2ps({"x": [i]}, n=n))
weights.append(-1.0)
h = tc.quantum.PauliStringSum2COO(pauli_structures, weights)
print(h)
# BCOO(complex64[64, 64], nse=448)
c = tc.Circuit(n)
c.h(range(n))
energy = tc.templates.measurements.operator_expectation(c, h)
# -6
API design: quantum for humans, less code, more power
Batteries included
Tons of amazing features and built in tools for research (click for details)
Support super large circuit simulation using tensor network engine.
Support noisy simulation with both Monte Carlo and density matrix (tensor network powered) modes.
Support stabilizer circuit simulation with stim backend.
Support approximate simulation with MPS-TEBD modes.
Support analog/digital hybrid simulation (time dependent Hamiltonian evolution, pulse level simulation) with neural ode modes.
Support Fermion Gaussian state simulation with expectation, entanglement, measurement, ground state, real and imaginary time evolution.
Support qudits simulation for tensor network and MPS approximation modes.
Support parallel quantum circuit evaluation across multiple GPUs and multiple hosts.
Highly customizable noise model with gate error and scalable readout error.
Support for non-unitary gate and post-selection simulation.
Support real quantum devices access from different providers.
Scalable readout error mitigation native to both bitstring and expectation level with automatic qubit mapping consideration.
Advanced quantum error mitigation methods and pipelines such as ZNE, DD, RC, etc.
Support MPS/MPO as representations for input states, quantum gates and observables to be measured.
Support vectorized parallelism on circuit inputs, circuit parameters, circuit structures, circuit measurements and these vectorization can be nested.
Gradients can be obtained with both automatic differenation and parameter shift (vmap accelerated) modes.
Machine learning interface/layer/model abstraction in both TensorFlow, PyTorch and Jax for both numerical simulation and real QPU experiments.
Support time evolution simulation with exact, ODE, Krylov, Trotter, Chebyshev, and fixed-schedule Taylor methods.
Support matrix-free spectral calculations using stochastic Lanczos quadrature (SLQ) and kernel polynomial methods (KPM) for density of states, thermodynamics, and response functions.
Support symmetry-enforced circuit simulation with U1Circuit for charge conservation.
Support Heisenberg picture-based Pauli propagation approximation simulation for circuits.
Circuit sampling supports both final state sampling and perfect sampling from tensor networks.
Light cone reduction support for local expectation calculation.
Highly customizable tensor network contraction path finder with opteinsum and cotengra interface.
Observables are supported in measurement, sparse matrix, dense matrix and MPO format.
Construct weighted Pauli-string Hamiltonians as sparse matrices or matrix-free operators for expectation and iterative spectral calculations.
Reusable common circuit/measurement/problem templates and patterns.
Jittable classical shadow infrastructures.
SOTA quantum algorithm and model implementations.
Support hybrid workflows and pipelines with CPU/GPU/QPU hardware from local/cloud/hpc resources using tf/torch/jax/cupy/numpy frameworks all at the same time.
Support agentic research workflows from literature-grounded implementation to validated scientific artifacts.
Support autonomous research discovery for circuit architectures and optimization strategies.
Fully AI-native ecosystem with built-in agentic skills and standardized development rules for AI assistants.
If this project helps in your research, please cite the two versions of software whitepapers to acknowledge the work put into the development of TensorCircuit-NG.
The Executable Research Hub is the literature-to-artifact layer of TensorCircuit-NG's agentic research stack. Each paper is packaged as a runnable, metadata-rich, and inspectable research artifact with its implementation, target figure, backend, scaling strategy, and validation context.
Adding one paper is the most approachable way to make a first contribution: pick a paper, follow the conventions in examples/reproduce_papers, and open a pull request.
Research and Applications
TensorCircuit-NG is a powerful framework for driving research and applications in quantum computing. Below are examples of published academic works (200+ in total) and open-source projects that utilize TensorCircuit and TensorCircuit-NG.
DQAS
For the application of Differentiable Quantum Architecture Search, see applications.
TenCirChem is an efficient and versatile quantum computation package for molecular properties. TenCirChem is based on TensorCircuit and is optimized for chemistry applications. The latest version TenCirChem-NG is open source and available at TenCirChem-NG.
For Rust-native Pauli propagation, fixed-particle-number U(1) circuit execution, Pauli algebra, structured Hamiltonians, measurement planning, symmetry reduction, restricted sectors, and a backend matrix-vector product interface for TensorCircuit-NG, see TenCirPauli. The project also provides structured operator algebra for fermionic, bosonic, qudit, Majorana, and hybrid systems, together with fermion-to-qubit mappings and chemistry interoperability.
EMQAOA-DARBO
For the numerical simulation and hardware experiments with error mitigation on QAOA, see the project repo.
For the simulation implementation of quantum states based on neural networks, tensor networs and quantum circuits using TensorCircuit-NG, see the project repo.
For the simulation code for the work "superior resilience to poisoning and amenability to unlearning in quantum machine learning", see the project repo.
The ORBIT-Q benchmark evaluates autonomous agents on scientific quantum programming across framework capability, agent configuration, correctness, and artifact efficiency. In its reported framework-axis comparison, TensorCircuit-NG leads the evaluated frameworks with the highest agent solve success rate and the lowest artifact-runtime slowdown. See the benchmark repository and accompanying paper.
PennyLane is a cross-platform Python library for quantum computing, quantum machine learning, and quantum chemistry. Train a quantum computer the same way as a neural network.