Skip to content

Library structure

Scott Xu edited this page Sep 29, 2021 · 16 revisions

This page provides an overview of the staq library and the overall directory structure.

Repository

Directory Description
include The main source code directory
libs External libraries
qasm Example openQASM source files
qasmtools Library which defines QASM syntax trees and a parser
qpus Example device representation files
staq The main staq compiler
tools Holds the staq tool suite
unit_tests Unit testing via Google Test/Mock (source included)

Source

Directory Description
include/gates Holds representations & tools for working with particular gate sets
    .../channel.hpp Tools for working with Clifford gates in the channel representation -- that is, Clifford gates represented as permutations of the Pauli group and arbitrary Pauli-axis rotations as sums of Paulis
include/mapping Classes & algorithms for mapping to physical/constrained hardware
include/optimization Optimizations on QASM ASTs
    .../rotation_folding.hpp An optimization to merge or cancel non-Clifford rotation gates (e.g., t, tdg, rx, ...) when possible
    .../simplify.hpp A basic adjacent gate cancellation optimization
include/output Transpilers from QASM into other languages
include/synthesis Algorithms for synthesizing various types of circuits
    .../linear_reversible.hpp Contains algorithms for synthesizing CX circuits from permutation matrices, either unconstrained (Gaussian elimination) and constrained by physical architectures (Steiner tree based)
    .../cnot_dihedral.hpp Contains algorithms for synthesizing CX+rz circuits from their Fourier expansions. Implements both unconstrained and topologically constrained versions
    .../logic_synthesis.hpp Implements synthesis of quantum circuits from classical Verilog files. Uses the EPFL tools & implementation of LUT-based Hierarchical Reversible Logic Synthesis
include/tools Contains miscellaneous tools for working with QASM ASTs
    .../resource_estimator.hpp Computes the gate/depth/qubit counts of a circuit
include/transformations Utility AST transformations
    .../desugar.hpp Transformation to expand all gates applied to registers
    .../inline.hpp Configurable AST inliner. Can be used to inline only certain gates
    .../oracle_synthesizer.hpp Replaces oracle declarations with synthesized circuits
    .../substitution.hpp Generic substitution routines. Includes simple variable substitution, as well as a powerful register substitution framework

Mapping

Directory Description
include/mapping/device.hpp Defines the physical device class, as well as some example devices
include/mapping/layout Algorithms and tools for generating an initial layout of a circuit onto a device
    .../basic.hpp Assigns physical qubits in order to logical qubits
    .../bestfit.hpp Assigns physical qubits so that the highest fidelity couplings are mapped to the logical qubits with the most CX gates
    .../eager.hpp Assigns physical qubits on a 'by-need' basis -- that is, assigns a valid physically coupled pair of qubits whenever an unmapped CX gate is found
include/mapping/mapping Algorithms and tools for mapping CX between uncoupled qubits
    .../swap.hpp Swaps qubits along a shortest path from the CX control to target
    .../steiner.hpp Re-synthesizes the circuit using a physically constrained version of Gray-synth

Included libs

Directory Description
CLI Parsing command line options. EPFL dependency
caterpillar EPFL library for quantum circuit synthesis
easy EPFL library for ESOP manipulation
ez EPFL dependency
fmt Output formatting. EPFL dependency
glucose SAT solver. EPFL dependency
kitty EPFL truth table library
lorina EPFL library for parsing of classical logic formats
mockturtle EPFL library for logic network representation
nlohmann JSON library for C++
pthreadwin32 Windows pthread compatibility. Glucose dependency.
rang Terminal colours. EPFL dependency
sparsepp Hash map library. EPFL dependency
tweedledum EPFL library for general purpose quantum compilation
zlib Windows zlib compatibility. Glucose dependency.
Clone this wiki locally