QFR - A JKQ tool for Quantum Functionality Representation
Project description
QFR - A JKQ Library for Quantum Functionality Representation Written in C++
A JKQ library for the representation of quantum functionality by the Institute for Integrated Circuits at the Johannes Kepler University Linz. This package is part of the JKQ toolset.
If you have any questions feel free to contact us using iic-quantum@jku.at or by creating an issue on GitHub.
Efficient Construction of Functional Representations for Quantum Algorithms
The QFR library provides the means for constructing the functionality of a given quantum circuit using decision diagrams in the form of the jkq.qfr
Python package.
It includes a traditional, sequential approach (qfr.ConstructionMethod.sequential
) and the efficient, recursive method proposed in [1] (qfr.ConstructionMethod.recursive
).
[1] L. Burgholzer, R. Raymond, I. Sengupta, and R. Wille. "Efficient Construction of Functional Representations for Quantum Algorithms". arXiv:2103.08281, 2021
In order to start using it, install the package using
pip install jkq.qfr
Then, in Python, the functionality of a given circuit (provided, e.g., as Qiskit QuantumCircuit) can be constructed with:
from jkq import qfr
from qiskit import QuantumCircuit
# create your quantum circuit
qc = <...>
# construct the functionality of the circuit
results = qfr.construct(qc)
# print the results
print(results)
The construct
function additionally provides the options store_decision_diagram
and store_matrix
that allow to store the resulting decision diagram or matrix, respectively. Note that storing the resulting matrix takes considerable amounts of memory in comparison to the typical memory footprint incurred by the corresponding decision diagram. At least 2^(2n+1)*sizeof(float)
byte are required for storing the matrix representing an n-qubit quantum circuit.
Special routines are available for constructing the functionality of the Quantum Fourier Transform (construct_qft(nqubits, ...)
) or Grover's algorithm (construct_grover(nqubits, seed, ...)
). For details on the method employed for Grover's search we refer to [1, Section 4.2].
JKQ Toolset
The QFR library is the backbone of the quantum software tools in JKQ: JKU Tools for Quantum Computing:
- JKQ DDSIM: a decision diagram-based simulator for quantum circuits.
- JKQ QMAP: a tool for mapping/compiling quantum circuits to real quantum architectures.
- JKQ QCEC: a decision diagram-based equivalence checking tool for quantum circuits.
- JKQ DDVis: a visualization tool for how decision diagrams are used in simulation and verification.
- You can find an online instance of this tool at http://iic.jku.at/eda/research/quantum_dd/tool/
It acts as an intermediate representation and provides the facilitites to
-
Obtain intermediate representations from circuit descriptions.
Currently available file formats are:
OpenQASM
(e.g. used by Qiskit)Real
(e.g. from RevLib)GRCS
Google Random Circuit Sampling Benchmarks (see GRCS)TFC
(e.g. from Reversible Logic Synthesis Benchmarks Page)QC
(e.g. from Feynman)
Importing a circuit from a file in either of those formats is done via:
std::string filename = "PATH_TO_FILE"; qc::QuantumComputation qc(filename);
or by calling
qc.import(filename);
which first resets the
qc
object before importing the new file. -
Generate circuit representations for important quantum algorithms.
Currently available algorithms are:
-
Entanglement
unsigned short n = 2; qc::Entanglement entanglement(n); // generates bell circuit
Generates the circuit for preparing an n qubit GHZ state. Primarily used as a simple test case.
-
Bernstein-Vazirani
unsigned long long hiddenInteger = 16777215ull; qc::BernsteinVazirani bv(hiddenInteger); // generates Bernstein-Vazirani circuit for given hiddenInteger
Generates the circuit for the Berstein-Vazirani algorithm using the provided hiddenInteger
-
Quantum Fourier Transform (QFT)
unsigned short n = 3; qc::QFT qft(n); // generates the QFT circuit for n qubits
Generates the circuit for the n qubit Quantum Fourier Transform.
-
Grover's search algorithm
unsigned short n = 2; qc::Grover grover(n); // generates Grover's algorithm for a random n-bit oracle
The algorithm performs ~ π/4 √2ⁿ Grover iterations. An optional
unsigned int
parameter controls the seed of the random number generation for the oracle generation.
-
-
Generate circuit descriptions from intermediate representations.
The library also supports the output of circuits in various formats by calling
std::string filename = "PATH_TO_DESTINATION_FILE.qasm"; qc.dump(filename);
Currently available file formats are:
OpenQASM
(.qasm)
Development
System Requirements
Building (and running) is continuously tested under Linux, MacOS, and Windows using the latest available system versions for GitHub Actions. However, the implementation should be compatible with any current C++ compiler supporting C++17 and a minimum CMake version of 3.14.
It is recommended (although not required) to have GraphViz installed for visualization purposes.
Configure, Build, and Install
To start off, clone this repository using
git clone --recurse-submodules -j8 https://github.com/iic-jku/qfr
Note the --recurse-submodules
flag. It is required to also clone all the required submodules. If you happen to forget passing the flag on your initial clone, you can initialize all the submodules by
executing git submodule update --init --recursive
in the main project directory.
Our projects use CMake as the main build configuration tool. Building a project using CMake is a two-stage process. First, CMake needs to be configured by calling
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
This tells CMake to search the current directory .
(passed via -S
) for a CMakeLists.txt file and process it into a directory build
(passed via -B
).
The flag -DCMAKE_BUILD_TYPE=Release
tells CMake to configure a Release build (as opposed to, e.g., a Debug build).
After configuring with CMake, the project can be built by calling
cmake --build build --config Release
This tries to build the project in the build
directory (passed via --build
).
Some operating systems and developer environments explicitly require a configuration to be set, which is why the --config
flag is also passed to the build command. The flag --parallel <NUMBER_OF_THREADS>
may be added to trigger a parallel build.
Building the project this way generates
- the library
libqfr.a
(Unix) /qfr.lib
(Windows) in thebuild/src
folder - a test executable
qfr_test
containing a small set of unit tests in thebuild/test
folder - a small demo example executable
qfr_example
in thebuild/test
directory.
You can link against the library built by this project in other CMake project using the JKQ::qfr
target.
Extending the Python Package
To extend the Python package you can locally install the package in edit mode, so that changes in the Python code are instantly available. The following example assumes you have a virtual environment set up and activated.
(venv) $ pip install cmake
(venv) $ pip install --editable .
If you change parts of the C++ code, you have to run the second line to make the changes visible in Python.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for jkq.qfr-1.4.2-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 84cce046e45d476da51ecd1376d72e0a5a917a7223a035366b3b8078c503be73 |
|
MD5 | 154bdf4172430b1e19d1b8f63924141d |
|
BLAKE2b-256 | 82b7274a51c7d9f176fc7bf44ecbd5db24850d872fbe712c1681877619e09fe6 |
Hashes for jkq.qfr-1.4.2-cp39-cp39-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 42bf510f777bfcea8852239a23534336ac63c01016141788e3c9aba5854016c0 |
|
MD5 | 6e72ea7bc5a88370a8b0fb19208aff4c |
|
BLAKE2b-256 | 433e97ed1b0907790812a67716baea5f50d95108a174160f49d761d70b585cb2 |
Hashes for jkq.qfr-1.4.2-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 64fc10141e12afe4db9b27a0545ae63a6a36e0a81cac69546edc0bb2aa747544 |
|
MD5 | a023b1ba1b9e9b7248b1f4c3ea62890b |
|
BLAKE2b-256 | 48feaa95e9253e5b8391f8db878b7a9d3f2705741210d7a11bb8128f8e63549b |
Hashes for jkq.qfr-1.4.2-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e3755a27172f4bdf28da41e4af8be9eacda1153634668a8b1439e0e9f943f3ce |
|
MD5 | 95a1a26ff5cb8165c2c919c19e57da17 |
|
BLAKE2b-256 | 863c430039810ec41b839e86b68a8b42fa99046ab5cbf6bc23302fb213e88a8b |
Hashes for jkq.qfr-1.4.2-cp38-cp38-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee5bfd136b69d4b8e0a67074eb0786834fe2e7d0c3f392e63b35401a49acf254 |
|
MD5 | dc51375794e336068f98058fdbbba7c0 |
|
BLAKE2b-256 | 84ef346cf107c1a9571e06660ab0843ce61df2a6a4ee294c299b11a66f7d46ca |
Hashes for jkq.qfr-1.4.2-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d547bada1b13ba17f88ae69c4133ef609454eaf373758a68a18abffaf53b22fe |
|
MD5 | 0987f785f0ce69977eda06d844618a3b |
|
BLAKE2b-256 | 224333d18cf33d77606ad88fc32b786ff8ade8987f2b4fe339faaa76f816a083 |
Hashes for jkq.qfr-1.4.2-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d6d91017a5e812a1d8b7eebd4f08707ba70ec4fb6be87b473b5d363e4d1a08bd |
|
MD5 | 99840d5924a981a8e690c19bc63c0fa1 |
|
BLAKE2b-256 | 7c8faa746505d630a7fd2ccd389272437f720b736d744d15746646bb07e906a2 |
Hashes for jkq.qfr-1.4.2-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d66ba4048e3bfffb91b3242beecf812ee679323e23b9c5d715393b37be455e65 |
|
MD5 | 85e3d086877bc472f0affe26fbd9be05 |
|
BLAKE2b-256 | cf65a64d616fd8443b0fa09702dae3e8942588f92a0a9ca16a43b340cc27eb04 |
Hashes for jkq.qfr-1.4.2-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 800e4ebf7d79783f56d526011eb2b9cb7f59a40e6669e319902cfbeb439a3880 |
|
MD5 | 8cd647c463a723362fb93d19219d2cda |
|
BLAKE2b-256 | 48c24d9e6715a8c63af28d7f6133b4275c0710077461243eab6af5ef60e48bdf |
Hashes for jkq.qfr-1.4.2-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5503d334f6ce87e6cc87168f2386e88e12d9ca92cad8edede3fb4d156a81ac5c |
|
MD5 | 0328776e2249ab2198bf40dabb86dae8 |
|
BLAKE2b-256 | 463f4752fb1163836d4dceed1c010bff8c254edb163f24b94410bff4a4ed1ca2 |
Hashes for jkq.qfr-1.4.2-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 73931400a91cb64bd860f113650284dc3012ccff66db18061fdda88d579032b3 |
|
MD5 | 4a1c51456f1f92e9701c1b5898a0f632 |
|
BLAKE2b-256 | 6a057a5d5b1b71e6caeec5870883cf57d6f3edf01b916544d31205c3036eda4f |
Hashes for jkq.qfr-1.4.2-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c46df26a05c26519d59394197e14d4f6f1127ddf2540591121b3b66d4d365c73 |
|
MD5 | 4418d410c57c2c2128179617af94a318 |
|
BLAKE2b-256 | 0672339f743da6577abb162f02dd0d5cadc7f3b856507c724876d059a4817190 |