qiskit-community / qiskit-hackathon-singapore-19

11 stars 5 forks source link

Enhance pulse visualization module #4

Closed nkanazawa1989 closed 4 years ago

nkanazawa1989 commented 5 years ago

Abstract

All quantum circuits are made up of sequence of microwave pulses. Recently we released OpenPulse, which is a new module in qiskit terra, enabling programming of quantum circuits at a level of microwave pulses. Circuit visualizers have been improved to provide better usability. Likewise, improvement of pulse visualizer is very important.

Description

The PR Qiskit/qiskit-terra#2650 will introduce QuantumCircuit to pulse Schedule converter, namely pulse scheduler. Output of pulse scheduler may become a very long pulse Schedule, and the default pulse visualizer dosen't deal with such long pulse Schedule.

Let's see the examples.

User-defined pulse visualization

User can create custom microwave pulses in OpenPulse, and these pulses are added to pulse Schedule. Manually created Schedules are usually not long, and pulse visualizer will give you sufficient output to understand what is happening in your experiment.

my_pulse = pulse_lib.gaussian(duration=30, sigma=5, amp=0.1, name='my_pulse')

sched = pulse.Schedule()
sched |= my_pulse(system.drives[0])
sched.draw(scaling=5, label=True)

index3

Small circuit-pulse visualization

When we convert relatively small QuantumCircuit, e.g. generating two qubit entangle, the pulse visualizer output is still easier viewing.

q = QuantumRegister(2, 'q')
qc = QuantumCircuit(q)
qc.h(q[0])
qc.cx(q[0], q[1])
qc.draw(output='mpl')

(input) image

qc_primitive = transpile(qc, basis_gates=['u1', 'u2', 'u3', 'cx'])
sched = schedule(qc_primitive, backend)
sched.draw(scaling=5, label=True)

(output) index

d is drive channel to control quantum state of the target qubit, and u is control channel to control two qubit interaction. Because pulses in these channels are complex numbers, real and imaginary parts are differentiated by tone of a color. Rotation symbols indicate Frame Change instruction, which gives phase shift of following pulse.

Large circuit-pulse visualization

When we convert a large QuantumCircuit, such as QFT circuits, the output figure is very hard to see.

q = QuantumRegister(3, 'q')
qc = QuantumCircuit(q)
qc.h(q[0])
qc.cu1(pi/2.0, q[1], q[0])
qc.h(q[1])
qc.cu1(pi/4.0, q[2], q[0])
qc.cu1(pi/2.0, q[2], q[1])
qc.h(q[2])
qc.draw(output='mpl')

(input) image

qc_primitive = transpile(qc, backend=backend)
sched = schedule(qc_primitive, backend)
sched.draw(scaling=5, table=False, label=True)

(output) index2

As you can see, the output is jammed with pulses and we cannot see the detail of each pulse shape. We are still able to optimize the visualization with several options, e.g. plot_range and channels_to_plot are useful, but, in contrast to circuit visualizer, this is not user-friendly. In such long Schedule case, it is also very hard to intuitively understand what is happening.

The project

It's relatively easy project to work on, without any expertise in quantum information and physics. IBM coach will provide some target Schedule objects to visualize, and the team will create new/enhance existing visualizer to have well-organized and easy viewing output. We prefer to use matplotlib as a visualizer backend.

If you have a background of visualization or graphic design, that would help to improve quality of deliverables.

Members

-

Deliverable

OpenPulse visualizer

GitHub repo

tbd

LSJHOPE commented 4 years ago

I want to join