Skip to content

Simulators

tnqvm

Maintained by ornl-qci

Tensor Network QPU Simulator for Eclipse XACC

C++
tnqvm illustration

Resource snapshot

Category

Simulators

Stars

44

Last pushed

Mar 5, 2025Updated 1y ago

Open issues

6

What it is

tnqvm is maintained by ornl-qci and sits in the Simulators lane of the open-source quantum map.

Tensor Network QPU Simulator for Eclipse XACC

Last verified by Qtangl generator on May 27, 2026

Who it's for

Developers and researchers who need to test ideas locally before running on hardware or who want to compare simulation strategies.

What you can build or learn

  • Benchmark how different simulation methods trade accuracy for runtime.
  • Inspect circuit behavior, noise assumptions, or state evolution offline.
  • Choose the right simulator for a debugging, teaching, or research workflow.

Code samples

Examples from the repository.

Hello-Checkpoint (examples/plos_one_experiments/experiments/.ipynb_checkpoints/hello-checkpoint.py)
import random
import numpy as np
import pyxacc as xacc
def write_qasm(rounds, nQ):
    """"
    Parameters
    ----------
    nQ: int, number of qubits
    entanglers: tuple of tuples whose length determines the circuit depth
                sub-tuples enumerates CNOT's acting at a given depth level
    Returns
    -------
    param_counter: number of variational parameters in circuit
    """
    file_name = "Supremacy_1D_{0}_qubits_{1}_rounds.qasm".format(nQ, rounds)
    file = open(file_name, "w")
    file.write("__qpu__ f(AcceleratorBuffer b) {\n")
    local_gates = ('X', 'Y', 'Z', 'RX', 'RY', 'RZ', 'H')
    if nQ%2==0: # even
        evens = tuple((i, i+1) for i in range(nQ) if i%2==0)
        odds = tuple((i, i+1) for i in range(nQ) if i%2==1)
    if nQ%2==1: # odd
        evens = tuple((i, i+1) for i in range(nQ-2) if i%2==0)
        odds = tuple((i, i+1) for i in range(nQ) if i%2==1)
    for i in range(nQ): 
        file.write('H ' + str(i) + '\n')  # initial Hadamards
    # random gates
    for i in range(rounds):
        for j in range(nQ): 
            gate = random.choice(local_gates)
            if 'R' in gate:
                angle = str(np.random.uniform(0,np.pi));
                file.write('{} '.format(str(gate) + '('+str(angle)+')') + str(j) + '\n')
            else:
                file.write('{} '.format(str(gate)) + str(j) + ' \n')
        for e in evens:
            file.write('CNOT {0} {1}\n'.format(*e))
        for e in odds:
            file.write('CNOT {0} {1}\n'.format(*e))
    file.write("}")
Untitled-Checkpoint (examples/plos_one_experiments/experiments/.ipynb_checkpoints/Untitled-checkpoint.ipynb)
import numpy as np

r2 = np.genfromtxt('profile_tnqvm_2_rounds.csv', delimiter=',', names=['r','n','m'])
r4 = np.genfromtxt('profile_tnqvm_4_rounds.csv', delimiter=',', names=['r','n','m'])
r6 = np.genfromtxt('profile_tnqvm_6_rounds.csv', delimiter=',', names=['r','n','m'])
r8 = np.genfromtxt('profile_tnqvm_8_rounds.csv', delimiter=',', names=['r','n','m'])
r10 = np.genfromtxt('profile_tnqvm_10_rounds.csv', delimiter=',', names=['r','n','m'])

import matplotlib.pyplot as plt
%matplotlib inline
plt.figure(figsize=(15,10))
plt.rc('font', family='serif', serif='cm10')
plt.rc('text', usetex=True)
plt.rcParams['text.latex.preamble'] = [r'\boldmath']
plt.rc('xtick', labelsize=20)
plt.rc('ytick', labelsize=20)

plt.rc('lines', lw=2)
plt.rc('axes', linewidth=2)
plt.rcParams["font.weight"] = "bold"
plt.rcParams["axes.labelweight"] = "bold"
plt.xlabel(r'Number of Qubits', fontsize=20)
plt.ylabel(r'Memory (MB)', fontsize=20)
plt.semilogy(r2['n'], r2['m'], '-', color='b', label='2 Rounds')
plt.semilogy(r4['n'], r4['m'], '-', color='r', label='4 Rounds')
plt.semilogy(r6['n'], r6['m'], '-', color='g', label='6 Rounds')
plt.semilogy(r8['n'], r8['m'], '-', color='m', label='8 Rounds')
plt.semilogy(r10['n'], r10['m'], '-', color='y', label='10 Rounds')
plt.legend()
#plt.savefig("2ndquant_2x2_2qbit_ibmqx5_theta_sweep_energy.pdf",bbox_inches='tight')
plt.show()
Profile Tnqvm (examples/plos_one_experiments/experiments/profile_tnqvm.py)
import random
import numpy as np
import pyxacc as xacc
import argparse
import sys
def parse_args(args):
    parser = argparse.ArgumentParser()
    parser.add_argument('-n',type=int,required=True)
    parser.add_argument('-r',type=int,required=True)
    opts = parser.parse_args(args)
    return opts
def write_qasm(rounds, nQ):
    """"
    Parameters
    ----------
    nQ: int, number of qubits
    entanglers: tuple of tuples whose length determines the circuit depth
                sub-tuples enumerates CNOT's acting at a given depth level
    Returns
    -------
    param_counter: number of variational parameters in circuit
    """
    file_name = "Supremacy_1D_{0}_qubits_{1}_rounds.qasm".format(nQ, rounds)
    file = open(file_name, "w")
    file.write("__qpu__ f(AcceleratorBuffer b) {\n")
    local_gates = ('X', 'Y', 'Z', 'RX', 'RY', 'RZ', 'H')
    if nQ%2==0: # even
        evens = tuple((i, i+1) for i in range(nQ) if i%2==0)
        odds = tuple((i, i+1) for i in range(nQ-1) if i%2==1)
    if nQ%2==1: # odd
        evens = tuple((i, i+1) for i in range(nQ-2) if i%2==0)
        odds = tuple((i, i+1) for i in range(nQ) if i%2==1)
    for i in range(nQ): 
        file.write('H ' + str(i) + '\n')  # initial Hadamards
    # random gates
    for i in range(rounds):
        for j in range(nQ): 
            gate = random.choice(local_gates)
            if 'R' in gate:
                angle = str(np.random.uniform(0,np.pi));

Repository README

Preview from the project README.

Rendered as Markdown inside a scrollable preview. Long READMEs stay contained; expand or open on GitHub for the full document.

~351 words · about 2 min readOpen on GitHub
BranchStatus
masterLinux CI

TNQVM Tensor Network XACC Accelerator

These plugins for XACC provide an Accelerator implementation that leverages tensor network theory to simulate quantum circuits.

Installation

With the XACC framework installed, run the following

$ mkdir build && cd build
$ cmake .. -DXACC_DIR=$HOME/.xacc (or wherever you installed XACC)
$ make install

TNQVM can be built with ExaTN support, providing a tensor network processing backend that scales on Summit-like architectures. To enable this support, first follow the ExaTN README to build and install ExaTN. Now configure TNQVM with CMake and build/install

$ mkdir build && cd build
$ cmake .. -DXACC_DIR=$HOME/.xacc -DEXATN_DIR=$HOME/.exatn
$ make install

To switch tensor processing backends use

auto qpu = xacc::getAccelerator("tnqvm", {std::make_pair("tnqvm-visitor", "exatn")});

or in Python

qpu = xacc.getAccelerator('tnqvm', {'tnqvm-visitor':'exatn'})

MPI Execution

TNQVM's exatn-mps visitor can support multi-node execution via MPI.

Prerequisites: ExaTN is built with MPI enabled, i.e., setting MPI_LIB and MPI_ROOT_DIR when configuring the ExaTN build.

To enable MPI in TNQVM, add -DTNQVM_MPI_ENABLED=TRUE to CMake along with other configuration variables.

A simulation executable which uses the exatn-mps visitor, e.g. via

auto qpu = xacc::getAccelerator("tnqvm", { std::make_pair("tnqvm-visitor", "exatn-mps")});

can be executed with MPI using mpiexec -np <number of processes> <executable>.

Documentation

Questions, Bug Reporting, and Issue Tracking

Questions, bug reporting and issue tracking are provided by GitHub. Please report all bugs by creating a new issue with the bug tag. You can ask questions by creating a new issue with the question tag.

License

TNQVM is licensed - BSD 3-Clause.

Cite TNQVM

If you use TNQVM in your research, please use the following citation

@article{tnqvm,
    author = {McCaskey, Alexander AND Dumitrescu, Eugene AND Chen, Mengsu AND Lyakh, Dmitry AND Humble, Travis},
    journal = {PLOS ONE},
    publisher = {Public Library of Science},
    title = {Validating quantum-classical programming models with tensor network simulations},
    year = {2018},
    month = {12},
    volume = {13},
    url = {https://doi.org/10.1371/journal.pone.0206704},
    pages = {1-19},
    number = {12},
    doi = {10.1371/journal.pone.0206704}
}
Read on GitHub

Activity

Latest release

—

Watchers

5

Python support

—

Learn digest

Get monthly updates when library entries change.

Monthly digest: new library entries, updated flagships, and one editorial pick.

Related resources

Keep exploring nearby tools.

qosf

os_quantum_software

Curated list of open-source quantum software projects.

CC0-1.0

2,105 stars · Updated 4mo ago

BBN-Q

PySimulator

Python with C++ Backend Simulator for Superconducting Circuits QIP

PythonApache-2.0

8 stars · Updated 12y ago

QISKit

qiskit-tutorial

A collection of Jupyter notebooks showing how to use the Qiskit SDK

Jupyter NotebookApache-2.0Archive

2,522 stars · Updated 3y ago

0tt3r

QuaC

Time Dependent Open Quantum Systems Solver written by Matthew Otten (mjotten@wisc.edu)

CMIT

30 stars · Updated 2y ago

aniabrown

QuEST

A multithreaded, distributed, GPU-accelerated simulator of quantum computers

C++MITArchive

473 stars · Updated 3mo ago

adamisntdead

QuSimPy

A Multi-Qubit Ideal Quantum Computer Simulator

PythonAGPL-3.0

724 stars · Updated 5y ago