-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🐛 Partial equivalence with ancillary qubits #508
Comments
Hey 👋🏻 Thanks for raising this issue! Let me start by pointing out a couple of things: I suppose you are placing the reset operations in the circuit to indicate that these qubits are ancillaries that should be in the zero state. Rather than that, you should be able to explicitly add these as AncillaQubits (https://docs.quantum.ibm.com/api/qiskit/circuit#qiskit.circuit.AncillaQubit) in Qiskit and that should directly flag them as such when being imported in QCEC. You are not really building a dynamic quantum circuit here because you are not using the non-unitary primitives in the middle of the computation. So enabling that flag for QCEC does not really help much. One could argue that QCEC could strip these operations from the circuit and instead mark them as ancillaries, which might be a pretty reasonable thing to do. Especially since we already try to determine output permutations from final measurements. In the meantime, it should work if you remove the reset operations and disable the dynamic circuit option. |
Hey! import sys
from mqt.qcec import verify
from qiskit import QuantumCircuit
from qiskit.circuit import AncillaQubit
ancilla = AncillaQubit()
qc1 = QuantumCircuit(1, 0)
qc1.add_bits([ancilla])
qc1.h(ancilla)
qc2 = QuantumCircuit(1, 0)
qc2.add_bits([ancilla])
result = verify(
qc1,
qc2,
check_partial_equivalence=True,
)
print(result.equivalence) File ".../lib/python3.10/site-packages/mqt/qcec/verify.py", line 56, in verify
ecm = EquivalenceCheckingManager(circ1, circ2, configuration)
RuntimeError: Could not import first circuit: KeyError: <qiskit.circuit.quantumregister.AncillaQubit object at 0x7f8da4895400> |
Alright. One step closer. I can reproduce your error. It has something to do with the way we translate Qiskit circuits. |
Alright, I did some digging. Turns out this seems to only really affect the ZX-based equivalence checker. The following code works just fine on my machine from qiskit import QuantumCircuit
from qiskit.circuit import AncillaRegister
from mqt.qcec import verify
anc = AncillaRegister(1)
qc1 = QuantumCircuit(1, 0)
qc1.add_register(anc)
qc1.h(anc[0])
qc2 = QuantumCircuit(1, 0)
qc2.add_register(anc)
result = verify(
qc1,
qc2,
check_partial_equivalence=True,
run_zx_checker=False,
)
print(result.equivalence) While we work on fixing the ZX Checker, the above should allow you to run the equivalence check as desired. |
Great, thanks! It works on my machine too. |
Environment information
Description
I’m facing an issue when trying to verify the partial equivalence between two quantum circuits, qc1 and qc2.
qc1:
qc2:
Expected behavior
When I check the equivalence of these two circuits, the result is
not_equivalent
, but I expected a partial equivalence between them.I would like to:
Thank you for your help!
How to Reproduce
The text was updated successfully, but these errors were encountered: