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.
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.
Arbitrary waveforms cannot be compressed and can only be expanded up to
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
withprogram()asprog: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)withstream_processing():stream.buffer(10).save_all('t2')
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:strDEFAULT:'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:boolDEFAULT:False
Example
withprogram()asprog:update_frequency("q1",4e6)# will set the frequency to 4 MHz### Example for sub-Hz resolutionupdate_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
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
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:
playing an operation to the element (identical to a :func:play statement)
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.
Processing the aqcuired data according to a parameter defined in the measure command,
including Demodulation, Integration and Time Tagging.
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
A parameter specifying the processing to be
done on the ADC data, there are multiple options available,
including demod(), integration() & time_tagging().
TYPE:tupleDEFAULT:()
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.
withprogram()asprog: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 Qmeasure('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 Imeasure('meas_pulse','resonator',adc_st,demod.full("optimized_weights",I,"out1"))withstream_processing():adc_st.input1().save_all("raw_adc_stream")fromqmimportQuantumMachinesManagerqm=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")
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.
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 and thus will have an overflow.
PARAMETER
DESCRIPTION
element
element for ramp to zero
TYPE:str
duration
time , in multiples of 4nsec.
Range: [4, ] in steps of 1, or None to take
value from config
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, ]
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.
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 savea=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 cellvec=declare(fixed,value=[0.2,0.3,0.4,0.5])save(vec[2],"ArrayCellSave")# array iterationi=declare(int)array=declare(fixed,value=[x/10forxinrange(30)])withfor_(i,0,i<30,i+1):save(array[i],"array")# save a constantsave(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
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 and . 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
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 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
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
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.
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
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.
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.
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.
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.
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.
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.
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 in steps of .
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:
where v_ij, i,j={0,1}, are QUA variables of type fixed.
Note that v_ij should satisfy -2 <= v_ij <= .
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.
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.
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.
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
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.
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.
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.
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.