Skip to content

Quantum chemistry

xacc-vqe

Maintained by ornl-qci

DEPRECATED - Variational quantum eigensolver built on XACC

C++BSD-3-Clause
xacc-vqe illustration

Resource snapshot

Category

Quantum chemistry

Stars

14

Last pushed

Jul 9, 2019Updated 7y ago

Open issues

13

Quickstart

Get running in a few lines.

Quickstart
$ export PY_INC_DIR=$(python -c "import sysconfig; print(sysconfig.get_paths()['platinclude'])")
$ cmake .. -DXACC_DIR=$(python -m pyxacc -L) -DPYTHON_INCLUDE_DIR=$PY_INC_DIR
$ make install

What it is

xacc-vqe is maintained by ornl-qci and sits in the Quantum chemistry lane of the open-source quantum map.

DEPRECATED - Variational quantum eigensolver built on XACC It commonly appears alongside quantumlib-openfermion, projectq-framework-projectq in example workflows.

Last verified by Qtangl generator on May 27, 2026

Who it's for

Researchers, students, and developers exploring how quantum software is used for chemistry and electronic-structure problems.

What you can build or learn

  • See how chemistry problems are mapped into quantum-friendly representations.
  • Understand the workflow around Hamiltonians, ansatze, and measurement loops.
  • Compare beginner-friendly entry points into chemistry-focused quantum tooling.

Code samples

Examples from the repository.

D2 (examples/deuteron/python/d2.py)
import sys
import xacc
import xaccvqe
from xaccvqe import PauliOperator
xacc.Initialize(['--compiler','quil'])
#ibm = xacc.getAccelerator('ibm')
tnqvm = xacc.getAccelerator('tnqvm')
buffer = tnqvm.createBuffer('q', 2)
ham = PauliOperator(5.906709445) + \
        PauliOperator({0:'X',1:'X'}, -2.1433) + \
        PauliOperator({0:'Y',1:'Y'}, -2.1433) + \
        PauliOperator({0:'Z'}, .21829) + \
        PauliOperator({1:'Z'}, -6.125)
xacc.setOption('ibm-shots','8192')
#xacc.setOption('vqe-backend','vqe-bayesopt')
#xacc.setOption('bo-n-iter','20')
@xaccvqe.qpu.vqe(accelerator=tnqvm, observable=ham)
def ansatz(buffer, t0):
    X(0)
    Ry(t0, 1)
    CNOT(1, 0)
# Run VQE with given ansatz kernel
initAngle = .5
ansatz(buffer, initAngle)
print(buffer.listExtraInfoKeys())
print('Energy = ', buffer.getInformation('vqe-energy'))
print('Opt Angles = ', buffer.getInformation('vqe-angles'))
# Print all children names
#print (buffer.getChildrenNames())
# Get all children with the given name
#children = buffer.getChildren('Z0')
#for c in children:
    # Print any info the children may have 
#    print(c.listExtraInfoKeys(), c.getInformation('kernel'), c.getInformation('parameters'))
# Get all children that have 'parameters' information equal to [0.5]
#cs = buffer.getChildren('parameters',[0.5])
#for c in cs:
    # Print the kernel name and the parameter ([0.5]) and the exp value
#    print(c.getInformation('kernel'), c.getInformation('parameters'), c.getExpectationValueZ())
# Get all unique children parameters 
D3 (examples/deuteron/python/d3.py)
import xacc
import xaccvqe
from xaccvqe import PauliOperator
xacc.Initialize(['--compiler','quil'])
ibm = xacc.getAccelerator('local-ibm')
tnqvm = xacc.getAccelerator('tnqvm')
rigetti = xacc.getAccelerator('rigetti')
#buffer = ibm.createBuffer('q', 2)
buffer = tnqvm.createBuffer('q', 2)
h2 = PauliOperator(5.906709445) + \
        PauliOperator({0:'X',1:'X'}, -2.1433) + \
        PauliOperator({0:'Y',1:'Y'}, -2.1433) + \
        PauliOperator({0:'Z'}, .21829) + \
        PauliOperator({1:'Z'}, -6.125)
h3 = h2 + PauliOperator(9.625) + \
    PauliOperator({1:'X',2:'X'}, -3.913119) + \
    PauliOperator({1:'Y',2:'Y'}, -3.913119) + \
    PauliOperator({2:'Z'}, -9.625)
@xaccvqe.qpu.vqe(accelerator=tnqvm, observable=h3)
def ansatz(buffer, t0, t1):
    X(0)
    Ry(t0, 2)
    CNOT(2, 0)
    Ry(t1, 1)
    CNOT(0,1)
    Ry(-t1, 1)
    CNOT(0,1)
    CNOT(1,0)
# Run VQE with given ansatz kernel
initAngle = .2
ansatz(buffer, initAngle, initAngle)
print(buffer.listExtraInfoKeys())
print('Energy = ', buffer.getInformation('vqe-energy'))
print('Opt Angles = ', buffer.getInformation('vqe-angles'))
Test Many Dynamic Params (examples/py_decorators/test_many_dynamic_params.py)
import sys
import xacc
import xaccvqe
from xaccvqe import PauliOperator
import numpy as np
xacc.Initialize()
tnqvm = xacc.getAccelerator('tnqvm')
buffer = tnqvm.createBuffer('q', 2)
ham = PauliOperator(5.906709445) + \
        PauliOperator({0:'X',1:'X'}, -2.1433) + \
        PauliOperator({0:'Y',1:'Y'}, -2.1433) + \
        PauliOperator({0:'Z'}, .21829) + \
        PauliOperator({1:'Z'}, -6.125)
xacc.setOption('itensor-svd-cutoff','1e-16')
# Hardware Efficient Ansatz xacc kernel
@xaccvqe.qpu.energy(accelerator=tnqvm, observable=ham)
def ansatz(buffer, *args):
    xacc(hwe,layers=2,n_qubits=2,connectivity='[[0,1]]')
# XACC Kernels can display number of required nParameters
# and be persisted to qasm string
print(ansatz.nParameters()) 
print(ansatz.getFunction().toString('q'))
# Generate an initial random set of vqe params 
# of the correct number of parameters and execute
ansatz(buffer, *np.random.uniform(low=-np.pi,high=np.pi, size=(ansatz.nParameters(),)))
print(buffer.listExtraInfoKeys())
print('Energy = ', buffer.getInformation('vqe-energy'))
print('Opt Angles = ', buffer.getInformation('vqe-angles'))
xacc.Finalize()

Plays well with

License

BSD-3-Clause

SPDX identifier detected from the repository metadata or license files.

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.

~151 words · about 1 min readOpen on GitHub

Build Status

XACC Plugins and Programs for the Variational Quantum Eigensolver

Installation

With the XACC framework installed, users can choose a couple ways to install these plugins - using Python/Pip

$ python -m pip install --user .

or CMake and Make without Python support

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

or with Python support

$ export PY_INC_DIR=$(python -c "import sysconfig; print(sysconfig.get_paths()['platinclude'])")
$ cmake .. -DXACC_DIR=$(python -m pyxacc -L) -DPYTHON_INCLUDE_DIR=$PY_INC_DIR
$ make install

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

XACC-VQE is licensed - BSD 3-Clause.

Activity

Latest release

—

Watchers

2

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.

ProjectQ-Framework

FermiLib

FermiLib: Open source software for analyzing fermionic quantum simulation algorithms

PythonApache-2.0

90 stars · Updated 8y ago

cda-tum

mqt-dasqa

MQT DASQA - Designer for Superconducting Quantum Architectures

PythonMIT

21 stars · Updated 1y ago

quantumlib

OpenFermion

Python package for compiling and analyzing quantum algorithms to simulate electronic structures.

PythonApache-2.0Flagship

1,697 stars · Updated 3mo ago

Qiskit

qiskit-nature

Qiskit Nature is an open-source, quantum computing, framework for solving quantum mechanical natural science problems.

PythonApache-2.0

385 stars · Updated 3mo ago

eclipse-qrisp

Qrisp

Qrisp - The next generation of quantum algorithm development

PythonEPL-2.0

267 stars · Updated 3mo ago

aspuru-guzik-group

tequila

A High-Level Abstraction Framework for Quantum Algorithms

PythonMITFlagship

428 stars · Updated 3mo ago