quantify.scheduler

class quantify.scheduler.Operation(name: str, data: dict = None)[source]

A JSON compatible data structure that contains information on how to represent the operation on the Gate, Pulse and/or Logical level. It also contains information on the Resource s used.

An operation always has the following attributes

  • duration (float) : duration of the operation in seconds (can be 0)

  • hash (str) : an auto generated unique identifier.

  • name (str) : a readable identifier, does not have to be unique

An Operation can contain information on several levels of abstraction. This information is used when different representations. Note that when initializing an operation not all of this information needs to be available as operations are typically modified during the compilation steps.

Note

Two different Operations containing the same information generate the same hash and are considered identical.

add_gate_info(gate_operation)[source]

Updates self.data[‘gate_info’] with contents of gate_operation.

Parameters

gate_operation (Operation) – an operation containing gate_info.

add_pulse(pulse_operation)[source]

Adds pulse_info of pulse_operation to self.

Parameters

pulse_operation (Operation) – an operation containing pulse_info.

property duration

Determine the duration of the operation based on the pulses described in pulse_info.

If the operation contains no pulse info, it is assumed to be ideal and have zero duration.

property hash

A hash based on the contents of the Operation.

class quantify.scheduler.Resource(dict=None, /, **kwargs)[source]

A resource corresponds to a physical resource such as an AWG channel, a qubit, or a classical register.

JSON schema for a quantify resource.

type

object

properties

  • name

Name of the resource.

type

string

  • type

Type of the resource, this property can be used by compilation steps.

type

string

additionalProperties

True

class quantify.scheduler.Schedule(name: str, data: dict = None)[source]

A collection of Operation objects and timing contraints that define relations between the operations.

The Schedule data structure is based on a dictionary. This dictionary contains:

operation_dict : a hash table containing the unique Operation s added to the schedule. timing_constraints : a list of all timing constraints added between operations.

JSON schema for a quantify schedule.

type

object

properties

  • name

Name of the schedule.

type

string

  • timing_constraints

A list containing timing constraints.

type

array

  • operation_dict

A dictionary of operations. Keys correspond to the hash attribute of operations.

type

object

  • resource_dict

A dictionary of resources.

type

object

additionalProperties

False

add(operation, rel_time: float = 0, ref_op: str = None, ref_pt: str = 'end', ref_pt_new: str = 'start', label: str = None)str[source]

Add an Operation to the schedule and specify timing constraints.

Parameters
  • operation (Operation) – The operation to add to the schedule

  • rel_time (float) – relative time between the the reference operation and added operation.

  • ref_op (str) – specifies the reference operation.

  • ref_pt (str) – reference point in reference operation must be one of (‘start’, ‘center’, ‘end’).

  • ref_pt_new (str) – reference point in added operation must be one of (‘start’, ‘center’, ‘end’).

  • label (str) – a label that can be used as an identifier when adding more operations.

Returns

returns the (unique) label of the last added operation.

Return type

str

add_resource(resource)[source]

Add a resource such as a channel or qubit to the schedule.

property operations

Operation dictionary, keys are the has of operations values are instances of Operation.

property resources

A dictionary containing resources. Keys are names (str), values are instances of Resource .

property timing_constraints

A list of dictionaries describing timing constraints between operations.

types

class quantify.scheduler.types.Operation(name: str, data: dict = None)[source]

A JSON compatible data structure that contains information on how to represent the operation on the Gate, Pulse and/or Logical level. It also contains information on the Resource s used.

An operation always has the following attributes

  • duration (float) : duration of the operation in seconds (can be 0)

  • hash (str) : an auto generated unique identifier.

  • name (str) : a readable identifier, does not have to be unique

An Operation can contain information on several levels of abstraction. This information is used when different representations. Note that when initializing an operation not all of this information needs to be available as operations are typically modified during the compilation steps.

Note

Two different Operations containing the same information generate the same hash and are considered identical.

add_gate_info(gate_operation)[source]

Updates self.data[‘gate_info’] with contents of gate_operation.

Parameters

gate_operation (Operation) – an operation containing gate_info.

add_pulse(pulse_operation)[source]

Adds pulse_info of pulse_operation to self.

Parameters

pulse_operation (Operation) – an operation containing pulse_info.

property duration

Determine the duration of the operation based on the pulses described in pulse_info.

If the operation contains no pulse info, it is assumed to be ideal and have zero duration.

property hash

A hash based on the contents of the Operation.

class quantify.scheduler.types.Resource(dict=None, /, **kwargs)[source]

A resource corresponds to a physical resource such as an AWG channel, a qubit, or a classical register.

JSON schema for a quantify resource.

type

object

properties

  • name

Name of the resource.

type

string

  • type

Type of the resource, this property can be used by compilation steps.

type

string

additionalProperties

True

class quantify.scheduler.types.Schedule(name: str, data: dict = None)[source]

A collection of Operation objects and timing contraints that define relations between the operations.

The Schedule data structure is based on a dictionary. This dictionary contains:

operation_dict : a hash table containing the unique Operation s added to the schedule. timing_constraints : a list of all timing constraints added between operations.

JSON schema for a quantify schedule.

type

object

properties

  • name

Name of the schedule.

type

string

  • timing_constraints

A list containing timing constraints.

type

array

  • operation_dict

A dictionary of operations. Keys correspond to the hash attribute of operations.

type

object

  • resource_dict

A dictionary of resources.

type

object

additionalProperties

False

add(operation, rel_time: float = 0, ref_op: str = None, ref_pt: str = 'end', ref_pt_new: str = 'start', label: str = None)str[source]

Add an Operation to the schedule and specify timing constraints.

Parameters
  • operation (Operation) – The operation to add to the schedule

  • rel_time (float) – relative time between the the reference operation and added operation.

  • ref_op (str) – specifies the reference operation.

  • ref_pt (str) – reference point in reference operation must be one of (‘start’, ‘center’, ‘end’).

  • ref_pt_new (str) – reference point in added operation must be one of (‘start’, ‘center’, ‘end’).

  • label (str) – a label that can be used as an identifier when adding more operations.

Returns

returns the (unique) label of the last added operation.

Return type

str

add_resource(resource)[source]

Add a resource such as a channel or qubit to the schedule.

property operations

Operation dictionary, keys are the has of operations values are instances of Operation.

property resources

A dictionary containing resources. Keys are names (str), values are instances of Resource .

property timing_constraints

A list of dictionaries describing timing constraints between operations.

gate_library

class quantify.scheduler.gate_library.CNOT(qC: str, qT: str)[source]

Conditional-NOT gate, a common entangling gate.

Performs an X gate on the target qubit qT conditional on the state of the control qubit qC.

This operation can be represented by the following unitary:

\[\begin{split}\mathrm{CNOT} = \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \ \end{bmatrix}\end{split}\]
class quantify.scheduler.gate_library.CZ(qC: str, qT: str)[source]

Conditional-phase gate, a common entangling gate.

Performs a Z gate on the target qubit qT conditional on the state of the control qubit qC.

This operation can be represented by the following unitary:

\[\begin{split}\mathrm{CZ} = \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & -1 \ \end{bmatrix}\end{split}\]
class quantify.scheduler.gate_library.Measure(*qubits)[source]

A projective measurement in the Z-basis.

Note

strictly speaking this is not a gate as it can not be described by a unitary.

class quantify.scheduler.gate_library.Reset(*qubits)[source]

Reset a qubit to the \(|0\rangle\) state.

Note

strictly speaking this is not a gate as it can not be described by a unitary.

class quantify.scheduler.gate_library.Rxy(theta: float, phi: float, qubit: str)[source]

A single qubit rotation around an axis in the equator of the Bloch sphere.

This operation can be represented by the following unitary:

\[\begin{split}\mathsf {R}_{xy} \left(\theta, \varphi\right) = \begin{bmatrix} \textrm {cos}(\theta /2) & -ie^{-i\varphi }\textrm {sin}(\theta /2) \\ -ie^{i\varphi }\textrm {sin}(\theta /2) & \textrm {cos}(\theta /2) \end{bmatrix}\end{split}\]
class quantify.scheduler.gate_library.X(qubit)[source]

A single qubit rotation of 180 degrees around the X-axis.

This operation can be represented by the following unitary:

\[\begin{split}X = \sigma_x = \begin{bmatrix} 0 & 1 \\ 1 & 0 \ \end{bmatrix}\end{split}\]
class quantify.scheduler.gate_library.X90(qubit)[source]

A single qubit rotation of 90 degrees around the X-axis.

class quantify.scheduler.gate_library.Y(qubit)[source]

A single qubit rotation of 180 degrees around the Y-axis.

\[\begin{split}\mathsf Y = \sigma_y = \begin{bmatrix} 0 & -i \\ i & 0 \end{bmatrix}\end{split}\]
class quantify.scheduler.gate_library.Y90(qubit)[source]

A single qubit rotation of 90 degrees around the Y-axis.

pulse_library

class quantify.scheduler.pulse_library.DRAGPulse(G_amp: float, D_amp: float, phase: float, freq_mod: float, duration: float, ch, t0: float = 0)[source]

DRAG pulse inteded for single qubit gates in transmon based systems.

A DRAG pulse is a gaussian pulse with a derivative component added to the out-of-phase channel to reduce unwanted excitations of the \(|1\rangle - |2\rangle\) transition.

The waveform is generated using waveforms.drag() .

References

  1. Gambetta, J. M., Motzoi, F., Merkel, S. T. & Wilhelm, F. K. Analytic control methods for high-fidelity unitary operations in a weakly nonlinear oscillator. Phys. Rev. A 83, 012308 (2011).

  1. F. Motzoi, J. M. Gambetta, P. Rebentrost, and F. K. Wilhelm Phys. Rev. Lett. 103, 110501 (2009).

class quantify.scheduler.pulse_library.IdlePulse(duration)[source]

An idle pulse performing no actions for a certain duration.

class quantify.scheduler.pulse_library.ModSquarePulse(amp: float, duration: float, ch: str, phase: float = 0, freq_mod: float = 0, t0: float = 0)[source]
class quantify.scheduler.pulse_library.NumericPulse(t0)[source]
class quantify.scheduler.pulse_library.SoftSquarePulse(amp: float, duration: float, ch, t0: float = 0)[source]

Place holder pulse for mocking the CZ pulse until proper implementation. Replicates parameters.

class quantify.scheduler.pulse_library.SquarePulse(amp: float, duration: float, ch, t0: float = 0)[source]

resources

class quantify.scheduler.resources.CompositeResource(name: str, resource_names: list)[source]

A channel composed of multiple resources.

The compiler backend is responsible for using this resource to map operations to the relevant sub-channels.

Tip

A relevant use-case of this class is when making use of sequencer units in the Pulsar_QCM. The user can make specify this composite channel to play pulses, while the backend compiler ensures the pulses get distributed to the relevant sequencer resources.

class quantify.scheduler.resources.Pulsar_QCM_sequencer(name: str, instrument_name: str, seq_idx: int, nco_freq: float = 0, nco_phase: float = 0)[source]

A single sequencer unit contained in a Pulsar_QCM module.

For pulse-sequencing purposes, the Pulsar_QCM_sequencer can be considered a channel capabable of outputting complex valued signals (I, and Q).

property timing_tuples

A list of timing tuples con

class quantify.scheduler.resources.Pulsar_QRM_sequencer(name: str, instrument_name: str, seq_idx: int, nco_freq: float = 0, nco_phase: float = 0)[source]
property timing_tuples

A list of timing tuples con

waveforms

quantify.scheduler.waveforms.drag(t, G_amp: float, D_amp: float, duration: float, nr_sigma: int = 3, phase: float = 0, subtract_offset: str = 'average')[source]

Generates a DRAG pulse consisting of a Gaussian \(G\) as the I- and a Derivative \(D\) as the Q-component.

All inputs are in s and Hz. phases are in degree.

\(G(t) = G_{amp} e^{- \frac{(t-\mu)^2}{2\sigma^2}}\).

\(D(t) = -D_{amp} \frac{(t-\mu)}{\sigma} G(t)\).

Parameters
  • t (numpy.ndarray) – times at which to evaluate the function

  • G_amp (float) – Amplitude of the Gaussian envelope.

  • D_amp (float) – Amplitude of the derivative component, the DRAG-pulse parameter.

  • duration (float) – Duration of the pulse in seconds.

  • nr_sigma (int) – After how many sigma the Gaussian is cut off.

  • phase (float) – Phase of the pulse in degrees.

  • subtract_offset (str) –

    Instruction on how to subtract the offset in order to avoid jumps in the waveform due to the cut-off.

    • ’average’: subtract the average of the first and last point.

    • ’first’: subtract the value of the waveform at the first sample.

    • ’last’: subtract the value of the waveform at the last sample.

    • ’none’, None: don’t subtract any offset.

Returns

complex waveform

Return type

numpy.ndarray

References

  1. Gambetta, J. M., Motzoi, F., Merkel, S. T. & Wilhelm, F. K. Analytic control methods for high-fidelity unitary operations in a weakly nonlinear oscillator. Phys. Rev. A 83, 012308 (2011).

  1. F. Motzoi, J. M. Gambetta, P. Rebentrost, and F. K. Wilhelm Phys. Rev. Lett. 103, 110501 (2009).

quantify.scheduler.waveforms.modulate_wave(t, wave, freq_mod)[source]

Apply single sideband (SSB) modulation to a waveform.

The frequency convention we adhere to is:

freq_base + freq_mod = freq_signal

Parameters
  • t (numpy.ndarray) – times at which to determine the modulation.

  • wave (numpy.ndarray) – complex waveform, real component corresponds to I, imag component to Q.

  • freq_mod (float) – modulation frequency in Hz.

Returns

mod_wave – modulated waveform.

Return type

numpy.ndarray

Note

Pulse modulation is generally not included when specifying waveform envelopes as there are many hardware backends include this capability.

quantify.scheduler.waveforms.rotate_wave(wave, phase: float)[source]

Rotate a wave in the complex plane.

Parameters
  • wave (numpy.ndarray) – complex waveform, real component corresponds to I, imag component to Q.

  • phase (float) – rotation angle in degrees

Returns

quantify.scheduler.waveforms.square(t, amp)[source]

A square pulse.

compilation

quantify.scheduler.compilation.qcompile(schedule: quantify.scheduler.types.Schedule, device_cfg: dict, backend: Callable = None, **kwargs)[source]

Compile and assemble a schedule into deployables.

Parameters
  • schedule (Schedule) – To be compiled

  • device_cfg (dict) – Specifying the required pulse information. The device_cfg schema is specified in

  • backend (Callable) – To the compiler, assembles the program(s).

Returns

schedule – The prepared schedule if no backend is provided, otherwise whatever object returned by the backend

Return type

Schedule

Configuration specification

JSON schema for a transmon based device configuration.

type

object

properties

  • qubits

Single qubit configuration.

type

object

  • edges

Two qubit configuration.

type

object

additionalProperties

False

quantify.scheduler.compilation.validate_config(config: dict, scheme_fn: str)[source]

Validate a configuration using a schema.

Parameters
  • config (dict) – The configuration to validate

  • scheme_fn (str) – The name of a json schema in the quantify.scheduler.schemas folder.

Returns

True if valid

Return type

bool

frontends

quantify.scheduler.frontends.openQL_sequencer_frontend(filename: str)[source]

Reads an OpenQL cQASM file and converts

backends

pulsar_backend

class quantify.scheduler.backends.pulsar_backend.PulsarModulations(gain, gain_Q, offset, phase, phase_delta)
gain

Alias for field number 0

gain_Q

Alias for field number 1

offset

Alias for field number 2

phase

Alias for field number 3

phase_delta

Alias for field number 4

class quantify.scheduler.backends.pulsar_backend.Q1ASMBuilder[source]

Generates a q1asm program instruction by instruction. Handles splitting overflowing operation times.

get_str()[source]
Returns

The program

Return type

str

quantify.scheduler.backends.pulsar_backend.build_q1asm(timing_tuples: list, pulse_dict: dict, sequence_duration: int, acquisitions: set)str[source]

Converts operations and waveforms to a q1asm program. This function verifies these hardware based constraints:

  • Each pulse must run for at least the INSTRUCTION_CLOCK_TIME

  • Each operation must have a timing separation of at least INSTRUCTION_CLOCK_TIME

Parameters
  • timing_tuples (list) – A sorted list of tuples matching timings to pulse_IDs.

  • pulse_dict (dict) – pulse_IDs to numerical waveforms with registered index in waveform memory.

  • sequence_duration (int) – maximum runtime of this sequence

  • acquisitions (set) – set of pulse_IDs which are acquisitions

Returns

A q1asm program in a string.

quantify.scheduler.backends.pulsar_backend.build_waveform_dict(pulse_info: dict, acquisitions: set)dict[source]

Allocates numerical pulse representation to indices and formats for sequencer JSON.

Parameters
  • pulse_info (dict) – Pulse ID to array-like numerical representation

  • acquisitions (set) – set of pulse_IDs which are acquisitions

Returns

Dictionary mapping pulses to numerical representation and memory index

quantify.scheduler.backends.pulsar_backend.configure_pulsar_sequencers(config_dict: dict)[source]

Configures multiple pulsar modules based on a configuration dictionary.

Parameters

config_dict (dict) – Dictionary with resource_names as keys and filenames of sequencer config json files as values.

quantify.scheduler.backends.pulsar_backend.generate_sequencer_cfg(pulse_info, timing_tuples, sequence_duration: int, acquisitions: set)[source]

Generate a JSON compatible dictionary for defining a sequencer configuration. Contains a list of waveforms and a program in a q1asm string.

Parameters
  • pulse_info (dict) – mapping of pulse IDs to numerical waveforms

  • timing_tuples (list) – time ordered list of tuples containing the (absolute starting time, pulse ID, modulations)

  • sequence_duration (int) – maximum runtime of this sequence

  • acquisitions (set) – set of pulse IDs which are acquisitions

Returns

Sequencer configuration

quantify.scheduler.backends.pulsar_backend.pulsar_assembler_backend(schedule, tuid=None, configure_hardware=False, debug=False)[source]

Create sequencer configuration files for multiple Qblox pulsar modules.

Sequencer configuration files contain assembly, a waveform dictionary and the parameters to be configured for every pulsar sequencer.

The sequencer configuration files are stored in the quantify datadir (see get_datadir())

Parameters
  • schedule (Schedule :) – The schedule to convert into assembly.

  • tuid (TUID :) – a tuid of the experiment the schedule belongs to. If set to None, a new TUID will be generated to store the sequencer configuration files.

  • configure_hardware (bool) – if True will configure the hardware to run the specified schedule.

  • debug (bool) – if True will produce extra debug output

Returns

  • schedule (Schedule :) – The schedule

  • config_dict (dict) – of sequencer names as keys with json filenames as values

Note

Currently only supports the Pulsar_QCM module. Does not yet support the Pulsar_QRM module.

visualization

quantify.scheduler.backends.visualization.circuit_diagram_matplotlib(schedule, figsize=None)[source]

Creates a circuit diagram visualization of a schedule using matplotlib.

For this visualization backend to work, the schedule must contain gate_info for each operation in the operation_dict as well as a value for abs_time for each element in the timing_constraints.

Parameters
  • schedule (Schedule) – the schedule to render.

  • figsize (tuple) – matplotlib figsize.

Returns

  • matplotlib figure object.

  • matplotlib axis object.

Return type

tuple

quantify.scheduler.backends.visualization.pulse_diagram_plotly(schedule, ch_list: list = None, fig_ch_height: float = 150, fig_width: float = 1000, modulation: bool = True, sampling_rate: float = 1000000000.0)[source]

Produce a plotly visualization of the pulses used in the schedule.

Parameters
  • schedule (Schedule) – the schedule to render

  • ch_list (list) – A list of channels to show. if set to None will use the first 8 channels it encounters in the sequence.

  • fig_ch_height (float) – height for each channel subplot in px

  • fig_width (float) – width for the figure in px

  • modulation (bool) – determines if modulation is included in the visualization

  • sampling_rate (float) – the time resolution used in the visualization.

Returns

the plot

Return type

plotly.graph_objects.Figure

visualization

circuit_diagram

quantify.scheduler.visualization.pulse_scheme.box_text(ax, x0, y0, text='', w=1.1, h=0.8, color='black', fillcolor=None, textcolor='black', fontsize=None)[source]

Draws a box filled with text at the specified position.

quantify.scheduler.visualization.pulse_scheme.fluxPulse(ax, pos, y_offs=0, width=2.5, s=0.1, amp=1.5, label=None, label_height=1.7, color='C1', **plot_kws)[source]

Draw a smooth flux pulse, where the rising and falling edges are given by Fermi-Dirac functions. s: smoothness of edge

quantify.scheduler.visualization.pulse_scheme.interval(ax, start, stop, y_offs=0, height=1.5, label=None, label_height=None, vlines=True, color='k', arrowstyle='<|-|>', **plot_kws)[source]

Draw an arrow to indicate an interval.

quantify.scheduler.visualization.pulse_scheme.meter(ax, x0, y0, y_offs=0, w=1.1, h=0.8, color='black', fillcolor=None)[source]

Draws a measurement meter on the specified position.

quantify.scheduler.visualization.pulse_scheme.mwPulse(ax, pos, y_offs=0, width=1.5, amp=1, label=None, phase=0, label_height=1.3, color='C0', modulation='normal', **plot_kws)[source]

Draw a microwave pulse: Gaussian envelope with modulation.

quantify.scheduler.visualization.pulse_scheme.new_pulse_fig(figsize=None)[source]

Open a new figure and configure it to plot pulse schemes.

quantify.scheduler.visualization.pulse_scheme.new_pulse_subplot(fig, *args, **kwargs)[source]

Add a new subplot configured for plotting pulse schemes to a figure.

All *args and **kwargs are passed to fig.add_subplot.

quantify.scheduler.visualization.pulse_scheme.ramZPulse(ax, pos, y_offs=0, width=2.5, s=0.1, amp=1.5, sep=1.5, color='C1')[source]

Draw a Ram-Z flux pulse, i.e. only part of the pulse is shaded, to indicate cutting off the pulse at some time.

circuit_diagram

quantify.scheduler.visualization.pulse_scheme.box_text(ax, x0, y0, text='', w=1.1, h=0.8, color='black', fillcolor=None, textcolor='black', fontsize=None)[source]

Draws a box filled with text at the specified position.

quantify.scheduler.visualization.pulse_scheme.fluxPulse(ax, pos, y_offs=0, width=2.5, s=0.1, amp=1.5, label=None, label_height=1.7, color='C1', **plot_kws)[source]

Draw a smooth flux pulse, where the rising and falling edges are given by Fermi-Dirac functions. s: smoothness of edge

quantify.scheduler.visualization.pulse_scheme.interval(ax, start, stop, y_offs=0, height=1.5, label=None, label_height=None, vlines=True, color='k', arrowstyle='<|-|>', **plot_kws)[source]

Draw an arrow to indicate an interval.

quantify.scheduler.visualization.pulse_scheme.meter(ax, x0, y0, y_offs=0, w=1.1, h=0.8, color='black', fillcolor=None)[source]

Draws a measurement meter on the specified position.

quantify.scheduler.visualization.pulse_scheme.mwPulse(ax, pos, y_offs=0, width=1.5, amp=1, label=None, phase=0, label_height=1.3, color='C0', modulation='normal', **plot_kws)[source]

Draw a microwave pulse: Gaussian envelope with modulation.

quantify.scheduler.visualization.pulse_scheme.new_pulse_fig(figsize=None)[source]

Open a new figure and configure it to plot pulse schemes.

quantify.scheduler.visualization.pulse_scheme.new_pulse_subplot(fig, *args, **kwargs)[source]

Add a new subplot configured for plotting pulse schemes to a figure.

All *args and **kwargs are passed to fig.add_subplot.

quantify.scheduler.visualization.pulse_scheme.ramZPulse(ax, pos, y_offs=0, width=2.5, s=0.1, amp=1.5, sep=1.5, color='C1')[source]

Draw a Ram-Z flux pulse, i.e. only part of the pulse is shaded, to indicate cutting off the pulse at some time.