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

timeline_drawer fails for conditional parameterized gates #13443

Open
eendebakpt opened this issue Nov 15, 2024 · 0 comments
Open

timeline_drawer fails for conditional parameterized gates #13443

eendebakpt opened this issue Nov 15, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@eendebakpt
Copy link
Contributor

Environment

  • Qiskit version: 1.2.4
  • Python version: 3.12
  • Operating system: Windows

What is happening?

The timeline_drawer fails for the parameterized crx gate. The underlying problem might be in the schedulers such as ALAP.

How can we reproduce the issue?

A minimal example shows one working case, and 3 failing cases:

import numpy as np
from qiskit.circuit import QuantumCircuit
from qiskit.transpiler import PassManager, InstructionDurations
from qiskit.transpiler.passes import ALAPScheduleAnalysis, PadDynamicalDecoupling
from qiskit.visualization import timeline_drawer
from qiskit.circuit.library import RXGate

durations = InstructionDurations( [("reset", None, 10),
     ("cz", None, 120), ("cx", None, 120), ("crx", None, 160),
     ("rx", None, 80), ('ry', None, 80), ('rz', None, 0),  ("measure", None, 30_000)]
)
dd_sequence = [RXGate(np.pi/2), RXGate(np.pi/2),RXGate(np.pi/2),RXGate(np.pi/2)]

#%% ALAP + DD works
circ = QuantumCircuit(2)
circ.rx(np.pi/2, 0)
circ.rz(-np.pi/2, 0)

pm = PassManager([ALAPScheduleAnalysis(durations),
                  PadDynamicalDecoupling(durations, dd_sequence)])
circ_dd = pm.run(circ)
timeline_drawer(circ_dd) # works


#%% Only ALAP fails
circ = QuantumCircuit(2)
circ.rx(np.pi/2, 0)
circ.rz(-np.pi/2, 0)
 
pm = PassManager([ALAPScheduleAnalysis(durations)])
circ_dd = pm.run(circ)
timeline_drawer(circ_dd) # fails


#%% CRX fails
circ = QuantumCircuit(2)
circ.rx(np.pi/2, 0)
circ.crx(-np.pi/2, 0, 1)

pm = PassManager([ALAPScheduleAnalysis(durations),
                  PadDynamicalDecoupling(durations, dd_sequence)])
circ_dd = pm.run(circ)
timeline_drawer(circ_dd) # works

#%% Different parameters for the rx
circ = QuantumCircuit(2)
circ.rx(0.1 * np.pi, 0)
circ.barrier()
circ.rx(.9*np.pi, 0)
circ.barrier()

 
pm = PassManager([ALAPScheduleAnalysis(durations),
                  PadDynamicalDecoupling(durations, dd_sequence)])
circ_dd = pm.run(circ)
timeline_drawer(circ_dd) # plots, but how can I specify the duration of the two different rx gates?

The exception generated is TypeError: '>' not supported between instances of 'int' and 'NoneType'

What should happen?

If the gate durations are specified, the schedulers should produce circuits that can be plotted by timeline_drawer.

Any suggestions?

No response

@eendebakpt eendebakpt added the bug Something isn't working label Nov 15, 2024
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

1 participant