Skip to main content

JKQ QCEC - A JKQ tool for Quantum Circuit Equivalence Checking

Project description

Build Status codecov License: MIT arXiv arXiv toolset: JKQ

JKQ QCEC - A JKQ tool for Quantum Circuit Equivalence Checking

A JKQ tool for quantum circuit equivalence checking by the Institute for Integrated Circuits at the Johannes Kepler University Linz based on methods proposed in [1], [2].

[1] L. Burgholzer and R. Wille. "Advanced Equivalence Checking for Quantum Circuits". IEEE Transactions on Computer Aided Design of Integrated Circuits and Systems (TCAD), 2021 (pre-print arXiv:2004.08420)

[2] L. Burgholzer, R. Raymond, and R. Wille. "Verifying Results of the IBM Qiskit Quantum Circuit Compilation Flow". In International Conference on Quantum Computing and Engineering (QCE), 2020 (pre-print arXiv:2009.02376)

This tool can be used for checking the equivalence of two quantum circuits provided in any of the following formats:

with the following available methods:

  • Reference - Construct and compare the DD for both circuits [1, Section III.B],
  • G \rightarrow \mathbb{I} \leftarrow G' - Starting from the identity I, either apply gates from G or (inverted) gates from G' according to one of the following strategies [1, Section IV.A]
    • Naive - Alternate between applications of G and G' [1, Section V.A],
    • Proportional - Proportionally apply gates according to the gate count ratio of G and G' [1, Section V.B],
    • Lookahead - Always apply the gate yielding the smaller DD [1, Section V.C],
  • Simulation - Conduct simulation runs to prove non-equivalence or give a strong indication of equivalence [1, Section IV.B],
  • Verification of compilation results - A dedicated scheme for verifying results of the IBM Qiskit Compilation Flow explicitly exploiting certain knowledge about the compilation process. [2]

The tool builds upon our decision diagram (DD) package as well as our quantum functionality representation (QFR). For more information, please visit iic.jku.at/eda/research/quantum_verification. If you want to visually explore decision diagrams for quantum computing, check out our installation-free web-tool JKQ DDVis.

If you have any questions, feel free to contact us via iic-quantum@jku.at or by creating an issue on GitHub.

Usage

This tool can either be used as a standalone executable with command-line interface, or as a library for the incorporation in other projects. Python bindings are available since version 1.4.5.

  • The standalone executable is launched in the following way:

    qcec_app <PATH_TO_FILE_1> <PATH_TO_FILE_2> (--method <method>)
    

    where <method> is one of

    • reference
    • naive
    • proportional (default)
    • lookahead
    • simulation
    • compilationflow

    An optional parameter --tol e allows to specify the numerical tolerance e (default: 1e-13) used during the computation.
    The simulation method has two optional parameters --nsims r and --fid F, controlling the maximum number of simulations r (default: 16) and the considered fidelity limit F (default 0.999), respectively.

    The executable performs the equivalence check and prints its result to the standard output. Per default, this produces JSON formatted output. Additional statistics (e.g., verification time, maximum number of nodes, required simulations, etc.) can be obtained by additionally providing the --ps flag. If the --csv flag is present, a CSV entry according to the following header is printed

    filename1;nqubits1;ngates1;filename2;nqubits2;ngates2;expectedEquivalent;equivalent;method;time;maxActive;nsims
    
  • Internally the library works in the following way

    • Import both input files into a qc::QuantumComputation object
      std::string file1 = "<PATH_TO_FILE_1>";
      qc::QuantumComputation qc1(file1);
      
      std::string file2 = "<PATH_TO_FILE_2>";
      qc::QuantumComputation qc2(file2);
      
    • Instantiate an ec::EquivalenceChecker object with both circuits
      ec::Method method = ec::{ Reference | Naive | Proportional | Lookahead };
      auto eq = ec::ImprovedDDEquivalenceChecker(qc1, qc2, method);
      
      or
      auto eq = ec::PowerOfSimulationEquivalenceChecker(qc1, qc2);
      
      or
      auto eq = ec::CompilationFlowEquivalenceChecker(qc1, qc2);
      
    • Perform the actual equivalence check
      eq.check();
      
    • Print the results
      eq.printResult();
      
      or access them through the eq.results member.

System requirements

Building (and running) is continuously tested under Linux (Ubuntu 20.04) using gcc-9.3 and clang-11, MacOS (Catalina 10.15) using AppleClang and gcc-10, and Windows using Microsoft Visual Studio 2017. However, the implementation should be compatible with any current C++ compiler supporting C++14 and a minimum CMake version of 3.10.

Configure, Build, and Install

In order to build the library execute the following in the project's main directory

  1. Configure CMake

    cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
    

    Windows users using Visual Studio and the MSVC compiler may try

    cmake -S . -B build -G "Visual Studio 15 2017" -A x64 -DCMAKE_BUILD_TYPE=Release
    

    Older CMake versions not supporting the above syntax (< 3.13) may be used with

    mkdir build && cd build
    cmake .. -DCMAKE_BUILD_TYPE=Release
    
  2. Build the respective target.

    cmake --build ./build --config Release --target <target>
    

    The following CMake targets are available

    • qcec_app: The commandline executable
    • qcec: The standalone library
    • qcec_example: A small commandline demo example
    • qcec_test: Unit tests using GoogleTest
  3. Optional: The QCEC library and tool may be installed on the system by executing

    cmake --build ./build --config Release --target install
    

    It can then also be included in other projects using the following CMake snippet

    find_package(qcec)
    target_link_libraries(${TARGET_NAME} PRIVATE JKQ::qcec)
    

Python Bindings

Running pip install . in the main project directory creates Python bindings for the JKQ QCEC tool. Then, using it in Python is as simple as:

from jkq import qcec
qcec.verify({"file1": "<PATH_TO_FILE_1>", "file2:": "<PATH_TO_FILE_2>"})

The full list of parameters as described in Usage which can be passed to qcec.verify(...) as a Python dictionary, are:

instance = {
    "file1":  "<PATH_TO_FILE_1>", # required
    "file2":  "<PATH_TO_FILE_2>", # required
    "method": "proportional",
    "tolerance": 1e-13,
    "nsims": 16,
    "fidelity": 0.999,
    "statistics": False,
    "csv": False,
}

Reference

If you use our tool for your research, we will be thankful if you refer to it by citing the appropriate publication:

[1] L. Burgholzer and R. Wille. "Advanced Equivalence Checking for Quantum Circuits". IEEE Trans. on CAD of Integrated Circuits and Systems (TCAD), 2021
@article{burgholzer2020advanced,
    author = {Burgholzer, Lukas and Wille, Robert},
    title = {Advanced Equivalence Checking for Quantum Circuits},
    year = 2021,
    journaltitle = {{IEEE} Trans. on {CAD} of Integrated Circuits and Systems}
}
[2] L. Burgholzer, R. Raymond, and R. Wille. "Verifying Results of the IBM Qiskit Quantum Circuit Compilation Flow". In International Conference on Quantum Computing and Engineering (QCE), 2020
@inproceedings{burgholzer2020verifyingResultsIBM,
  title = {Verifying results of the {{IBM Qiskit}} quantum circuit compilation flow},
  booktitle = {International Conference on Quantum Computing and Engineering},
  author = {Burgholzer, Lukas and Raymond, Rudy and Wille, Robert},
  year = {2020}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jkq.qcec-1.5.0b1.tar.gz (8.1 kB view hashes)

Uploaded Source

Built Distributions

jkq.qcec-1.5.0b1-cp39-cp39-win_amd64.whl (279.6 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

jkq.qcec-1.5.0b1-cp39-cp39-manylinux2014_x86_64.whl (369.9 kB view hashes)

Uploaded CPython 3.9

jkq.qcec-1.5.0b1-cp39-cp39-manylinux2014_aarch64.whl (347.5 kB view hashes)

Uploaded CPython 3.9

jkq.qcec-1.5.0b1-cp39-cp39-macosx_10_9_x86_64.whl (332.1 kB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

jkq.qcec-1.5.0b1-cp38-cp38-win_amd64.whl (279.5 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

jkq.qcec-1.5.0b1-cp38-cp38-manylinux2014_x86_64.whl (369.7 kB view hashes)

Uploaded CPython 3.8

jkq.qcec-1.5.0b1-cp38-cp38-manylinux2014_aarch64.whl (347.4 kB view hashes)

Uploaded CPython 3.8

jkq.qcec-1.5.0b1-cp38-cp38-macosx_10_9_x86_64.whl (332.0 kB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

jkq.qcec-1.5.0b1-cp37-cp37m-win_amd64.whl (280.3 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

jkq.qcec-1.5.0b1-cp37-cp37m-manylinux2014_x86_64.whl (372.1 kB view hashes)

Uploaded CPython 3.7m

jkq.qcec-1.5.0b1-cp37-cp37m-manylinux2014_aarch64.whl (349.3 kB view hashes)

Uploaded CPython 3.7m

jkq.qcec-1.5.0b1-cp37-cp37m-macosx_10_9_x86_64.whl (330.2 kB view hashes)

Uploaded CPython 3.7m macOS 10.9+ x86-64

jkq.qcec-1.5.0b1-cp36-cp36m-win_amd64.whl (280.3 kB view hashes)

Uploaded CPython 3.6m Windows x86-64

jkq.qcec-1.5.0b1-cp36-cp36m-manylinux2014_x86_64.whl (372.1 kB view hashes)

Uploaded CPython 3.6m

jkq.qcec-1.5.0b1-cp36-cp36m-manylinux2014_aarch64.whl (349.2 kB view hashes)

Uploaded CPython 3.6m

jkq.qcec-1.5.0b1-cp36-cp36m-macosx_10_9_x86_64.whl (330.2 kB view hashes)

Uploaded CPython 3.6m macOS 10.9+ x86-64

jkq.qcec-1.5.0b1-cp35-cp35m-win_amd64.whl (280.3 kB view hashes)

Uploaded CPython 3.5m Windows x86-64

jkq.qcec-1.5.0b1-cp35-cp35m-manylinux2014_x86_64.whl (372.1 kB view hashes)

Uploaded CPython 3.5m

jkq.qcec-1.5.0b1-cp35-cp35m-manylinux2014_aarch64.whl (349.2 kB view hashes)

Uploaded CPython 3.5m

jkq.qcec-1.5.0b1-cp35-cp35m-macosx_10_9_x86_64.whl (330.2 kB view hashes)

Uploaded CPython 3.5m macOS 10.9+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page