2
$\begingroup$

I'm trying to reproduce the Bell-state pulse display as shown in this tutorial. The code is very short:

bell = QuantumCircuit(2, 2)
bell.h(0)
bell.cx(0,1)
qc = transpile(bell,backend)
sched_circ = schedule(qc,backend)
sched_circ.draw()

but if I use the backend ibmq_armonk there are not enough qubits and, for ibmq_qasm_simulator, Qiskit-pulse is not supported. Is there a way to get it working? I do not need to run the waveforms on a device - I just want to analyze them.

P.S. If anyone has a compact IO protocol writing/reading scheduler pulses for multi-qubit Qiskit circuits in HD5 format I'd be interested to collaborate.

Follow up: After I upgraded my qiskit to ver 0.25.3 the backend=FakeOpenPulse2Q() works exactly as suggested below. Thanks for the help. Jan

$\endgroup$
1
$\begingroup$

You can use fake pulse backend to do this.

from qiskit.circuit import QuantumCircuit
import matplotlib.pyplot as plt
from qiskit.test.mock import FakeOpenPulse2Q
backend = FakeOpenPulse2Q()
from qiskit import transpile, schedule 
bell = QuantumCircuit(2, 2)
bell.h(0)
bell.cx(0,1)
qc = transpile(bell,backend)
pulse_schedule = schedule(qc, backend)

fig, ax = plt.subplots(figsize=(14, 10))
pulse_schedule.draw('IQXDebugging', axis = ax, show_waveform_info = True)

You will get something like below:

enter image description here

$\endgroup$
3
  • $\begingroup$ Brilliant! Thanks a lot. A minor follow-up. I run a stand-alone python script (no Jupyter). Is there a way to control the Matplotlib 'ax' - the default sched_circ.draw() takes all the screen. Idealy, I'd like sth like this: '''import matplotlib.pyplot as plt plt.figure(figsize=(8, 6)) ax = plt.subplot(1, 1, 1) sched_circ.draw(plot_range=[0, 400],ax=ax) plt.show() ''' but 'ax' or 'axis' is not on the list of sched_circ.draw.__code__.co_varnames $\endgroup$ – Jan Balewski May 7 at 15:44
  • $\begingroup$ I edited the answer to include the change of fig size. :) Also look here for more details: qiskit.org/documentation/stubs/… $\endgroup$ – KAJ226 May 7 at 17:03
  • 1
    $\begingroup$ thank you for the advice - all work for me now as I wanted. (My Qiskit vers was too old - I updated it). If anyone is interested in collaborating on storing multi-qubit circuit waveforms as HD5 please contact me. $\endgroup$ – Jan Balewski May 7 at 17:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.