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 visualization.pulse_v2.device_info required for plotting pulse schedules. #12346

Open
vishal-ph opened this issue May 6, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@vishal-ph
Copy link

vishal-ph commented May 6, 2024

Environment

  • Qiskit version: 1.0.2
  • Python version: 3.11.8
  • Operating system: MacOS Sonoma 14.1

What is happening?

While trying to plot the pulse schedule diagram from a quantum circuit whilst passing the backend object as argument, the plotter fails because the script qiskit.visualization.pulse_v2.device_info.py extracts the backend name as, backend.name() which is not callable anymore.

How can we reproduce the issue?

Code to reproduce the error:

from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister, qasm3, transpile, schedule
from qiskit_ibm_provider import IBMProvider
provider = IBMProvider()
backend = provider.get_backend("ibm_brisbane")

# Quantum Circuit
ckt = QuantumCircuit(3,3)
ckt.h([0])
ckt.cx(0,1)
ckt.cx(0,2)
ckt.measure([0,1,2],[0,1,2])

# transpile the circuit
t_ckt = transpile(ckt, backend=backend)

# obtain pulse schedule and plot
ckt_sched = schedule(t_ckt, backend=backend)
ckt_sched.draw(time_range=(0,1000),time_unit='ns',backend=backend)

This generates the following error message:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[6], line 1
----> 1 ckt_sched.draw(time_range=(0,1000),time_unit='ns',backend=backend)

File ~/anaconda3/envs/new_exp/lib/python3.11/site-packages/qiskit/pulse/schedule.py:1628, in _common_method.<locals>.decorator.<locals>.wrapper(*args, **kwargs)
   1626 @functools.wraps(method)
   1627 def wrapper(*args, **kwargs):
-> 1628     return method(*args, **kwargs)

File ~/anaconda3/envs/new_exp/lib/python3.11/site-packages/qiskit/pulse/schedule.py:1693, in draw(self, style, backend, time_range, time_unit, disable_channels, show_snapshot, show_framechange, show_waveform_info, show_barrier, plotter, axis)
   1690 # pylint: disable=cyclic-import
   1691 from qiskit.visualization import pulse_drawer
-> 1693 return pulse_drawer(
   1694     program=self,
   1695     style=style,
   1696     backend=backend,
   1697     time_range=time_range,
   1698     time_unit=time_unit,
   1699     disable_channels=disable_channels,
   1700     show_snapshot=show_snapshot,
   1701     show_framechange=show_framechange,
   1702     show_waveform_info=show_waveform_info,
   1703     show_barrier=show_barrier,
   1704     plotter=plotter,
   1705     axis=axis,
   1706 )

File ~/anaconda3/envs/new_exp/lib/python3.11/site-packages/qiskit/visualization/pulse_v2/interface.py:386, in draw(program, style, backend, time_range, time_unit, disable_channels, show_snapshot, show_framechange, show_waveform_info, show_barrier, plotter, axis)
    383 temp_style.update(style or stylesheet.IQXStandard())
    385 if backend:
--> 386     device = device_info.OpenPulseBackendInfo.create_from_backend(backend)
    387 else:
    388     device = device_info.OpenPulseBackendInfo()

File ~/anaconda3/envs/new_exp/lib/python3.11/site-packages/qiskit/visualization/pulse_v2/device_info.py:113, in OpenPulseBackendInfo.create_from_backend(cls, backend)
    110 defaults = backend.defaults()
    112 # load name
--> 113 name = backend.name()
    115 # load cycle time
    116 dt = configuration.dt

TypeError: 'str' object is not callable

What should happen?

The code should output and draw the pulse schedule with ns time units.

Any suggestions?

I believe the backend name should be extracted as backend.name here

@vishal-ph vishal-ph added the bug Something isn't working label May 6, 2024
@wagnersj
Copy link
Contributor

wagnersj commented May 6, 2024

Confirming that this bug exists as described by @vishal-ph . The same issue appears to have been corrected elsewhere in Qiskit (e.g. in qiskit/providers/providerutils.py) to adapt between V1 and V2 backend classes.

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

2 participants