Qiskit / qiskit

Qiskit is an open-source SDK for working with quantum computers at the level of extended quantum circuits, operators, and primitives.

Home Page:https://www.ibm.com/quantum/qiskit

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unify pulse Commands and Instructions

taalexander opened this issue · comments

What is the expected enhancement?

Pulse Commands were initially created to allow the pulse to be only defined once as a SamplePulse and then have its usage tracked based on the pulse instance. Every Instruction instance was then defined as containing a Command and its Channel operands that the command is applied to.

This change may result in some breaking changes, but I have a couple of ideas to make this mostly backward compatible.

Requirements for closure of this issue include:

Background and Ideas

I believe this has resulted in a confusing API with many statements that look like

PulseCommand(...)(channel1, channel2, ...)

which yields an instruction. Or called more explicitly:

PulseInstruction(PulseCommand(...), channel1, channel2, ...)

If we were to unify commands with instructions a generic instruction would accept a list of operands that could be either a numeric parameter like a complex or a channel to operate on, eg.:

PulseInstruction(operand1, operand2, ...)

For example, a frame change would go from,

FrameChange(0.0)(DriveChannel(0))

or explicitly,

FrameChangeInstruction(FrameChange(0.0), DriveChannel(0))

to

ShiftPhase(0.0, DriveChannel(0))

where ShiftPhase is of type Instruction.

The current behavior of pulses could be fixed by redefining Pulse as a Type and defining a Play instruction:

random_pulse = SamplePulse(np.random.random(10))
Play(random_pulse, DriveChannel(0)