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

The max index of qubits in gates.CU1 is out ranged in qibo/src/qibo/models /hep.py #1497

Open
Landau1908 opened this issue Oct 17, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@Landau1908
Copy link

Landau1908 commented Oct 17, 2024

Describe the bug
A minimun example: if nqubits =even number, it works, otherwise, it doesn't work.

from qibo.ui import plot_circuit
from qibo.models.hep import qPDF

ansatz = 'Weighted'
multi_output = True
layers = 3
nqubits = 7

mypdf = qPDF(ansatz, layers, nqubits, multi_output=multi_output)
plot_circuit(mypdf.circuit, scale = 0.8, cluster_gates = True, style="quantumspain")

Ouputs:

Traceback (most recent call last):

  Cell In[7], line 1
    plot_circuit(mypdf.circuit, scale = 0.8, cluster_gates = True, style="quantumspain")

  File E:\ProgramData\Lib\site-packages\qibo\ui\mpldrawer.py:729 in plot_circuit
    ax = _plot_quantum_schedule(gates_cluster, inits, params, labels, scale=scale)

  File E:\ProgramData\Lib\site-packages\qibo\ui\mpldrawer.py:59 in _plot_quantum_schedule
    return _plot_quantum_circuit(

  File E:\ProgramData\Lib\site-packages\qibo\ui\mpldrawer.py:120 in _plot_quantum_circuit
    _draw_gates(

  File E:\ProgramData\Lib\site-packages\qibo\ui\mpldrawer.py:180 in _draw_gates
    _draw_controls(

  File E:\ProgramData\Lib\site-packages\qibo\ui\mpldrawer.py:198 in _draw_controls
    control_indices = _get_flipped_indices(controls, labels)

  File E:\ProgramData\Lib\site-packages\qibo\ui\mpldrawer.py:472 in _get_flipped_indices
    return [_get_flipped_index(t, labels) for t in targets]

  File E:\ProgramData\Lib\site-packages\qibo\ui\mpldrawer.py:445 in _get_flipped_index
    i = labels.index(target)

ValueError: 'q_7' is not in list

Expected behavior
After reading the code (qibo/src/qibo/models /hep.py), this error is induced by this line

for q in range(1, qubits + 1, 2):

which should be corrected to

for q in range(1, qubits + 0, 2):

There are total 4 lines should be corrected: Line163,193,237,260

Desktop (please complete the following information):

  • OS: Win10, 64

Additional context
Add any other context about the problem here.

@Landau1908 Landau1908 added the bug Something isn't working label Oct 17, 2024
@MatteoRobbiati
Copy link
Contributor

Thanks for opening this @Landau1908!
I just checked if the dedicated Qibo qPDF example works and I can confirm everything is fine from that side.

Could you please complete the Describe the bug section pasting the source code which is generating the error?

@renatomello
Copy link
Contributor

Can this be closed?

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

No branches or pull requests

3 participants