Skip to content

QUA Statements Reference

qm.qua._dsl.program

Create a QUA program.

Used within a context manager, the program is defined in the code block below with statement.

Statements in the code block below are played as soon as possible, meaning that an instruction will be played immediately unless it is dependent on a previous instruction. Additionally, commands output to the same elements will be played sequentially, and to different elements will be played in parallel. An exception is that pulses will be implicitly aligned at the end of each for_ loop iteration.

The generated program_name object is used as an input to the execute function of a qm.QuantumMachine object.

Example
with program() as program_name:
    play('pulse1', 'element1')
    wait('element1')

qm.execute(program_name)

where qm is an instance of a qm.QuantumMachine

qm.qua._dsl.play

Play a pulse based on an 'operation' defined in element.

The pulse will be modified according to the properties of the element (see detailed explanation about pulse modifications below), and then played to the OPX output(s) defined to be connected to the input(s) of the element in the configuration.

PARAMETER DESCRIPTION
pulse

The name of an operation to be performed, as defined in the element in the quantum machine configuration. Can also be a ramp function or be multiplied by an ramp.

TYPE: str

element

The name of the element, as defined in the quantum machine configuration.

TYPE: str

duration

The time to play this pulse in units of the clock cycle (4ns). If not provided, the default pulse duration will be used. It is possible to dynamically change the duration of both constant and arbitrary pulses. Arbitrary pulses can only be stretched, not compressed.

TYPE: Union[int,QUA variable of type int] DEFAULT: None

chirp

Allows to perform piecewise linear sweep of the element’s intermediate frequency in time. Input should be a tuple, with the 1st element being a list of rates and the second should be a string with the units. The units can be either: ‘Hz/nsec’, ’mHz/nsec’, ’uHz/nsec’, ’pHz/nsec’ or ‘GHz/sec’, ’MHz/sec’, ’KHz/sec’, ’Hz/sec’, ’mHz/sec’.

TYPE: Union[list[int], str, int, str] DEFAULT: None

truncate

Allows playing only part of the pulse, truncating the end. If provided, will play only up to the given time in units of the clock cycle (4ns).

TYPE: Union[int, QUA variable of type int] DEFAULT: None

condition

Will play the operation only if the condition is true.

TYPE: A logical expression to evaluate. DEFAULT: None

timestamp_stream

(Supported from QOP 2.2) Adding a timestamp_stream argument will save the time at which the operation occurred to a stream. If the timestamp_stream is a string label, then the timestamp handle can be retrieved with qm._results.JobResults.get with the same label.

TYPE: Union[str, _ResultSource] DEFAULT: None

Note

Arbitrary waveforms cannot be compressed and can only be expanded up to \(2^{24}-1\) clock cycles (67ms). Unexpected output will occur if a duration outside the range is given. See Dynamic pulse duration in the documentation for further information.

Note

When using chrip, it is possible to add a flag "continue_chirp=True" to the play command. When this flag is set, the internal oscillator will continue the chirp even after the play command had ended. See the `chirp documentation chirp documentation for more information.

Example
with program() as prog:
    v1 = declare(fixed)
    assign(v1, 0.3)
    play('pulse1', 'element1')
    play('pulse1' * amp(0.5), 'element1')
    play('pulse1' * amp(v1), 'element1')
    play('pulse1' * amp(0.9, v1, -v1, 0.9), 'element_iq_pair')
    time_stream = declare_stream()
    # Supported on QOP2.2+
    play('pulse1', f'element1', duration=16, timestamp_stream='t1')
    play('pulse1', f'element1', duration=16, timestamp_stream=time_stream)
    with stream_processing():
        stream.buffer(10).save_all('t2')

qm.qua._dsl.pause

Pause the execution of the job until qm.jobs.running_qm_job.RunningQmJob.resume is called.

The quantum machines freezes on its current output state.

qm.qua._dsl.update_frequency

Dynamically update the frequency of the oscillator associated with a given element.

This changes the frequency from the value defined in the quantum machine configuration.

The behavior of the phase (continuous vs. coherent) is controlled by the keep_phase parameter and is discussed in the documentation.

PARAMETER DESCRIPTION
element

The element associated with the oscillator whose frequency will be changed

TYPE: str

new_frequency

The new frequency value to set in units set by units parameter. In steps of 1.

TYPE: int

units

units of new frequency. Useful when sub-Hz precision is required. Allowed units are "Hz", "mHz", "uHz", "nHz", "pHz"

TYPE: str DEFAULT: 'Hz'

keep_phase

Determine whether phase will be continuous through the change (if True) or it will be coherent, only the frequency will change (if False).

TYPE: bool DEFAULT: False

Example
with program() as prog:
    update_frequency("q1", 4e6) # will set the frequency to 4 MHz

    ### Example for sub-Hz resolution
    update_frequency("q1", 100.7) # will set the frequency to 100 Hz (due to casting to int)
    update_frequency("q1", 100700, units='mHz') # will set the frequency to 100.7 Hz

qm.qua._dsl.update_correction

Updates the correction matrix used to overcome IQ imbalances of the IQ mixer for the next pulses played on the element

Note

Make sure to update the correction after you called update_frequency

Note

Calling update_correction will also reset the frame of the oscillator associated with the element.

PARAMETER DESCRIPTION
element

The element associated with the oscillator whose correction matrix will change

TYPE: str

c00

The top left matrix element

TYPE: Union[float,QUA variable of type real]

c01

The top right matrix element

TYPE: Union[float,QUA variable of type real]

c10

The bottom left matrix element

TYPE: Union[float,QUA variable of type real]

c11

The bottom right matrix element

TYPE: Union[float,QUA variable of type real]

Example
with program() as prog:
    update_correction("q1", 1.0, 0.5, 0.5, 1.0)

qm.qua._dsl.set_dc_offset

Set the DC offset of an element's input to the given value. This value will remain the DC offset until changed or until the Quantum Machine is closed. The offset value remains until it is changed or the Quantum Machine is closed.

-- Available from QOP 2.0 --

PARAMETER DESCRIPTION
element

The element to update its DC offset

TYPE: str

element_input

The desired input of the element, can be 'single' for a 'singleInput' element or 'I' or 'Q' for a 'mixInputs' element

TYPE: str

offset

The offset to set

TYPE: QuaNumberType

qm.qua._dsl.measure

Perform a measurement of element using pulse based on 'operation' as defined in the 'element'.

An element for which a measurement is applied must have outputs defined in the configuration.

A measurement consists of:

  1. playing an operation to the element (identical to a :func:play statement)

  2. waiting for a duration of time defined as the time_of_flight in the configuration of the element, and then sampling the returning pulse. The OPX input to be sampled is defined in the configuration of the element.

  3. Processing the aqcuired data according to a parameter defined in the measure command, including Demodulation, Integration and Time Tagging.

For a more detailed description of the measurement operation, see Measure Statement Features

PARAMETER DESCRIPTION
pulse

The name of an operation to be performed, as defined in the element in the quantum machine configuration. Pulse must have a measurement operation. Can also be multiplied by an amp.

TYPE: str

element

name of the element, as defined in the quantum machine configuration. The element must have outputs.

TYPE: str

stream

The stream variable which the raw ADC data will be saved and will appear in result analysis scope. You can receive the results with qm.QmJob.result_handles.get("name"). A string name can also be used. In this case, the name of the result handle should be suffixed by _input1 for data from analog input 1 and _input2 for data from analog input 2.

If stream is set to None, raw results will not be saved (note: must be explicitly set to None). The raw results will be saved as long as the digital pulse that is played with pulse is high.

!!! Warning:

Streaming adc data without declaring the stream with `declare_stream(adc_trace=true)` might cause performance issues

TYPE: Union[str, _ResultSource] DEFAULT: None

*outputs

A parameter specifying the processing to be done on the ADC data, there are multiple options available, including demod(), integration() & time_tagging().

TYPE: tuple DEFAULT: ()

timestamp_stream

(Supported from QOP 2.2) Adding a timestamp_stream argument will save the time at which the operation occurred to a stream. If the timestamp_stream is a string label, then the timestamp handle can be retrieved with qm.results.streaming_result_fetcher.StreamingResultFetcher with the same label.

TYPE: Union[str, _ResultSource] DEFAULT: None

Example
with program() as prog:
    I = declare(fixed)
    Q = declare(fixed)
    adc_st = declare_stream(adc_trace=True)

    # measure by playing 'meas_pulse' to element 'resonator', do not save raw results.
    # demodulate data from "out1" port of 'resonator' using 'cos_weights' and store result in I, and also
    # demodulate data from "out1" port of 'resonator' using 'sin_weights' and store result in Q
    measure('meas_pulse', 'resonator', None, demod.full("cos_weights", I, "out1"), demod.full("sin_weights", Q, "out1"))

    # measure by playing 'meas_pulse' to element 'resonator', save raw results to `adc_st`
    # demodulate data from 'out1' port of 'resonator' using 'optimized_weights' and store result in I
    measure('meas_pulse', 'resonator', adc_st, demod.full("optimized_weights", I, "out1"))
    with stream_processing():
        adc_st.input1().save_all("raw_adc_stream")

from qm import QuantumMachinesManager
qm = QuantumMachinesManager().open_qm(config)
job = qm.execute(prog)
# ... we wait for the results to be ready...
job.result_handles.wait_for_all_values()
# raw results can be retrieved as follows (here job is a QmJob object:
raw_I_handle = job.result_handles.get("raw_adc_stream")

qm.qua._dsl.align

Align several elements together.

All the elements referenced in elements will wait for all the others to finish their currently running statement.

If no arguments are given, the statement will align all the elements used in the program.

PARAMETER DESCRIPTION
*elements

a single element, multiple elements, or none

TYPE: str DEFAULT: ()

qm.qua._dsl.reset_phase

Resets the phase of the oscillator associated with element, setting the phase of the next pulse to absolute zero. This sets the phase of the currently playing intermediate frequency to the value it had at the beginning of the program (t=0).

Note
  • The phase will only be set to zero when the next play or align command is executed on the element.
  • Reset phase will only reset the phase of the intermediate frequency (:math:\\omega_{IF}) currently in use.
PARAMETER DESCRIPTION
element

an element

TYPE: str

qm.qua._dsl.ramp_to_zero

Starting from the last DC value, gradually lowers the DC to zero for duration *4nsec

If duration is None, the duration is taken from the element's config

Warning

This feature does not protect from voltage jumps. Those can still occur, i.e. when the data sent to the analog output is outside the range -0.5 to \(0.5 - 2^{16}\) and thus will have an overflow.

PARAMETER DESCRIPTION
element

element for ramp to zero

TYPE: str

duration

time , in multiples of 4nsec. Range: [4, \(2^{24}\)] in steps of 1, or None to take value from config

TYPE: Union[int, None] DEFAULT: None

qm.qua._dsl.wait

Wait for the given duration on all provided elements without outputting anything. Duration is in units of the clock cycle (4ns)

PARAMETER DESCRIPTION
duration

time to wait in units of the clock cycle (4ns). Range: [4, \(2^{31}-1\)] in steps of 1.

TYPE: Union[int,QUA variable of type int]

*elements

elements to wait on

TYPE: Union[str,sequence of str] DEFAULT: ()

Warning

In case the value of this is outside the range above, unexpected results may occur.

Note

The purpose of the wait operation is to add latency. In most cases, the latency added will be exactly the same as that specified by the QUA variable or the literal used. However, in some cases an additional computational latency may be added. If the actual wait time has significance, such as in characterization experiments, the actual wait time should always be verified with a simulator.

qm.qua._dsl.wait_for_trigger

Wait for an external trigger on the provided element.

During the command the OPX will play the pulse supplied by the pulse_to_play parameter

PARAMETER DESCRIPTION
element

element to wait on

TYPE: str

pulse_to_play

the name of the pulse to play on the element while waiting for the external trigger. Must be a constant pulse. Default None, no pulse will be played.

TYPE: str DEFAULT: None

trigger_element

Available only with the OPD. The triggered element. See further details in the note.

TYPE: Union[str, tuple] DEFAULT: None

time_tag_target

Available only with the OPD. The time at which the trigger arrived relative to the waiting start time. In ns.

TYPE: QUA variable of type int DEFAULT: None

Warning

In the OPX - The maximum allowed voltage value for the digital trigger is 1.8V. A voltage higher than this can damage the controller.

In the OPX+ and with the OPD - The maximum allowed voltage is 3.3V.

Note

Read more about triggering with the OPD here

qm.qua._dsl.save

Stream a QUA variable, a QUA array cell, or a constant scalar. the variable is streamed and not immediately saved (see Stream processing). In case result_or_tag is a string, the data will be immediately saved to a result handle under the same name.

If result variable is used, it can be used in results analysis scope see stream_processing if string tag is used, it will let you receive result with qm.QmJob.result_handles. The type of the variable determines the stream datatype, according to the following rule:

  • int -> int64
  • fixed -> float64
  • bool -> bool
Note

Saving arrays as arrays is not currently supported. Please use a QUA for loop to save an array.

Example
# basic save
a = declare(int, value=2)
save(a, "a")

# fetching the results from python (job is a QmJob object):
a_handle = job.result_handles.get("a")
a_data = a_handle.fetch_all()

# save the third array cell
vec = declare(fixed, value=[0.2, 0.3, 0.4, 0.5])
save(vec[2], "ArrayCellSave")

# array iteration
i = declare(int)
array = declare(fixed, value=[x / 10 for x in range(30)])
with for_(i, 0, i < 30, i + 1):
    save(array[i], "array")

# save a constant
save(3, "a")
PARAMETER DESCRIPTION
var

A QUA variable or a QUA array cell to save

TYPE: Union[QUA variable, a QUA array cell]

stream_or_tag

A stream variable or string tag name to save the value under

TYPE: Union[str, stream variable]

qm.qua._dsl.frame_rotation

Shift the phase of the oscillator associated with an element by the given angle.

This is typically used for virtual z-rotations.

Note

The fixed point format of QUA variables of type fixed is 4.28, meaning the phase must be between \(-8\) and \(8-2^{28}\). Otherwise the phase value will be invalid. It is therefore better to use frame_rotation_2pi() which avoids this issue.

Note

The phase is accumulated with a resolution of 16 bit. Therefore, N changes to the phase can result in a phase (and amplitude) inaccuracy of about :math:N \cdot 2^{-16}. To null out this accumulated error, it is recommended to use reset_frame(el) from time to time.

PARAMETER DESCRIPTION
angle

The angle to add to the current phase (in radians)

TYPE: Union[float, QUA variable of type fixed]

*elements

a single element whose oscillator's phase will be shifted. multiple elements can be given, in which case all of their oscillators' phases will be shifted

TYPE: str DEFAULT: ()

qm.qua._dsl.frame_rotation_2pi

Shift the phase of the oscillator associated with an element by the given angle in units of 2pi radians.

This is typically used for virtual z-rotations.

Note

Unlike the case of frame_rotation(), this method performs the 2-pi radian wrap around of the angle automatically.

Note

The phase is accumulated with a resolution of 16 bit. Therefore, N changes to the phase can result in a phase inaccuracy of about :math:N \cdot 2^{-16}. To null out this accumulated error, it is recommended to use reset_frame(el) from time to time.

PARAMETER DESCRIPTION
angle

The angle to add to the current phase (in \(2\pi\) radians)

TYPE: Union[float,QUA variable of type real]

*elements

a single element whose oscillator's phase will be shifted. multiple elements can be given, in which case all of their oscillators' phases will be shifted

TYPE: str DEFAULT: ()

qm.qua._dsl.fast_frame_rotation

Shift the phase of the oscillator associated with an element by applying the rotation matrix [[cosine, -sine],[sin, cosine]].

This is typically used for virtual z-rotations.

-- Available from QOP 2.2 --

Note

The phase is accumulated with a resolution of 16 bit. Therefore, N changes to the phase can result in a phase (and amplitude) inaccuracy of about :math:N \cdot 2^{-16}. To null out this accumulated error, it is recommended to use reset_frame(el) from time to time.

PARAMETER DESCRIPTION
cosine

The main diagonal values of the rotation matrix

TYPE: Union[float,QUA variable of type real]

sine

The bottom left rotation matrix element and minus the top right rotation matrix element value

TYPE: Union[float,QUA variable of type real]

*elements

A single element whose oscillator's phase will be shifted. multiple elements can be given, in which case all of their oscillators' phases will be shifted

TYPE: str DEFAULT: ()

qm.qua._dsl.reset_frame

Resets the frame of the oscillator associated with an element to 0.

Used to reset all of the frame updated made up to this statement.

PARAMETER DESCRIPTION
*elements

a single element whose oscillator's phase will be reset. multiple elements can be given, in which case all of their oscillators' phases will be reset

TYPE: str DEFAULT: ()

qm.qua._dsl.assign

Set the value of a given QUA variable, or of a QUA array cell

PARAMETER DESCRIPTION
var

A QUA variable or a QUA array cell for which to assign

TYPE: QUA variable

_exp

An expression for which to set the variable

TYPE: QUA expression

Example::

with program() as prog:
    v1 = declare(fixed)
    assign(v1, 1.3)
    play('pulse1' * amp(v1), 'element1')

qm.qua._dsl.switch_

Part of the switch-case flow control statement in QUA.

To be used with a context manager.

The code block inside should be composed of only case_() and default_() statements, and there should be at least one of them.

The expression given in the switch_() statement will be evaluated and compared to each of the values in the case_() statements. The QUA code block following the case_() statement which evaluated to true will be executed. If none of the statements evaluated to true, the QUA code block following the default_() statement (if given) will be executed.

PARAMETER DESCRIPTION
expression

An expression to evaluate

TYPE: QuaExpressionType

unsafe

If set to True, then switch-case would be more efficient and would produce less gaps. However, if an input which does not match a case is given, unexpected behavior will occur. Cannot be used with the default_() statement. Default is false, use with care.

TYPE: bool DEFAULT: False

Example
x=declare(int)
with switch_(x):
    with case_(1):
        play('first_pulse', 'element')
    with case_(2):
        play('second_pulse', 'element')
    with case_(3):
        play('third_pulse', 'element')
    with default_():
        play('other_pulse', 'element')

qm.qua._dsl.case_

Part of the switch-case flow control statement in QUA.

To be used with a context manager.

Must be inside a switch_() statement.

The expression given in the switch_() statement will be evaluated and compared to each of the values in the case_() statements. The QUA code block following the case_() statement which evaluated to true will be executed. If none of the statements evaluated to true, the QUA code block following the default_() statement (if given) will be executed.

PARAMETER DESCRIPTION
case_exp

A value (or expression) to compare to the expression in the switch_() statement

TYPE: TypeOrExpression[AllPyTypes]

Example
x=declare(int)
with switch_(x):
    with case_(1):
        play('first_pulse', 'element')
    with case_(2):
        play('second_pulse', 'element')
    with case_(3):
        play('third_pulse', 'element')
    with default_():
        play('other_pulse', 'element')

qm.qua._dsl.default_

Part of the switch-case flow control statement in QUA.

To be used with a context manager.

Must be inside a switch_() statement, and there can only be one default_() statement.

The expression given in the switch_() statement will be evaluated and compared to each of the values in the case_() statements. The QUA code block following the case_() statement which evaulated to true will be executed. If none of the statements evaluated to true, the QUA code block following the default_() statement (if given) will be executed.

Example
x=declare(int)
with switch_(x):
    with case_(1):
        play('first_pulse', 'element')
    with case_(2):
        play('second_pulse', 'element')
    with case_(3):
        play('third_pulse', 'element')
    with default_():
        play('other_pulse', 'element')

qm.qua._dsl.if_

If flow control statement in QUA.

To be used with a context manager.

The QUA code block following the statement will be executed only if the expression given evaluates to true.

PARAMETER DESCRIPTION
expression

A boolean expression to evaluate

TYPE: QuaExpressionType

Example
x=declare(int)
with if_(x>0):
    play('pulse', 'element')

qm.qua._dsl.elif_

Else-If flow control statement in QUA.

To be used with a context manager.

Must appear after an if_() statement.

The QUA code block following the statement will be executed only if the expressions in the preceding if_() and elif_() statements evaluates to false and if the expression given in this elif_() evaluates to true.

PARAMETER DESCRIPTION
expression

A boolean expression to evaluate

TYPE: QuaExpressionType

Example
x=declare(int)
with if_(x>2):
    play('pulse', 'element')
with elif_(x>-2):
    play('other_pulse', 'element')
with else_():
    play('third_pulse', 'element')

qm.qua._dsl.else_

Else flow control statement in QUA.

To be used with a context manager.

Must appear after an if_() statement.

The QUA code block following the statement will be executed only if the expressions in the preceding if_() and elif_() statements evaluates to false.

Example
x=declare(int)
with if_(x>0):
    play('pulse', 'element')
with else_():
    play('other_pulse', 'element')

qm.qua._dsl.for_each_

Flow control: Iterate over array elements in QUA.

It is possible to either loop over one variable, or over a tuple of variables, similar to the zip style iteration in python.

To be used with a context manager.

PARAMETER DESCRIPTION
var

The iteration variable

TYPE: Union[QUA variable, tuple of QUA variables]

values

A list of values to iterate over or a QUA array.

TYPE: Union[list of literals, tuple of lists of literals, QUA array, tuple of QUA arrays]

Example
x=declare(fixed)
y=declare(fixed)
with for_each_(x, [0.1, 0.4, 0.6]):
    play('pulse' * amp(x), 'element')
with for_each_((x, y), ([0.1, 0.4, 0.6], [0.3, -0.2, 0.1])):
    play('pulse1' * amp(x), 'element')
    play('pulse2' * amp(y), 'element')
Warning

This behavior is not exactly consistent with python zip. Instead of sending a list of tuple as values, the function expects a tuple of lists. The first list containing the values for the first variable, and so on.

qm.qua._dsl.while_

While loop flow control statement in QUA.

To be used with a context manager.

PARAMETER DESCRIPTION
cond

an expression which evaluates to a boolean variable, determines if to continue to next loop iteration

TYPE: QUA expression DEFAULT: None

Example
x = declare(int)
assign(x, 0)
with while_(x<=30):
    play('pulse', 'element')
    assign(x, x+1)

qm.qua._dsl.for_

For loop flow control statement in QUA.

To be used with a context manager.

PARAMETER DESCRIPTION
var

QUA variable used as iteration variable

TYPE: QUA variable DEFAULT: None

init

an expression which sets the initial value of the iteration variable

TYPE: QUA expression DEFAULT: None

cond

an expression which evaluates to a boolean variable, determines if to continue to next loop iteration

TYPE: QUA expression DEFAULT: None

update

an expression to add to var with each loop iteration

TYPE: QUA expression DEFAULT: None

Example
x = declare(fixed)
with for_(var=x, init=0, cond=x<=1, update=x+0.1):
    play('pulse', 'element')

qm.qua._dsl.infinite_loop_

Infinite loop flow control statement in QUA.

To be used with a context manager.

Optimized for zero latency between iterations, provided that no more than a single element appears in the loop.

Note

In case multiple elements need to be used in an infinite loop, it is possible to add several loops in parallel (see example). Two infinite loops cannot share an element nor can they share variables.

Example
with infinite_loop_():
    play('pulse1', 'element1')
with infinite_loop_():
    play('pulse2', 'element2')

qm.qua._dsl.L

Creates an expression with a literal value

PARAMETER DESCRIPTION
value

int, float or bool to wrap in a literal expression

qm.qua._dsl.DeclarationType

qm.qua._dsl.declare

Declare a single QUA variable or QUA vector to be used in subsequent expressions and assignments.

Declaration is performed by declaring a python variable with the return value of this function.

PARAMETER DESCRIPTION
t

The type of QUA variable. Possible values: int, fixed, bool, where:

int a signed 32-bit number fixed a signed 4.28 fixed point number bool either True or False

TYPE: VariableDeclarationType

value

An initial value for the variable or a list of initial values for a vector

TYPE: Optional[OneOrMore[AllPyTypes]] DEFAULT: None

size

If declaring a vector without explicitly specifying a value, this parameter is used to specify the length of the array

TYPE: Optional[PyNumberType] DEFAULT: None

RETURNS DESCRIPTION
QuaVariableType

The variable or vector

Warning

some QUA statements accept a variable with a valid range smaller than the full size of the generic QUA variable. For example, amp() accepts numbers between -2 and 2. In case the value stored in the variable is larger than the valid input range, unexpected results may occur.

Example
a = declare(fixed, value=0.3)
play('pulse' * amp(a), 'element')

array1 = declare(int, value=[1, 2, 3])
array2 = declare(fixed, size=5)

qm.qua._dsl.declare_input_stream

Declare a QUA variable or a QUA vector to be used as an input stream from the job to the QUA program.

Declaration is performed by declaring a python variable with the return value of this function.

Declaration is similar to the normal QUA variable declaration. See declare for available parameters.

See Input streams for more information.

-- Available from QOP 2.0 --

Example
tau = declare_input_stream(int)
...
advance_input_stream(tau)
play('operation', 'element', duration=tau)

qm.qua._dsl.advance_input_stream

Advances the input stream pointer to the next available variable/vector.

If there is no new data waiting in the stream, this command will wait until it is available.

The variable/vector can then be used as a normal QUA variable.

See Input streams for more information.

-- Available from QOP 2.0 --

qm.qua._dsl.declare_stream

Declare a QUA output stream to be used in subsequent statements To retrieve the result - it must be saved in the stream processing block.

Declaration is performed by declaring a python variable with the return value of this function.

Note

if the stream is an ADC trace, declaring it with the syntax declare_stream(adc_trace=True) will add a buffer of length corresponding to the pulse length.

RETURNS DESCRIPTION
A

class:_ResultSource object to be used in

TYPE: _ResultSource

_ResultSource

stream_processing

Example
a = declare_stream()
measure('pulse', 'element', a)

with stream_processing():
    a.save("tag")
    a.save_all("another tag")

qm.qua._dsl.amp

To be used only within a play or measure command, as a multiplication to the operation.

It is possible to scale the pulse's amplitude dynamically by using the following syntax:

play('pulse_name' * amp(v), 'element')

where v is QUA variable of type fixed. Range of v: -2 to \(2 - 2^{-16}\) in steps of \(2^{-16}\).

Moreover, if the pulse is intended to a mixedInputs element and thus is defined with two waveforms, the two waveforms, described as a column vector, can be multiplied by a matrix:

play('pulse_name' * amp(v_00, v_01, v_10, v_11), 'element'),

where v_ij, i,j={0,1}, are QUA variables of type fixed. Note that v_ij should satisfy -2 <= v_ij <= \(2 - 2{-16}\).

Note that scaling in this manner, rather than in the configuration, might result in a computational overhead. See QUA Best Practice Guide for more information.

PARAMETER DESCRIPTION
v1

If only this variable is given, it is the scaler amplitude factor which multiples the pulse associated with the operation. If all variables are given, then it is the first element in the amplitude matrix which multiples the pulse associated with the operation.

TYPE: QuaNumberType

v2

The second element in the amplitude matrix which multiples the pulse associated with the operation.

TYPE: Optional[QuaNumberType] DEFAULT: None

v3

The third element in the amplitude matrix which multiples the pulse associated with the operation.

TYPE: Optional[QuaNumberType] DEFAULT: None

v4

The forth element in the amplitude matrix which multiples the pulse associated with the operation.

TYPE: Optional[QuaNumberType] DEFAULT: None

qm.qua._dsl.ramp

To be used only within a play command, instead of the operation.

It’s possible to generate a voltage ramp by using the ramp(slope) command. The slope argument is specified in units of V/ns. Usage of this feature is as follows:

play(ramp(0.0001),'qe1',duration=1000)

.. note: The pulse duration must be specified if the ramp feature is used.

PARAMETER DESCRIPTION
v

The slope in units of V/ns

qm.qua._dsl.strict_timing_

Any QUA command written within the strict timing block will be required to to play without gaps.

See the documentation for further information and examples.

To be used with a context manager.

-- Available from QOP 2.0 --

qm.qua._dsl.RealAccumulationMethod

A base class for specifying the integration and demodulation processes in the measure statement. These are the options which can be used inside the measure command as part of the demod and integration processes.

accumulated

Same as sliced(), however the accumulated result of the demodulation/integration is saved in each array cell. See Accumulated demodulation.

PARAMETER DESCRIPTION
iw

integration weights

TYPE: str

target

variable to which demod result is saved

TYPE: QUA array

samples_per_chunk

The number of ADC samples to be used for each chunk is this number times 4.

TYPE: int

element_output

(optional) the output of an element from which to get ADC results

TYPE: str DEFAULT: ''

full

Perform an ordinary demodulation/integration. See Full demodulation.

PARAMETER DESCRIPTION
iw

integration weights

TYPE: str

target

variable to which demod result is saved

TYPE: QUA variable

element_output

(optional) the output of an element from which to get ADC results

TYPE: str DEFAULT: ''

moving_window

Same as sliced(), however the several chunks are accumulated and saved to each array cell. See Moving window demodulation.

PARAMETER DESCRIPTION
iw

integration weights

TYPE: str

target

variable to which demod result is saved

TYPE: QUA array

samples_per_chunk

The number of ADC samples to be used for each chunk is this number times 4.

TYPE: int

chunks_per_window

The number of chunks to use in the moving window

TYPE: int

element_output

(optional) the output of an element from which to get ADC results

TYPE: str DEFAULT: ''

sliced

Perform a demodulation/integration in which the demodulation/integration process is split into chunks and the value of each chunk is saved in an array cell. See Sliced demodulation.

PARAMETER DESCRIPTION
iw

integration weights

TYPE: str

target

variable to which demod result is saved

TYPE: QUA array

samples_per_chunk

The number of ADC samples to be used for each chunk is this number times 4.

TYPE: int

element_output

(optional) the output of an element from which to get ADC results

TYPE: str DEFAULT: ''

qm.qua._dsl.DualAccumulationMethod

A base class for specifying the dual integration and demodulation processes in the :func:measure statement. These are the options which can be used inside the measure command as part of the dual_demod and dual_integration processes.

accumulated

This feature is currently not supported in QUA

full

Perform an ordinary dual demodulation/integration. See Dual demodulation.

PARAMETER DESCRIPTION
iw1

integration weights to be applied to element_output1

TYPE: str

element_output1

the output of an element from which to get ADC results

TYPE: str

iw2

integration weights to be applied to element_output2

TYPE: str

element_output2

the output of an element from which to get ADC results

TYPE: str

target

variable to which demod result is saved

TYPE: QUA variable

moving_window

This feature is currently not supported in QUA

sliced

This feature is currently not supported in QUA

qm.qua._dsl.TimeTagging

A base class for specifying the time tagging process in the measure statement. These are the options which can be used inside the measure command as part of the time_tagging process.

analog

Performs time tagging. See Time tagging.

PARAMETER DESCRIPTION
target

The QUA array into which the times of the detected pulses are saved (in ns)

TYPE: QUA array of type int

max_time

The time in which pulses are detected (Must be larger than the pulse duration)

TYPE: QUA int

targetLen

A QUA int which will get the number of pulses detected

TYPE: QUA int DEFAULT: None

element_output

the output of an element from which to get the pulses

TYPE: str DEFAULT: ''

digital

Performs time tagging from the attached OPD. See Time tagging.

-- Available with the OPD addon --

PARAMETER DESCRIPTION
target

The QUA array into which the times of the detected pulses are saved (in ns)

TYPE: QUA array of type int

max_time

The time in which pulses are detected (Must be larger than the pulse duration)

TYPE: QUA int

targetLen

A QUA int which will get the number of pulses detected

TYPE: QUA int DEFAULT: None

element_output

the output of an element from which to get the pulses

TYPE: str DEFAULT: ''

high_res

Performs high resolution time tagging. See Time tagging.

-- Available from QOP 2.0 --

PARAMETER DESCRIPTION
target

The QUA array into which the times of the detected pulses are saved (in ps)

TYPE: QUA array of type int

max_time

The time in which pulses are detected (Must be larger than the pulse duration)

TYPE: QUA int

targetLen

A QUA int which will get the number of pulses detected

TYPE: QUA int DEFAULT: None

element_output

the output of an element from which to get the pulses

TYPE: str DEFAULT: ''

qm.qua._dsl.Counting

A base class for specifying the counting process in the measure statement. These are the options which can be used inside the measure command as part of the counting process.

-- Available with the OPD addon --

digital

Performs counting from the attached OPD. See Time tagging.

-- Available with the OPD addon --

PARAMETER DESCRIPTION
target

A QUA int which will get the number of pulses detected

TYPE: QUA int

max_time

The time in which pulses are detected (Must be larger than the pulse duration)

TYPE: QUA int

element_outputs

the outputs of an element from which to get ADC results

TYPE: str DEFAULT: ''

qm.qua._dsl.stream_processing

A context manager for the creation of Stream processing pipelines

Each pipeline defines an analysis process that is applied to every stream item. A pipeline must be terminated with a save/save_all terminal, and then can be retrieved with QmJob.result_handles.

There are two save options: save_all will save every stream item, save will save only last item.

A pipeline can be assigned to python variable, and then reused on other pipelines. It is ensured that the common part of the pipeline is processed only once.

Creating a results analysis
with stream_processing():
    a.save("tag")
    a.save_all("another tag")
Retrieving saved result
QmJob.result_handles.get("tag")