Tutorial 3. Compiling to Hardware#
See also
The complete source code of this tutorial can be found in
Compilation converts a schedule into timing information and backend-specific instructions that can be executed by control hardware.
1. Define a schedule#
from quantify import ClockResource, Schedule
from quantify.operations import SquarePulse
sched = Schedule("simple")
sched.add(SquarePulse(amp=0.2, duration=8e-9, port="q0:res", clock="q0.ro"))
sched.add(SquarePulse(amp=0.1, duration=12e-9, port="q0:res", clock="q0.ro"))
sched.add_resource(ClockResource(name="q0.ro", freq=7e9))
2. Provide device and hardware configs#
A QuantumDevice provides the device configuration. A hardware compilation
config is backend-specific and describes the control hardware and connectivity.
from quantify.backends.mock.mock_rom import (
hardware_compilation_config as mock_hardware_compilation_config,
)
hardware_comp_cfg = mock_hardware_compilation_config
from quantify import BasicTransmonElement, QuantumDevice
quantum_device = QuantumDevice("device")
q0 = BasicTransmonElement("q0")
quantum_device.add_element(q0)
# Minimal parameters for readout
q0.clock_freqs.readout(7e9)
q0.measure.pulse_amp(0.1)
q0.measure.acq_delay(100e-9)
quantum_device.hardware_config(hardware_comp_cfg)
Refer to Hardware backends for backend-specific configuration details.
3. Compile the schedule#
from quantify import SerialCompiler
compiler = SerialCompiler(name="compiler")
config = quantum_device.generate_compilation_config()
compiled = compiler.compile(schedule=sched, config=config)
The returned compiled schedule contains absolute timing and compiled
instructions in compiled.compiled_instructions.
4. Execute with the InstrumentCoordinator#
from quantify import InstrumentCoordinator
from quantify.backends.mock.mock_rom import (
MockReadoutModule,
MockROMInstrumentCoordinatorComponent,
)
ic = InstrumentCoordinator("ic")
rom = MockReadoutModule("mock_rom")
ic.add_component(MockROMInstrumentCoordinatorComponent(mock_rom=rom))
For acquisition details, see Acquisitions.