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

CSP ignores 3-or-more-qubit gates #7155

Open
1ucian0 opened this issue Oct 18, 2021 · 12 comments · May be fixed by #12912
Open

CSP ignores 3-or-more-qubit gates #7155

1ucian0 opened this issue Oct 18, 2021 · 12 comments · May be fixed by #12912
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@1ucian0
Copy link
Member

1ucian0 commented Oct 18, 2021

Information

  • Qiskit Terra version: main

What is the current behavior?

Take the following circuit:

from qiskit import QuantumCircuit
qc = QuantumCircuit(3)
qc.cx(0,1)
qc.ccx(2,0,1)
qc.draw()
q_0: ──■────■──
     ┌─┴─┐┌─┴─┐
q_1: ┤ X ├┤ X ├
     └───┘└─┬─┘
q_2: ───────■──

CSPLayout should not be able to find a solution with a layout 0- > 1 -> 2. However:

from qiskit.transpiler import CouplingMap
from qiskit.transpiler.passes import CSPLayout

pass_ = CSPLayout(CouplingMap([(0, 1), (1, 2)]))
result = pass_(qc)
pass_.property_set["CSPLayout_stop_reason"]
'solution found'

Suggested solutions

There are two options. If CSPLayout encounters a 3-or-more-qubit gate, either assumes that this needs complete connection among the involved qubits, or just fails with reason 3-or-more-qubit gate found.

@yjt98765
Copy link
Contributor

@1ucian0 I tried to add 3-or-more-qubit gates as constraints, and the pass generates this layout:

Layout({
1: Qubit(QuantumRegister(3, 'qr'), 0),
0: Qubit(QuantumRegister(3, 'qr'), 1),
2: Qubit(QuantumRegister(3, 'qr'), 2)
})

I guess maybe it is reasonable? It does not involve swaps. It simply suggests that mapping qr[0] to physical qubit 1. Such mapping is allowed, right? It is kind of the point of using CSP in this pass.

@1ucian0
Copy link
Member Author

1ucian0 commented Nov 29, 2021

In the original example, CCX does not have a possible layout in the coupling map 0 - > 1 -> 2. No solution should be found or raise.

@Silrem
Copy link

Silrem commented Jan 28, 2022

Can I work on this?

@1ucian0
Copy link
Member Author

1ucian0 commented Jan 31, 2022

Sure thing @Silrem. Assigning. let me know if I can help!

@Silrem
Copy link

Silrem commented Feb 5, 2022

@1ucian0 Just created a PR (#7625). Not sure if I can/should add you as a reviewer. Anyway, my first draft is there =)

@javabster javabster moved this to PR Open in Contributor Monitoring Jun 21, 2022
@1ucian0 1ucian0 moved this from PR open / Contributor working on it to Contributor MIA in Contributor Monitoring Aug 4, 2022
@javabster javabster moved this from Contributor MIA to Tagged but unassigned in Contributor Monitoring Dec 12, 2022
@javabster
Copy link
Contributor

un-assigning so that this issue is open for others to have a go. If anyone would like to pick this work up make sure to take a look at #7625 and go from there 😄

@lmpawan10
Copy link

I want to work on the issue if it still exists.

@javabster
Copy link
Contributor

sorry for the slow reply @lmpawan10, I'll assign to you 😄 As this is an old issue the first step would be to check that the bug still exists

@1ucian0
Copy link
Member Author

1ucian0 commented Aug 14, 2023

Hello @lmpawan10 ! Are you still working on this one?

@lmpawan10
Copy link

Sorry that I got busier with other tasks. I am planning to work on this issue this month.
You can give it to others if they are interested, or I will deal with it.

@AngeloDanducci AngeloDanducci moved this from Tagged but unassigned to Assigned in Contributor Monitoring Sep 7, 2023
@1ucian0
Copy link
Member Author

1ucian0 commented Sep 16, 2023

Hi @lmpawan10 ! how is that going?

@1ucian0
Copy link
Member Author

1ucian0 commented May 7, 2024

clearing assignee

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
Status: Assigned
5 participants