Installation for Users

QCEC is mainly developed as a C++ library that builds upon our decision diagram (DD) package as well as our quantum functionality representation (QFR). In order to make the tool as accessible as possible, it comes with an easy-to-use Python interface.

We encourage installing QCEC via pip (preferably in a virtual environment):

(venv) $ pip install mqt.qcec

In most practical cases (under 64-bit Linux, MacOS incl. Apple Silicon, and Windows), this requires no compilation and merely downloads and installs a platform-specific pre-built wheel.

A Detailed Walk Through

First, save the following lines as in a folder where you want to install QCEC and run the example:

from qiskit import QuantumCircuit, transpile
from qiskit.test.mock import FakeLondon
from mqt import qcec

# create your quantum circuit
circ = QuantumCircuit(3)
circ.h(0), 1), 2)

# compile circuit to 5-qubit London Architecture
circ_comp = transpile(circ, backend=FakeLondon())

# verify the equivalence of both circuits
result = qcec.verify(circ, circ_comp)

# print the result

Then, the following snippet shows the installation process from setting up the virtual environment to running a small example program.

$ python3 -m venv venv
$ . venv/bin/activate
(venv) $ pip install -U pip setuptools wheel
(venv) $ pip install mqt.qcec qiskit-terra
(venv) $ python3
        ┌───┐           ░ ┌─┐
   q_0: ┤ H ├──■────■───░─┤M├──────
        └───┘┌─┴─┐  │   ░ └╥┘┌─┐
   q_1: ─────┤ X ├──┼───░──╫─┤M├───
             └───┘┌─┴─┐ ░  ║ └╥┘┌─┐
   q_2: ──────────┤ X ├─░──╫──╫─┤M├
                  └───┘ ░  ║  ║ └╥┘
meas: 3/═══════════════════╩══╩══╩═
                           0  1  2

ancilla_0 -> 0 ─────────────────────────────────────░──────────
                                              ┌───┐ ░       ┌─┐
      q_2 -> 1 ───────────────────────────────┤ X ├─░───────┤M├
                                              └─┬─┘ ░       └╥┘
ancilla_1 -> 2 ─────────────────────────────────┼───░────────╫─
                          ┌───┐     ┌───┐       │   ░ ┌─┐    ║
      q_1 -> 3 ───────────┤ X ├──■──┤ X ├──■────■───░─┤M├────╫─
               ┌─────────┐└─┬─┘┌─┴─┐└─┬─┘┌─┴─┐      ░ └╥┘┌─┐ ║
      q_0 -> 4 ┤ U2(0,π) ├──■──┤ X ├──■──┤ X ├──────░──╫─┤M├─╫─
               └─────────┘     └───┘     └───┘      ░  ║ └╥┘ ║
       meas: 3/════════════════════════════════════════╩══╩══╩═
                                                       0  1  2

Building from Source for Performance

In order to get the best performance out of QCEC and enable platform-specific compiler optimizations that cannot be enabled on portable wheels, it is recommended to build the package from source via:

(venv) $ pip install mqt.qcec --no-binary mqt.qcec

This requires a C++ compiler compiler supporting C++17 and a minimum CMake version of 3.14.

The library is continuously tested under Linux, MacOS, and Windows using the latest available system versions for GitHub Actions. In order to access the latest build logs, visit qcec/actions/workflows/ci.yml.


We noticed some issues when compiling with Microsoft’s MSCV compiler toolchain. If you want to start development on this project under Windows, consider using the clang compiler toolchain. A detailed description of how to set this up can be found here.