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

Bug in qibo.transpiler.placer.Subgraph for Qibo 0.2.14 or master #1546

Closed
carlos-luque opened this issue Dec 16, 2024 · 2 comments · Fixed by #1549
Closed

Bug in qibo.transpiler.placer.Subgraph for Qibo 0.2.14 or master #1546

carlos-luque opened this issue Dec 16, 2024 · 2 comments · Fixed by #1549
Labels
bug Something isn't working

Comments

@carlos-luque
Copy link
Contributor

The if statement that checks the number of two-qubit gates in the circuit contains an error. The statement checks if there are three two-qubit gates.
The if statement on line 129 is located in the function call of the class Subgraph. https://github.com/qiboteam/qibo/blob/45886717471a919d09a832a953c1c05cb6174fa1/src/qibo/transpiler/placer.py#L129C1-L134C14

To Reproduce

import networkx as nx

def star_connectivity():
    Q = [i for i in range(5)]
    chip = nx.Graph()
    chip.add_nodes_from(Q)
    graph_list = [(Q[i], Q[2]) for i in range(5) if i != 2]
    chip.add_edges_from(graph_list)
    return chip

QPU = star_connectivity()

import qibo
from qibo import gates
from qibo.models import Circuit

qibo.set_backend("numpy")

circuit = Circuit(4)
circuit.add(gates.H(0))
circuit.add(gates.CNOT(0, 1))
circuit.add(gates.CNOT(1, 2))
circuit.add(gates.M(3))

from qibo.transpiler.optimizer import Preprocessing
from qibo.transpiler.placer import Subgraph

fase_asignacion = Preprocessing(connectivity=QPU)
asignacion_circuit = fase_asignacion(circuit)
placement = Subgraph(connectivity=QPU)
colocacion_incial = placement(asignacion_circuit)

Error:
[Qibo 0.2.14|ERROR|.....]: Circuit must contain at least two two-qubit gates to implement subgraph placement.

Expected behavior
The circuit contains at least two two-qubit gates, so the error shouldn't occur.

Sugested fix
I would suggest changing the number 3 to 2 in the if statement that checks the number of two-qubit gates in the circuit

@carlos-luque carlos-luque added the bug Something isn't working label Dec 16, 2024
@alecandido
Copy link
Member

Thanks @carlos-luque for reporting the issue.

As you said, it is pretty much an easy fix. But since you found it, I would encourage you to contribute a PR with the proposed suggestion, and a corresponding test (which should ensure that the fix is working, but also that the problem will not appear again).

@carlos-luque
Copy link
Contributor Author

Thanks @alecandido for you reply. I'll do it

carlos-luque added a commit to carlos-luque/qibo that referenced this issue Dec 18, 2024
 The if statement that checks the number of two-qubit gates in the circuit
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
None yet
Development

Successfully merging a pull request may close this issue.

2 participants