Skip to content

General-purpose SDKs

quantumflow

Maintained by rigetti

>Notice: This is research code that will not necessarily be maintained to >support further releases of Forest and other Rigetti Software.

PythonApache-2.0
quantumflow illustration

Resource snapshot

Category

General-purpose SDKs

Stars

98

Last pushed

Jun 3, 2019Updated 7y ago

Open issues

0

What it is

quantumflow is maintained by rigetti and sits in the Compilers and languages lane of the open-source quantum map.

>Notice: This is research code that will not necessarily be maintained to >support further releases of Forest and other Rigetti Software.

Last verified by Qtangl generator on May 27, 2026

Who it's for

Developers who want to understand the representations and compilers that sit between high-level code and runnable circuits.

What you can build or learn

  • Compare IRs, DSLs, transpilers, and compiler assumptions across ecosystems.
  • Understand how high-level code becomes something a backend can execute.
  • Spot tools that matter when interoperability and compilation quality are important.

Code samples

Examples from the repository.

Circuit Identities (examples/circuit_identities.ipynb)
circ0 = qf.Circuit()
circ0 += qf.Z(0)            # Z gate on qubit 0
circ0 += qf.CNOT(0, 1)      # Controlled not gate: control is qubit 0, target is qubit 1
qf.circuit_to_image(circ0)  # Convert circuit to LaTex, then to PNG image
Circuit Identities (examples/circuit_identities.py)
#!/usr/bin/env python
#
# This source code is licensed under the Apache License, Version 2.0 found in
# the LICENSE.txt file in the root directory of this source tree.
"""A collection of useful circuit identities"""
from itertools import zip_longest
import numpy as np
from quantumflow import (
    I, H, X, Y, Z, CNOT, CZ, SWAP, ISWAP, CANONICAL, XX, YY, ZZ, S,
    CCNOT, RZ, Circuit, ccnot_circuit, gates_close, RX, CPHASE, TZ,
    CPHASE00, CPHASE10, CPHASE01)
def identities():
    """ Return a list of circuit identities, each consisting of a name, and
    two equivalent Circuits."""
    circuit_identities = []
    # Pick random parameter
    theta = np.pi * np.random.uniform()
    # Single qubit gate identities
    name = "Hadamard is own inverse"
    circ0 = Circuit([H(0), H(0)])
    circ1 = Circuit([I(0)])
    circuit_identities.append([name, circ0, circ1])
    name = "Hadamards convert X to Z"
    circ0 = Circuit([H(0), X(0), H(0)])
    circ1 = Circuit([Z(0)])
    circuit_identities.append([name, circ0, circ1])
    name = "Hadamards convert Z to X"
    circ0 = Circuit([H(0), Z(0), H(0)])
    circ1 = Circuit([X(0)])
    circuit_identities.append([name, circ0, circ1])
    name = "S sandwich converts X to Y"
    circ0 = Circuit([S(0).H, X(0), S(0)])
    circ1 = Circuit([Y(0)])
    circuit_identities.append([name, circ0, circ1])
    name = "S sandwich converts Y to X"
    circ0 = Circuit([S(0), Y(0), S(0).H])
    circ1 = Circuit([X(0)])
    circuit_identities.append([name, circ0, circ1])
    name = "Hadamards convert RZ to RX"
    circ0 = Circuit([H(0), RZ(theta, 0), H(0)])
Circuit Visulizations (examples/circuit_visulizations.py)
#!/usr/bin/env python
#
# This source code is licensed under the Apache License, Version 2.0 found in
# the LICENSE.txt file in the root directory of this source tree.
"""
QuantumFlow: Example visualizations of Circuits using LaTeX.
Requires external dependencies `pdflatex` and `poppler`.
"""
import shutil
import sys
import quantumflow as qf
from pyquil.quil import Program
from pyquil.gates import Z, CNOT, CZ, CCNOT
if shutil.which('pdflatex') is None:
    print('Failed: External dependency `pdflatex` not found.')
    sys.exit()
if shutil.which('pdftocairo') is None:
    print('Failed: External dependency `pdftocairo` not found. '
          'Install `poppler`.')
    sys.exit()
# Display Bell state preparation
qf.circuit_to_image(qf.ghz_circuit([0, 1])).show()
# 4-qubit GHZ state preparation
qf.circuit_to_image(qf.ghz_circuit([0, 1, 2, 3])).show()
# 4-qubit ripple add
circ = qf.addition_circuit(['a[0]', 'a[1]', 'a[2]', 'a[3]'],
                           ['b[0]', 'b[1]', 'b[2]', 'b[3]'],
                           ['cin', 'cout'])
order = ['cin', 'a[0]', 'b[0]', 'a[1]', 'b[1]', 'a[2]', 'b[2]', 'a[3]',
         'b[3]', 'cout']
latex = qf.circuit_to_latex(circ, order)
img = qf.render_latex(latex)
img.show()
# Visualize pyquil protoquil programs
prog = Program()
prog = prog.inst(Z(0))
prog = prog.inst(CNOT(0, 1))
prog = prog.inst(CZ(0, 1))
prog = prog.inst(CCNOT(0, 1, 2))
qf.forest.pyquil_to_image(prog).show()

License

Apache-2.0

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.

~146 words · about 1 min readOpen on GitHub

Notice: This is research code that will not necessarily be maintained to support further releases of Forest and other Rigetti Software. We welcome bug reports and PRs but make no guarantee about fixes or responses.

QuantumFlow: A Quantum Algorithms Development Toolkit

Build Status

Installation for development

It is easiest to install QuantumFlow's requirements using conda.

git clone https://github.com/rigetti/quantumflow.git
cd quantumflow
conda install -c conda-forge --file requirements.txt
pip install -e .

You can also install with pip. However some of the requirements are tricky to install (notably tensorflow & cvxpy), and (probably) not everything in QuantumFlow will work correctly.

git clone https://github.com/rigetti/quantumflow.git
cd quantumflow
pip install -r requirements.txt
pip install -e .

Example

Train the QAOA algorithm, with back-propagation gradient descent, to perform MAXCUT on a randomly chosen 6 node graph.

./examples/qaoa_maxcut.py --verbose --steps 5 --nodes 6 random

Activity

Latest release

—

Watchers

13

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.

quantumlib

Cirq

Python framework for creating, editing, and running Noisy Intermediate-Scale Quantum (NISQ) circuits.

PythonApache-2.0Flagship

4,971 stars · Updated 3mo ago

XanaduAI

pennylane

PennyLane is an open-source quantum software platform for quantum computing, quantum machine learning, and quantum chemistry.

PythonApache-2.0FlagshipQtangl relevant

3,229 stars · Updated 3mo ago

QISKit

qiskit

Qiskit is an open-source SDK for working with quantum computers at the level of extended quantum circuits, operators, and primitives.

PythonApache-2.0FlagshipQtangl relevant

7,412 stars · Updated 3mo ago

Qiskit

qiskit-terra

Qiskit is an open-source SDK for working with quantum computers at the level of extended quantum circuits, operators, and primitives.

PythonApache-2.0

7,412 stars · Updated 3mo ago

Microsoft

QuantumKatas

Tutorials and programming exercises for learning Q# and quantum computing

Jupyter NotebookMITFlagshipArchive

4,862 stars · Updated 2y ago

QuantumBFS

Yao.jl

Extensible, Efficient Quantum Algorithm Design for Humans.

JuliaApache-2.0Flagship

1,032 stars · Updated 3mo ago