Skip to content
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

Equivalence checking with a certain restriction #441

Open
ritu-thombre99 opened this issue Aug 11, 2024 · 2 comments
Open

Equivalence checking with a certain restriction #441

ritu-thombre99 opened this issue Aug 11, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@ritu-thombre99
Copy link

ritu-thombre99 commented Aug 11, 2024

Environment information

OS: MacOS
MQT version: 2.6.0
Compiler: C++

Description

I'm trying to compile circuits with a certain restriction that measurements can only be performed using certain qubits.

For example, in the following coupling map, measurement can only be performed using physical qubit 2
image

The input circuit is a GHZ state preparation:
image

After compiling:
Initial mapping (logical->physical) : 0->2, 1->1, 2->0

Logical qubit 0 is already mapped to physical qubit 2, so it is measured

But to measure logical qubit 1, it needs to be swapped with logical qubit 0 so that it is mapped to physical qubit 2

Hence, a SWAP is inserted between logical qubits 1 and 0 after measuring logical qubit 0

And the compiled circuit looks like below:

image

Is it possible to check equivalence of this compiling?

I tried with the following code:

from mqt import qcec
result = qcec.verify(circ, circ_comp, transform_dynamic_circuit=True,)

# print the result
print(result.equivalence)

Output: not_equivalent

I also tried running the equivalence with combinations of backpropagate_output_permutation=True and fix_output_permutation_mismatch=True, but the output is not_equivalent.

Sometimes it is equivalent

In a very particular case where logical qubit is mapped to physical qubit 0 (mapping of logical qubit 1 and 2 doesn't matter),
the circuits before and after compiling are equivalent

image

Expected behavior

Circuits should be equivalent in both the cases, not just when logical qubit 0 is mapped to physical qubit 0.

How to Reproduce

Import qiskit, mqt.qcec and the run the code/circuit blocks mentioned above.

@burgholzer
Copy link
Member

I am fairly sure that QCEC cannot handle this special case at the moment.
What you are describing here is a dynamic circuit that contains mid-circuit measurements. So it needs some kind of transformation before being able to be checked.
I am fairly sure that QCEC currently messes up the initial layout or the output permutation when it tries to transform the circuits above.

I think this could be fixable in principle for cases like these with a combination of the optimization passes we have in place already.
I'll see what I can do once I am back from vacation.

@burgholzer burgholzer added the bug Something isn't working label Aug 22, 2024
@burgholzer burgholzer added this to MQT Aug 22, 2024
@burgholzer burgholzer moved this from In Progress to Todo in MQT Verification Aug 22, 2024
@github-project-automation github-project-automation bot moved this to In Progress in MQT Aug 22, 2024
@burgholzer burgholzer moved this from In Progress to Todo in MQT Aug 22, 2024
@ritu-thombre99
Copy link
Author

@glassnotes to keep you in loop

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Todo
Status: Todo
Development

No branches or pull requests

2 participants