qat.experimental.frontend.importer.pulse.builder module
- class PulseKernelBuilder(name, shots=None)
Bases:
objectBase class for importers that translate a program into the Pulse dialect.
Provides common machinery for assembling programs at the pulse-level, which can be used to assemble a pulse-level kernel.
It does not yet support custom control flow constructs, but it provides the ability to pass through the number of shots, and eventually sweep parameters, which is then used to build the structured control flow around the program. Likewise, it does not support parameterisation of arguments in the operations it constructs (or kernel arguments). This is likely to change in the future.
Warning
This is intended for internal compiler use and is not part of the public API. We use it in our importers for pulse-level programs, and it is a useful tool for testing. We cannot guarantee that it will remain stable or supported in future releases. Use with caution.
The builder allows for symbolic construction of frames, waveforms and acquisition results that can be used in subsequent operations. The methods to build operations return the builder instance to allow for method chaining. For example,
kernel = ( PulseKernelBuilder("my_kernel", shots=1000) .create_frame("q0/drive", 4.8e9, "q0") .create_frame("q0/readout", 8.8e9, "r0") .create_frame("q0/acquire", 8.8e9, "r0") .phase_set("q0/drive", 0.0) .phase_set("q0/acquire", 0.0) .create_gaussian_waveform("q0/drive", 0.5, 80e-9, 0.47, False) .create_square_waveform("q0/readout", 0.5, 800e-9) .pulse("q0/drive", "q0/drive") .phase_shift("q0/drive", 1.57) .pulse("q0/drive", "q0/drive") .synchronize("q0/drive", "q0/readout", "q0/acquire") .pulse("q0/readout", "q0/readout") .wait("q0/acquire", 80e-9) .acquire("q0/acquire", "q0_meas", 800e-9, integrate=True) .synchronize("q0/drive", "q0/readout", "q0/acquire") .wait("q0/drive", 500e-6) .synchronize("q0/drive", "q0/readout", "q0/acquire") )
The previous program would implement a simple experiment to drive a qubit and measure it, with a reset time between shots.
Initialise a new PulseKernelBuilder.
- Parameters:
- acquire(frame_name, acquire_name, duration, weights=None, integrate=True)
Add an acquire operation to the pulse block.
- Parameters:
frame_name¶ (
str) – The name of the frame to acquire from.acquire_name¶ (
str) – The name used to track the acquisition result that can be used in post-processing.duration¶ (
float) – The duration of the acquisition.weights¶ (
Optional[list[float|complex]]) – The weights to use for the acquisition.integrate¶ (
bool) – Whether to integrate the acquisition result to give an IQ value.
- Return type:
- Returns:
The PulseKernelBuilder instance for method chaining.
- create_blackman_waveform(waveform_name, amplitude, duration, *drag_coefficients)
Create a Blackman waveform and add it to the pulse block.
- Parameters:
- Return type:
- Returns:
The PulseKernelBuilder instance for method chaining.
- create_custom_waveform(waveform_name, samples, duration)
Create a custom waveform and add it to the pulse block.
- Parameters:
- Return type:
- Returns:
The PulseKernelBuilder instance for method chaining.
- create_frame(frame_name, frequency, port)
Create a new frame and add it to the pulse block.
- Parameters:
- Return type:
- Returns:
The PulseKernelBuilder instance for method chaining.
- create_gaussian_square_waveform(waveform_name, amplitude, duration, fractional_rise, fractional_top_width, regularize=False, drag_coefficient=None)
Create a Gaussian square waveform and add it to the pulse block.
- Parameters:
waveform_name¶ (
str) – The name of the waveform to create.amplitude¶ (
float) – The amplitude of the waveform.duration¶ (
float) – The duration of the waveform.fractional_rise¶ (
float) – Gaussian edge-width proportion in normalized units.fractional_top_width¶ (
float) – Flat-top proportion in normalized units.regularize¶ (
bool) – Whether to regularize the shape at the edges.drag_coefficient¶ (
Optional[float]) – DRAG coefficient. Gaussian-square supports at most one.
- Return type:
- Returns:
The PulseKernelBuilder instance for method chaining.
- create_gaussian_waveform(waveform_name, amplitude, duration, fractional_breadth, regularize=False, *drag_coefficients)
Create a Gaussian waveform and add it to the pulse block.
- Parameters:
waveform_name¶ (
str) – The name of the waveform to create.amplitude¶ (
float) – The amplitude of the waveform.duration¶ (
float) – The duration of the waveform.fractional_breadth¶ (
float) – Gaussian width proportion in normalized units.regularize¶ (
bool) – Whether to regularize the shape at the edges.drag_coefficients¶ (
float) – DRAG coefficients by derivative order, starting at order 1.
- Return type:
- Returns:
The PulseKernelBuilder instance for method chaining.
- create_rounded_square_waveform(waveform_name, amplitude, duration, fractional_top_width, fractional_rise, *drag_coefficients)
Create a rounded square waveform and add it to the pulse block.
- Parameters:
waveform_name¶ (
str) – The name of the waveform to create.amplitude¶ (
float) – The amplitude of the waveform.duration¶ (
float) – The duration of the waveform.fractional_top_width¶ (
float) – Flat-top proportion in normalized units.fractional_rise¶ (
float) – Rise and fall width proportion in normalized units.drag_coefficients¶ (
float) – DRAG coefficients by derivative order, starting at order 1.
- Return type:
- Returns:
The PulseKernelBuilder instance for method chaining.
- create_sech_waveform(waveform_name, amplitude, duration, fractional_breadth, regularize=False, *drag_coefficients)
Create a hyperbolic secant (sech) waveform and add it to the pulse block.
- Parameters:
waveform_name¶ (
str) – The name of the waveform to create.amplitude¶ (
float) – The amplitude of the waveform.duration¶ (
float) – The duration of the waveform.fractional_breadth¶ (
float) – Sech width proportion in normalized units.regularize¶ (
bool) – Whether to regularize the shape at the edges.drag_coefficients¶ (
float) – DRAG coefficients by derivative order, starting at order 1.
- Return type:
- Returns:
The PulseKernelBuilder instance for method chaining.
- create_setup_hold_waveform(waveform_name, amplitude, duration, setup, fractional_rise)
Create a setup hold waveform and add it to the pulse block.
- Parameters:
- Return type:
- Returns:
The PulseKernelBuilder instance for method chaining.
- create_sinusoidal_waveform(waveform_name, amplitude, duration, number_of_periods, internal_phase=0.0, *drag_coefficients)
Create a sinusoidal waveform and add it to the pulse block.
- Parameters:
waveform_name¶ (
str) – The name of the waveform to create.amplitude¶ (
float) – The amplitude of the waveform.duration¶ (
float) – The duration of the waveform.number_of_periods¶ (
float) – Number of periods across the waveform domain.internal_phase¶ (
float) – Internal phase offset in radians.drag_coefficients¶ (
float) – DRAG coefficients by derivative order, starting at order 1.
- Return type:
- Returns:
The PulseKernelBuilder instance for method chaining.
- create_soft_square_waveform(waveform_name, amplitude, duration, fractional_top_width, fractional_rise, regularize=False, *drag_coefficients)
Create a soft square waveform and add it to the pulse block.
- Parameters:
waveform_name¶ (
str) – The name of the waveform to create.amplitude¶ (
float) – The amplitude of the waveform.duration¶ (
float) – The duration of the waveform.fractional_top_width¶ (
float) – Flat-top proportion in normalized units.fractional_rise¶ (
float) – Rise and fall width proportion in normalized units.regularize¶ (
bool) – Whether to regularize the shape at the edges.drag_coefficients¶ (
float) – DRAG coefficients by derivative order, starting at order 1.
- Return type:
- Returns:
The PulseKernelBuilder instance for method chaining.
- create_square_waveform(waveform_name, amplitude, duration)
Create a square waveform and add it to the pulse block.
- Parameters:
- Return type:
- Returns:
The PulseKernelBuilder instance for method chaining.
- finalize()
Finalizes the kernel, adding the surrounding control flow and adding it to a kernel.
- Return type:
- Returns:
The finalized pulse kernel.
- phase_set(frame_name, phase)
Set the phase of a frame.
- Parameters:
- Return type:
- Returns:
The PulseKernelBuilder instance for method chaining.
- phase_shift(frame_name, phase)
Shift the phase of a frame.
- Parameters:
- Return type:
- Returns:
The PulseKernelBuilder instance for method chaining.
- pulse(frame_name, waveform_name)
Add a pulse operation to the pulse block.
- Parameters:
- Return type:
- Returns:
The PulseKernelBuilder instance for method chaining.
- synchronize(*frame_names)
Add a synchronize operation to the pulse block.
- Parameters:
frame_names¶ (
str) – The names of the frames to synchronize.- Return type:
- Returns:
The PulseKernelBuilder instance for method chaining.
- wait(frame_name, duration)
Add a wait operation to the pulse block.
- Parameters:
- Return type:
- Returns:
The PulseKernelBuilder instance for method chaining.