Transpiler scheduling passes (qiskit_ibm_runtime.transpiler.passes.scheduling)

A collection of scheduling passes for working with IBM Quantum’s next-generation backends that support advanced “dynamic circuit” capabilities. Ie., circuits with support for classical control-flow/feedback based off of measurement results. For more information on dynamic circuits, see our Classical feedforward and control flow guide.

Warning

You should not mix these scheduling passes with Qiskit’s built in scheduling passes as they will negatively interact with the scheduling routines for dynamic circuits. This includes setting scheduling_method in transpile() or generate_preset_pass_manager().

Classes

BlockBasePadder

The base class of padding pass.

ALAPScheduleAnalysis

Dynamic circuits as-late-as-possible (ALAP) scheduling analysis pass.

ASAPScheduleAnalysis

Dynamic circuits as-soon-as-possible (ASAP) scheduling analysis pass.

DynamicCircuitInstructionDurations

For dynamic circuits the IBM Qiskit backend currently reports instruction durations that differ compared with those required for the legacy Qobj-based path.

PadDelay

Padding idle time with Delay instructions.

PadDynamicalDecoupling

Dynamical decoupling insertion pass for IBM dynamic circuit backends.

Example usage

Below we demonstrate how to schedule and pad a teleportation circuit with delays for a dynamic circuit backend’s execution model:

from qiskit.circuit import ClassicalRegister, QuantumCircuit, QuantumRegister
from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager
from qiskit.transpiler.passmanager import PassManager

from qiskit_ibm_runtime.transpiler.passes.scheduling import ALAPScheduleAnalysis
from qiskit_ibm_runtime.transpiler.passes.scheduling import PadDelay
from qiskit_ibm_runtime.fake_provider import FakeJakartaV2

backend = FakeJakartaV2()

# Use this duration class to get appropriate durations for dynamic
# circuit backend scheduling
# Generate the main Qiskit transpile passes.
pm = generate_preset_pass_manager(optimization_level=1, backend=backend)
# Configure the as-late-as-possible scheduling pass
pm.scheduling = PassManager([
    ALAPScheduleAnalysis(target=backend.target),
    PadDelay(target=backend.target)]
    )

qr = QuantumRegister(3)
crz = ClassicalRegister(1, name="crz")
crx = ClassicalRegister(1, name="crx")
result = ClassicalRegister(1, name="result")

teleport = QuantumCircuit(qr, crz, crx, result, name="Teleport")

teleport.h(qr[1])
teleport.cx(qr[1], qr[2])
teleport.cx(qr[0], qr[1])
teleport.h(qr[0])
teleport.measure(qr[0], crz)
teleport.measure(qr[1], crx)
with teleport.if_test((crz, 1)):
    teleport.z(qr[2])
with teleport.if_test((crx, 1)):
    teleport.x(qr[2])
teleport.measure(qr[2], result)

# Transpile.
scheduled_teleport = pm.run(teleport)

scheduled_teleport.draw(output="mpl", style="iqp")

(Source code, png, hires.png, pdf)

Circuit diagram output by the previous code.

Instead of padding with delays we may also insert a dynamical decoupling sequence using the PadDynamicalDecoupling pass as shown below:

from qiskit.circuit.library import XGate

from qiskit_ibm_runtime.transpiler.passes.scheduling import PadDynamicalDecoupling


dd_sequence = [XGate(), XGate()]

pm = generate_preset_pass_manager(optimization_level=1, backend=backend)
pm.scheduling = PassManager(
    [
        ALAPScheduleAnalysis(target=backend.target),
        PadDynamicalDecoupling(target=backend.target, dd_sequences=dd_sequence),
    ]
)

dd_teleport = pm.run(teleport)

dd_teleport.draw(output="mpl", style="iqp")

(Source code, png, hires.png, pdf)

Circuit diagram output by the previous code.

When compiling a circuit with Qiskit, it is more efficient and more robust to perform all the transformations in a single transpilation. This has been done above by extending Qiskit’s preset pass managers. For example, Qiskit’s transpile() function internally builds its pass set by using generate_preset_pass_manager(). This returns instances of StagedPassManager, which can be extended.