Quantum Machine API¶
-
class
QuantumMachine
(machine_id, pb_config, config, manager)¶ -
close
()¶ Closes the quantum machine.
- Returns
True
if the close request succeeded, Raises an exception otherwise.
-
execute
(program, duration_limit=1000, data_limit=20000, force_execution=False, dry_run=False, **kwargs) → qm.QmJob.QmJob¶ Executes a program and returns an job object to keep track of execution and get results.
- Parameters
program – A QUA
program()
object to executeduration_limit (int) – Maximal time (in msec) for which results will be collected. If set to 0, limit will be disabled.
data_limit – Maximal amount of data sends for which results will be collected. If set to 0, If set to 0, limit will be disabled.
Here data sends is either:
4 ADC samples, in case raw data is transferred
a single save operation
Note
Disabling data acquisition limit can lead to a very large amount of data stored in the server and/or user PC.
- Parameters
force_execution (bool) – Execute program even if another program is currently running
dry_run (bool) – compile program but do not run it
No new results will be available to the returned job object When
duration_limit
is reached, or whendata_limit
is reached, whichever occurs sooner.- Returns
A
QmJob
object (see QM Job API).
-
get_config
()¶ Gives the current config of the qm
- Returns
A dictionary with the qm’s config
-
get_dc_offset_by_qe
(qe, input)¶ DEPRECATED This method is deprecated. Use get_output_dc_offset_by_element(..) instead
get the current DC offset of the OPX analog output channel associated with a quantum element.
- Parameters
qe – the name of the element to get the correction for
input – the input name as appears in the element’s config be more specific here
- Returns
the offset, in normalized output units
-
get_digital_buffer
(element, digital_input)¶ get the buffer for digital waveforms of the quantum element
- Parameters
element (str) – the name of the element to get the buffer for
digital_input (str) – the digital input name as appears in the element’s config
- Returns
the buffer
-
get_digital_delay
(element, digital_input)¶ - Parameters
element – the name of the element to get the delay for
digital_input – the digital input name as appears in the element’s config
- Returns
the delay
-
get_input_dc_offset_by_element
(element, output)¶ get the current DC offset of the OPX analog input channel associated with a quantum element.
- Parameters
element – the name of the element to get the correction for
output – the output name as appears in the element’s config be more specific here
- Returns
the offset, in normalized output units
-
get_io1_value
()¶ Gives the data stored in
IO1
No inference is made on type.
- Returns
A dictionary with data stored in
IO1
. (Data is in all three format:int
,float
andbool
)
-
get_io2_value
()¶ Gives the data stored in
IO2
No inference is made on type.
- Returns
A dictionary with data from the second IO register. (Data is in all three format:
int
,float
andbool
)
-
get_io_values
()¶ Gives the data stored in both
IO1
andIO2
No inference is made on type.
- Returns
A list that contains dictionaries with data from the IO registers. (Data is in all three format:
int
,float
andbool
)
-
get_output_dc_offset_by_element
(element, input)¶ get the current DC offset of the OPX analog output channel associated with a quantum element.
- Parameters
element – the name of the element to get the correction for
input – the input name as appears in the element’s config be more specific here
- Returns
the offset, in normalized output units
-
get_smearing
(element)¶ get the smearing associated with a measurement quantum element.
This is a broadening of the raw results acquisition window, to account for dispersive broadening in the measurement elements (readout resonators etc.) The acquisition window will be broadened by this amount on both sides.
- Parameters
element (str) – the name of the element to get smearing for
- Returns
the smearing, in nesc.
-
get_time_of_flight
(element)¶ get the time of flight, associated with a measurement quantum element.
This is the amount of time between the beginning of a measurement pulse applied to quantum element and the time that the data is available to the controller for demodulation or streaming.
- Parameters
element (str) – the name of the element to get time of flight for
- Returns
the time of flight, in nsec
-
list_controllers
()¶ Gives a list with the defined controllers in this qm
- Returns
The names of the controllers configured in this qm
-
save_config_to_file
(filename)¶ Saves the qm current config to a file
- Param
filename: The name of the file where the config will be saved
-
set_correction
(qe, values)¶ DEPRECATED This method is deprecated. Using this method will update the correction for ALL elements that use the same mixer config as the supplied element. Use set_mixer_correction(..) instead.
Sets the correction matrix for correcting gain and phase imbalances of an IQ mixer associated with a quantum element.
- Parameters
qe (str) – the name of the element to update the correction for
values (tuple) – tuple is of the form (v00, v01, v10, v11) where the matrix is | v00 v01 | | v10 v11 |
-
set_dc_offset_by_qe
(qe, input, offset)¶ *DEPRECATED* “This method is deprecated. Use set_output_dc_offset_by_element(..) instead.” * set the current DC offset of the OPX analog output channel associated with a quantum element.
- Parameters
qe (str) – the name of the element to update the correction for
input (str) –
the input name as appears in the element config. Options:
- ’single’
for an element with single input
- ’I’ or ‘Q’
for an element with mixer inputs
offset (float) – the dc value to set to, in normalized output units. Ranges from -0.5 to 0.5 - 2^-16 in steps of 2^-16.
Warning
if the sum of the DC offset and the largest waveform data-point exceed the normalized unit range specified above, DAC output overflow will occur and the output will be corrupted.
-
set_digital_buffer
(element, digital_input, buffer)¶ set the buffer for digital waveforms of the quantum element
- Parameters
element (str) – the name of the element to update buffer for
digital_input (str) – the digital input name as appears in the element’s config
buffer (int) – the buffer value to set to, in nsec. Range: 0 to (255 - delay) / 2, in steps of 1
-
set_digital_delay
(element, digital_input, delay)¶ Sets the delay of the digital waveform of the quantum element
- Parameters
element (str) – the name of the element to update delay for
digital_input (str) – the digital input name as appears in the element’s config
delay (int) – the delay value to set to, in nsec. Range: 0 to 255 - 2 * buffer, in steps of 1
-
set_frequency
(qe, freq)¶ DEPRECATED This method is deprecated. Use set_intermediate_frequency(..) instead
Sets the frequency of an element, at the output of the mixer, taking LO frequency into account.
- Parameters
qe (str) – the name of the element to update the correction for
freq (float) – the frequency to set to the given element
Note
if an intermediate_frequency entry corresponding to
freq
does not exist in the mixer correction list of the mixer corresponding to the quantum element, an entry will be created. The entry will be populated with the values of the current correction matrix.
-
set_input_dc_offset_by_element
(element, output, offset)¶ set the current DC offset of the OPX analog input channel associated with a quantum element.
- Parameters
element (str) – the name of the element to update the correction for
output (str) – the output key name as appears in the element config under ‘outputs’.
offset (float) – the dc value to set to, in normalized input units. Ranges from -0.5 to 0.5 - 2^-16 in steps of 2^-16.
Warning
if the sum of the DC offset and the largest waveform data-point exceed the normalized unit range specified above, DAC output overflow will occur and the output will be corrupted.
-
set_intermediate_frequency
(element, freq)¶ Sets the intermediate frequency of the the quantum element
- Parameters
element (str) – the name of the element whose intermediate frequency will be updated
freq (float) – the intermediate frequency to set to the given element
Note
if an intermediate_frequency entry corresponding to
freq
does not exist in the mixer correction list of the mixer corresponding to the quantum element, an entry will be created. The entry will be populated with the values of the current correction matrix.
-
set_io1_value
(value_1)¶ Sets the value of
IO1
.This can be used later inside a QUA program as a QUA variable
IO1
without declaration. The type of QUA variable is inferred from the python type passed tovalue_1
, according to the following rule:int -> int float -> fixed bool -> bool
- Parameters
value_1 (float | bool | int) – the value to be placed in
IO1
-
set_io2_value
(value_2)¶ Sets the value of
IO1
.This can be used later inside a QUA program as a QUA variable
IO2
without declaration. The type of QUA variable is inferred from the python type passed tovalue_2
, according to the following rule:int -> int float -> fixed bool -> bool
- Parameters
value_1 (float | bool | int) – the value to be placed in
IO1
-
set_io_values
(value_1, value_2)¶ Sets the value of
IO1
andIO2
This can be used later inside a QUA program as a QUA variable
IO1
,IO2
without declaration. The type of QUA variable is inferred from the python type passed tovalue_1
,value_2
, according to the following rule:int -> int float -> fixed bool -> bool
- Parameters
value_1 (float | bool | int) – the value to be placed in
IO1
value_2 (float | bool | int) – the value to be placed in
IO2
-
set_mixer_correction
(mixer, intermediate_frequency, lo_frequency, values)¶ Sets the correction matrix for correcting gain and phase imbalances of an IQ mixer for the supplied intermediate frequency and LO frequency.
- Parameters
mixer (str) – the name of the mixer, as defined in the configuration
intermediate_frequency (long) – the intermediate frequency for which to apply the correction matrix
lo_frequency (long) – the LO frequency for which to apply the correction matrix
values (tuple) – tuple is of the form (v00, v01, v10, v11) where the matrix is | v00 v01 | | v10 v11 |
-
set_output_dc_offset_by_element
(element, input, offset)¶ set the current DC offset of the OPX analog output channel associated with a quantum element.
- Parameters
element (str) – the name of the element to update the correction for
input (str) –
the input name as appears in the element config. Options:
- ’single’
for an element with single input
- ’I’ or ‘Q’
for an element with mixer inputs
offset (float) – the dc value to set to, in normalized output units. Ranges from -0.5 to 0.5 - 2^-16 in steps of 2^-16.
Warning
if the sum of the DC offset and the largest waveform data-point exceed the normalized unit range specified above, DAC output overflow will occur and the output will be corrupted.
-
simulate
(program, simulate, **kwargs)¶ simulate the outputs of a deterministic QUA program.
Equivalent to
execute()
withdry_run=True
andsimulate=SimulationConfig
(see example).Note
A simulated job does not support calling QuantumMachine API functions.
The following example shows a simple execution of the simulator, where the associated config object is omitted for brevity.
Example:
>>> from qm.QuantumMachinesManager import QuantumMachinesManager >>> from qm.qua import * >>> from qm import SimulationConfig >>> >>> qmManager = QuantumMachinesManager() >>> qm1 = qmManager.open_qm(config) >>> >>> with program() as prog: >>> play('pulse1', 'qe1') >>> >>> job = qm1.simulate(prog, SimulationConfig(duration=100))
- Parameters
program – A QUA
program()
object to executesimulate – A
SimulationConfig
configuration objectkwargs – additional parameteres to pass to execute
- Returns
a
QmJob
object (see QM Job API).
-