cda-tum / mqt-qcec

MQT QCEC - A tool for Quantum Circuit Equivalence Checking
https://mqt.readthedocs.io/projects/qcec
MIT License
90 stars 21 forks source link

🐛 Circuits without measurements might cause segfaults #236

Closed burgholzer closed 1 year ago

burgholzer commented 1 year ago

mqt.qcec version

latest

OS

any

Python version

any

C++ compiler

any

Additional environment information

No response

Description

QCEC might unexpectedly segfault when circuits to not contain measurements (that allow to infer the output permutation). The observed exception is

libc++abi: terminating with uncaught exception of type std::invalid_argument: Alternating checker must not be used for circuits that both have non-idle ancillary qubits. Use the construction checker instead.

However, the circuits in question do not contain non-idle ancillaries, which indicates that one of the checks does not fully support the absence of measurements. Should be fairly easy to fix.

Expected behavior

QCEC should not segfault on circuits compiled without measurements at the end of the circuit.

How to Reproduce

Run

from mqt import qcec

from qiskit import QuantumCircuit, transpile
from qiskit.providers.fake_provider import FakeAthens

circ = QuantumCircuit(1)
circ.x(0)
circTransp = transpile(circ, backend=FakeAthens())
result = qcec.verify(circ,circTransp)