semi_cr.core.quam_components package¶
Submodules¶
semi_cr.core.quam_components.cryo_switch module¶
- class semi_cr.core.quam_components.cryo_switch.CryoSwitch(*, in_channel: InOutSingleChannel, channels: dict[str, InOutSingleChannel], amplitude: float = 0.1, intermediate_frequency: int = 100000000, readout_length: int = 1000)[source]¶
Bases:
QuamComponentQUAM component for a cryogenic RF switch / multiplexer.
Groups multiple
InOutSingleChannelinstances and exposes helpers to drive them together inside QUA programs (frequency sweeps, alignment, simultaneous measurements, etc.).- channels¶
Mapping from logical channel names to in/out reflectometry channels.
- in_channel: InOutSingleChannel¶
- wait(duration: QuaVariable[int] | QuaLiteral[int] | QuaBinaryOperation[int] | QuaArrayCell[int] | QuaArrayLength[int] | QuaLibFunctionOutput[int] | QuaFunctionOutput[int] | QuaBroadcast[int] | _QuaGlobalVarOperation[int] | int) None[source]¶
Wait on all selected channels without outputting a pulse.
- update_frequency(new_frequency: QuaVariable[int] | QuaLiteral[int] | QuaBinaryOperation[int] | QuaArrayCell[int] | QuaArrayLength[int] | QuaLibFunctionOutput[int] | QuaFunctionOutput[int] | QuaBroadcast[int] | _QuaGlobalVarOperation[int] | int, units: str = 'Hz', keep_phase: bool = False) None[source]¶
Update the intermediate frequency on all selected channels.
- apply_to_config(config: dict) None¶
Add information to the QUA configuration, such as pulses and waveforms.
- Parameters:
config – The QUA configuration dictionary. Initially this is a nearly empty dictionary, but
Note
This function is called by [QuamRoot.generate_config][quam.core.quam_classes.QuamRoot.generate_config].
Note
The config has a starting template, defined at [quam.core.qua_config_template][]
- get_attr_name(attr_val: Any) str¶
Get the name of an attribute that matches the value.
- Parameters:
attr_val – The value of the attribute.
- Returns:
The name of the attribute.
- Raises:
AttributeError if not found. –
- get_attrs(follow_references: bool = False, include_defaults: bool = True) Dict[str, Any]¶
Get all attributes and corresponding values of this object.
- Parameters:
follow_references – Whether to follow references when getting the value. If False, the reference will be returned as a string.
include_defaults – Whether to include attributes that have the default value.
- Returns:
A dictionary of attribute names and values.
- get_raw_value(attr: str) Any¶
Get the value of an attribute without following references.
If the value is a reference, the reference string is returned
- get_reference(attr: str | None = None, relative_path: str | None = None, follow_chain: bool = False) str | None¶
Get the reference path of this object or one of its attributes.
- Parameters:
attr – The optional attribute to get the reference path for. If None, the reference path of the object itself is returned.
relative_path – The optional relative path to join with the reference path.
follow_chain – If True and attr is a reference, follow the reference chain to return the ultimate target reference. Default is False for backward compatibility. Only applies when attr is specified.
- Returns:
The reference path of this object or the specified attribute.
- Raises:
ValueError – If both attr and relative_path are specified, or if follow_chain is True but attr is not a reference.
Examples
We assume a QuamRoot object with a component “elem”. - elem.get_reference() == “#/elem” - elem.get_reference(attr=”child”) == “#/elem/child” - elem.get_reference(relative_path=”#./child”) == “#/elem/child” - elem.get_reference(relative_path=”#../child”) == “#/child” - elem.get_reference(relative_path=”#./child/grandchild”) == “#/elem/child/grandchild”
With follow_chain=True (if attr contains a reference to another reference): - elem.get_reference(attr=”chain_ref”, follow_chain=True) # returns ultimate target
- get_root() QuamRoot | None¶
Get the QuamRoot object of this object.
This function recursively searches the parent chain for a QuamRoot object. If no QuamRoot object is found, it will return the last instantiated QuamRoot if it exists, else None.
- Returns:
The root of this object, or None if no root is found.
- property inferred_id: str | int¶
Get the id of this object inferred from its
idfield or parent position.If this object has a dataclass field named
idwith a concrete (non-reference, non-None) value, that value is returned. Otherwise the attribute name or key under which this object is stored in its parent is returned.- Returns:
The explicit id if set, or the attribute name / key in the parent as a string.
- Raises:
AttributeError – If no explicit id is set and this object has no parent.
- iterate_components(skip_elems: Sequence[QuamBase] | None = None) Generator[QuamBase, None, None]¶
Iterate over all QuamBase objects in this object, including nested objects.
- Parameters:
skip_elems – A sequence of QuamBase objects to skip. This is used to prevent infinite loops when iterating over nested objects.
- Returns:
A generator of QuamBase objects.
- parent: ClassVar[QuamBase]¶
Descriptor for the parent attribute of QuamBase.
This descriptor is used to ensure that the parent attribute of a QuamBase object is not overwritten. This is to prevent the following situation:
``` parent1 = QuamBase() parent2 = QuamBase()
child = QuamBase() child.parent = parent1 # This is fine child.parent = parent2 # This raises an AttributeError ```
- print_summary(indent: int = 0)¶
Print a summary of the QuamBase object.
- Parameters:
indent – The number of spaces to indent the summary.
- set_at_reference(attr: str, value: Any, allow_non_reference: bool = True)¶
Follow the reference of an attribute and set the value at the reference.
This method follows reference chains recursively. If an attribute contains a reference to another reference, both references are preserved while the ultimate target value is updated.
- Parameters:
attr – The attribute to set the value at the reference of.
value – The value to set.
allow_non_reference – Whether to allow the attribute to be a non-reference. If True (default), non-reference attributes are allowed. If False, the attribute must be a reference or an error is raised.
- Raises:
ValueError – If the attribute is not a reference and allow_non_reference is False.
ValueError – If the reference is invalid, e.g. “#./” since it has no attribute.
- to_dict(follow_references: bool = False, include_defaults: bool = True) Dict[str, Any]¶
Convert this object to a dictionary.
- Parameters:
follow_references – Whether to follow references when getting the value. If False, the reference will be returned as a string.
include_defaults – Whether to include attributes that have the default value.
- Returns:
A dictionary representation of this object. Any QuamBase objects will be recursively converted to dictionaries.
Note
If the value of an attribute does not match the annotation, the “__class__” key will be added to the dictionary. This is to ensure that the object can be reconstructed when loading from a file.
semi_cr.core.quam_components.helpers module¶
- semi_cr.core.quam_components.helpers.get_trigger_component(device: Multiplexer) SingleChannel[source]¶
- semi_cr.core.quam_components.helpers.get_mux_components(device: Multiplexer) tuple[MultiInputChannel, ...][source]¶
semi_cr.core.quam_components.multi_input_channel module¶
- class semi_cr.core.quam_components.multi_input_channel.MultiInputChannel(*, operations: Dict[str, quam.components.pulses.Pulse] = <factory>, id: Union[str, int] = None, digital_outputs: Dict[str, quam.components.channels.DigitalOutputChannel] = <factory>, sticky: Optional[quam.components.channels.StickyChannelAddon] = None, intermediate_frequency: Optional[float] = None, thread: Optional[str] = None, core: Optional[str] = None, opx_output: Union[quam.components.ports.analog_outputs.LFFEMAnalogOutputPort, quam.components.ports.analog_outputs.OPXPlusAnalogOutputPort, Tuple[str, int], Tuple[str, int, int]], filter_fir_taps: List[float] = None, filter_iir_taps: List[float] = None, opx_output_offset: float = None, opx_inputs: list[quam.components.ports.analog_inputs.LFAnalogInputPort | quam.components.ports.analog_inputs.OPXPlusAnalogInputPort | quam.components.ports.analog_inputs.LFFEMAnalogInputPort | quam.components.ports.analog_inputs.MWFEMAnalogInputPort | collections.abc.Sequence[typing.Any]] = <factory>, opx_input_offsets: list[float | None] | None = None, time_of_flight: int = 140, smearing: int = 0)[source]¶
Bases:
SingleChannel- opx_inputs: list[LFAnalogInputPort | OPXPlusAnalogInputPort | LFFEMAnalogInputPort | MWFEMAnalogInputPort | Sequence[Any]]¶
- apply_to_config(config: dict)[source]¶
Adds this SingleChannel to the QUA configuration.
See [QuamComponent.apply_to_config][quam.core.quam_classes.QuamComponent.apply_to_config] for details.
- align(*other_elements)¶
- frame_rotation(angle: QuaVariable[float] | QuaLiteral[float] | QuaBinaryOperation[float] | QuaArrayCell[float] | QuaArrayLength[float] | QuaLibFunctionOutput[float] | QuaFunctionOutput[float] | QuaBroadcast[float] | _QuaGlobalVarOperation[float] | float)¶
Shift the phase of the channel element’s oscillator 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 \(N \cdot 2^{-16}\). To null out this accumulated error, it is recommended to use reset_frame(el) from time to time.
- frame_rotation_2pi(angle: QuaVariable[float] | QuaLiteral[float] | QuaBinaryOperation[float] | QuaArrayCell[float] | QuaArrayLength[float] | QuaLibFunctionOutput[float] | QuaFunctionOutput[float] | QuaBroadcast[float] | _QuaGlobalVarOperation[float] | float)¶
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 \(N \cdot 2^{-16}\). To null out this accumulated error, it is recommended to use reset_frame(el) from time to time.
- Parameters:
angle (Scalar[float]) – The angle to add to the current phase (in $2pi$ radians)
- get_attr_name(attr_val: Any) str¶
Get the name of an attribute that matches the value.
- Parameters:
attr_val – The value of the attribute.
- Returns:
The name of the attribute.
- Raises:
AttributeError if not found. –
- get_attrs(follow_references: bool = False, include_defaults: bool = True) Dict[str, Any]¶
Get all attributes and corresponding values of this object.
- Parameters:
follow_references – Whether to follow references when getting the value. If False, the reference will be returned as a string.
include_defaults – Whether to include attributes that have the default value.
- Returns:
A dictionary of attribute names and values.
- get_raw_value(attr: str) Any¶
Get the value of an attribute without following references.
If the value is a reference, the reference string is returned
- get_reference(attr: str | None = None, relative_path: str | None = None, follow_chain: bool = False) str | None¶
Get the reference path of this object or one of its attributes.
- Parameters:
attr – The optional attribute to get the reference path for. If None, the reference path of the object itself is returned.
relative_path – The optional relative path to join with the reference path.
follow_chain – If True and attr is a reference, follow the reference chain to return the ultimate target reference. Default is False for backward compatibility. Only applies when attr is specified.
- Returns:
The reference path of this object or the specified attribute.
- Raises:
ValueError – If both attr and relative_path are specified, or if follow_chain is True but attr is not a reference.
Examples
We assume a QuamRoot object with a component “elem”. - elem.get_reference() == “#/elem” - elem.get_reference(attr=”child”) == “#/elem/child” - elem.get_reference(relative_path=”#./child”) == “#/elem/child” - elem.get_reference(relative_path=”#../child”) == “#/child” - elem.get_reference(relative_path=”#./child/grandchild”) == “#/elem/child/grandchild”
With follow_chain=True (if attr contains a reference to another reference): - elem.get_reference(attr=”chain_ref”, follow_chain=True) # returns ultimate target
- get_root() QuamRoot | None¶
Get the QuamRoot object of this object.
This function recursively searches the parent chain for a QuamRoot object. If no QuamRoot object is found, it will return the last instantiated QuamRoot if it exists, else None.
- Returns:
The root of this object, or None if no root is found.
- property inferred_id: str | int¶
Get the id of this object inferred from its
idfield or parent position.If this object has a dataclass field named
idwith a concrete (non-reference, non-None) value, that value is returned. Otherwise the attribute name or key under which this object is stored in its parent is returned.- Returns:
The explicit id if set, or the attribute name / key in the parent as a string.
- Raises:
AttributeError – If no explicit id is set and this object has no parent.
- iterate_components(skip_elems: Sequence[QuamBase] | None = None) Generator[QuamBase, None, None]¶
Iterate over all QuamBase objects in this object, including nested objects.
- Parameters:
skip_elems – A sequence of QuamBase objects to skip. This is used to prevent infinite loops when iterating over nested objects.
- Returns:
A generator of QuamBase objects.
- parent: ClassVar[QuamBase]¶
Descriptor for the parent attribute of QuamBase.
This descriptor is used to ensure that the parent attribute of a QuamBase object is not overwritten. This is to prevent the following situation:
``` parent1 = QuamBase() parent2 = QuamBase()
child = QuamBase() child.parent = parent1 # This is fine child.parent = parent2 # This raises an AttributeError ```
- play(pulse_name: str, amplitude_scale: QuaVariable[float] | QuaLiteral[float] | QuaBinaryOperation[float] | QuaArrayCell[float] | QuaArrayLength[float] | QuaLibFunctionOutput[float] | QuaFunctionOutput[float] | QuaBroadcast[float] | _QuaGlobalVarOperation[float] | float | Sequence[QuaVariable[float] | QuaLiteral[float] | QuaBinaryOperation[float] | QuaArrayCell[float] | QuaArrayLength[float] | QuaLibFunctionOutput[float] | QuaFunctionOutput[float] | QuaBroadcast[float] | _QuaGlobalVarOperation[float] | float] | None = None, duration: QuaVariable[int] | QuaLiteral[int] | QuaBinaryOperation[int] | QuaArrayCell[int] | QuaArrayLength[int] | QuaLibFunctionOutput[int] | QuaFunctionOutput[int] | QuaBroadcast[int] | _QuaGlobalVarOperation[int] | int = None, condition: QuaVariable[bool] | QuaLiteral[bool] | QuaBinaryOperation[bool] | QuaArrayCell[bool] | QuaArrayLength[bool] | QuaLibFunctionOutput[bool] | QuaFunctionOutput[bool] | QuaBroadcast[bool] | _QuaGlobalVarOperation[bool] | bool = None, chirp: Tuple[Iterable[int] | QuaArrayVariable[int] | QuaVariable[int] | QuaLiteral[int] | QuaBinaryOperation[int] | QuaArrayCell[int] | QuaArrayLength[int] | QuaLibFunctionOutput[int] | QuaFunctionOutput[int] | QuaBroadcast[int] | _QuaGlobalVarOperation[int] | int, Literal['Hz/nsec', 'GHz/sec', 'mHz/nsec', 'MHz/sec', 'uHz/nsec', 'KHz/sec', 'nHz/nsec', 'Hz/sec', 'pHz/nsec', 'mHz/sec']] | Tuple[Iterable[int], Iterable[int], Literal['Hz/nsec', 'GHz/sec', 'mHz/nsec', 'MHz/sec', 'uHz/nsec', 'KHz/sec', 'nHz/nsec', 'Hz/sec', 'pHz/nsec', 'mHz/sec']] = None, truncate: QuaVariable[int] | QuaLiteral[int] | QuaBinaryOperation[int] | QuaArrayCell[int] | QuaArrayLength[int] | QuaLibFunctionOutput[int] | QuaFunctionOutput[int] | QuaBroadcast[int] | _QuaGlobalVarOperation[int] | int = None, timestamp_stream: str | ResultStreamSource = None, continue_chirp: bool = False, target: str = '', validate: bool = True)¶
Play a pulse on this channel.
- Parameters:
pulse_name (str) – The name of the pulse to play. Should be registered in self.operations.
amplitude_scale (Optional[Union[ScalarFloat, Sequence[ScalarFloat]]]) – Amplitude scale of the pulse. Can be either a (qua) float, or a list of (qua) floats. If None, the pulse is played without amplitude scaling.
duration (Scalar[int]) – Duration of the 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.
chirp (Union[(list[int], str), (int, str)]) – 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’.
truncate (Scalar[int]) – 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).
condition (A logical expression to evaluate.) – Will play analog pulse only if the condition’s value is true. Any digital pulses associated with the operation will always play.
timestamp_stream (Union[str, _ResultSource]) – (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 samelabel.validate (bool) – If True (default), validate that the pulse is registered in Channel.operations.
Note
The element argument from qm.qua.play()`is not needed, as it is automatically set to `self.name.
- print_summary(indent: int = 0)¶
Print a summary of the QuamBase object.
- Parameters:
indent – The number of spaces to indent the summary.
- property pulse_mapping¶
- ramp(slope: QuaVariable[float] | QuaLiteral[float] | QuaBinaryOperation[float] | QuaArrayCell[float] | QuaArrayLength[float] | QuaLibFunctionOutput[float] | QuaFunctionOutput[float] | QuaBroadcast[float] | _QuaGlobalVarOperation[float] | float, duration: QuaVariable[int] | QuaLiteral[int] | QuaBinaryOperation[int] | QuaArrayCell[int] | QuaArrayLength[int] | QuaLibFunctionOutput[int] | QuaFunctionOutput[int] | QuaBroadcast[int] | _QuaGlobalVarOperation[int] | int)¶
Play a voltage ramp on this channel.
Generates a linear voltage ramp using QUA’s
ramp(slope)command.- Parameters:
Example
```python with program() as prog:
channel.ramp(slope=0.0001, duration=1000)
Note
This is equivalent to
play(ramp(slope), element, duration=duration)in QUA. The channel element is set automatically.
- ramp_to_zero(duration: int | None = None)¶
Ramp the channel output gradually to zero from its last DC value.
- Parameters:
duration (int, optional) – Duration of the ramp in multiples of 4 ns. Range: [4, 2^24]. If None, the duration is taken from the element’s sticky config (
StickyChannelAddon.duration).
Note
This does not protect against voltage jumps if the current output value is outside the [-0.5, 0.5 - 2^-16] range.
- reset_if_phase()¶
Resets the intermediate frequency phase of the oscillator, 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 (\(\\omega_{IF}\)) currently in use.
- set_at_reference(attr: str, value: Any, allow_non_reference: bool = True)¶
Follow the reference of an attribute and set the value at the reference.
This method follows reference chains recursively. If an attribute contains a reference to another reference, both references are preserved while the ultimate target value is updated.
- Parameters:
attr – The attribute to set the value at the reference of.
value – The value to set.
allow_non_reference – Whether to allow the attribute to be a non-reference. If True (default), non-reference attributes are allowed. If False, the attribute must be a reference or an error is raised.
- Raises:
ValueError – If the attribute is not a reference and allow_non_reference is False.
ValueError – If the reference is invalid, e.g. “#./” since it has no attribute.
- set_dc_offset(offset: QuaVariable[float] | QuaLiteral[float] | QuaBinaryOperation[float] | QuaArrayCell[float] | QuaArrayLength[float] | QuaLibFunctionOutput[float] | QuaFunctionOutput[float] | QuaBroadcast[float] | _QuaGlobalVarOperation[float] | float)¶
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.
- Parameters:
offset (Scalar[float]) – The DC offset to set the input to. This is limited by the OPX output voltage range.
- to_dict(follow_references: bool = False, include_defaults: bool = True) Dict[str, Any]¶
Convert this object to a dictionary.
- Parameters:
follow_references – Whether to follow references when getting the value. If False, the reference will be returned as a string.
include_defaults – Whether to include attributes that have the default value.
- Returns:
A dictionary representation of this object. Any QuamBase objects will be recursively converted to dictionaries.
Note
If the value of an attribute does not match the annotation, the “__class__” key will be added to the dictionary. This is to ensure that the object can be reconstructed when loading from a file.
- update_frequency(new_frequency: QuaVariable[int] | QuaLiteral[int] | QuaBinaryOperation[int] | QuaArrayCell[int] | QuaArrayLength[int] | QuaLibFunctionOutput[int] | QuaFunctionOutput[int] | QuaBroadcast[int] | _QuaGlobalVarOperation[int] | int, units: str = 'Hz', keep_phase: bool = False)¶
Dynamically update the frequency of the associated oscillator.
This changes the frequency from the value defined in the channel.
The behavior of the phase (continuous vs. coherent) is controlled by the
keep_phaseparameter and is discussed in the documentation.- Parameters:
new_frequency (Scalar[int]) – The new frequency value to set in units set by
unitsparameter. In steps of 1.units (str) – units of new frequency. Useful when sub-Hz precision is required. Allowed units are “Hz”, “mHz”, “uHz”, “nHz”, “pHz”
keep_phase (bool) – Determine whether phase will be continuous through the change (if
True) or it will be coherent, only the frequency will change (ifFalse).
Example
```python with program() as prog:
qua.update_frequency(“q1”, 4e6) # will set the frequency to 4 MHz
### Example for sub-Hz resolution # will set the frequency to 100 Hz (due to casting to int) qua.update_frequency(“q1”, 100.7)
# will set the frequency to 100.7 Hz qua.update_frequency(“q1”, 100700, units=’mHz’)
- wait(duration: QuaVariable[int] | QuaLiteral[int] | QuaBinaryOperation[int] | QuaArrayCell[int] | QuaArrayLength[int] | QuaLibFunctionOutput[int] | QuaFunctionOutput[int] | QuaBroadcast[int] | _QuaGlobalVarOperation[int] | int, *other_elements: str | Channel)¶
Wait for the given duration on all provided elements without outputting anything.
Duration is in units of the clock cycle (4ns)
- Parameters:
Warning
In case the value of this is outside the range above, unexpected results may occur.
Note
The current channel element is always included in the wait operation.
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.
- class semi_cr.core.quam_components.multi_input_channel.MultiInputMWChannel(*, operations: Dict[str, quam.components.pulses.Pulse]=<factory>, id: Union[str, int]=None, digital_outputs: Dict[str, quam.components.channels.DigitalOutputChannel]=<factory>, sticky: quam.components.channels.StickyChannelAddon | None = None, intermediate_frequency: float | None = None, thread: str | None = None, core: str | None = None, LO_frequency: float = '#./upconverter_frequency', RF_frequency: float = '#./inferred_RF_frequency', opx_output: quam.components.ports.analog_outputs.MWFEMAnalogOutputPort, upconverter: int = 1, opx_inputs: list[quam.components.ports.analog_inputs.MWFEMAnalogInputPort | collections.abc.Sequence[Any]] = <factory>, opx_input_offsets: list[float | None] | None = None, time_of_flight: int = 140, smearing: int = 0)[source]¶
Bases:
MWChannel- apply_to_config(config: dict)[source]¶
Adds this Channel to the QUA configuration.
config.elements.<element_name> will be created, and the operations are added.
- Parameters:
config (dict) – The QUA config that’s in the process of being generated.
- Raises:
ValueError – If the channel already exists in the config.
- measure(pulse_name: str = 'readout', outputs: tuple[str, ...] = ('out1', 'out2'), amplitude_scale: float | None = None)[source]¶
- align(*other_elements)¶
- frame_rotation(angle: QuaVariable[float] | QuaLiteral[float] | QuaBinaryOperation[float] | QuaArrayCell[float] | QuaArrayLength[float] | QuaLibFunctionOutput[float] | QuaFunctionOutput[float] | QuaBroadcast[float] | _QuaGlobalVarOperation[float] | float)¶
Shift the phase of the channel element’s oscillator 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 \(N \cdot 2^{-16}\). To null out this accumulated error, it is recommended to use reset_frame(el) from time to time.
- frame_rotation_2pi(angle: QuaVariable[float] | QuaLiteral[float] | QuaBinaryOperation[float] | QuaArrayCell[float] | QuaArrayLength[float] | QuaLibFunctionOutput[float] | QuaFunctionOutput[float] | QuaBroadcast[float] | _QuaGlobalVarOperation[float] | float)¶
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 \(N \cdot 2^{-16}\). To null out this accumulated error, it is recommended to use reset_frame(el) from time to time.
- Parameters:
angle (Scalar[float]) – The angle to add to the current phase (in $2pi$ radians)
- get_attr_name(attr_val: Any) str¶
Get the name of an attribute that matches the value.
- Parameters:
attr_val – The value of the attribute.
- Returns:
The name of the attribute.
- Raises:
AttributeError if not found. –
- get_attrs(follow_references: bool = False, include_defaults: bool = True) Dict[str, Any]¶
Get all attributes and corresponding values of this object.
- Parameters:
follow_references – Whether to follow references when getting the value. If False, the reference will be returned as a string.
include_defaults – Whether to include attributes that have the default value.
- Returns:
A dictionary of attribute names and values.
- get_raw_value(attr: str) Any¶
Get the value of an attribute without following references.
If the value is a reference, the reference string is returned
- get_reference(attr: str | None = None, relative_path: str | None = None, follow_chain: bool = False) str | None¶
Get the reference path of this object or one of its attributes.
- Parameters:
attr – The optional attribute to get the reference path for. If None, the reference path of the object itself is returned.
relative_path – The optional relative path to join with the reference path.
follow_chain – If True and attr is a reference, follow the reference chain to return the ultimate target reference. Default is False for backward compatibility. Only applies when attr is specified.
- Returns:
The reference path of this object or the specified attribute.
- Raises:
ValueError – If both attr and relative_path are specified, or if follow_chain is True but attr is not a reference.
Examples
We assume a QuamRoot object with a component “elem”. - elem.get_reference() == “#/elem” - elem.get_reference(attr=”child”) == “#/elem/child” - elem.get_reference(relative_path=”#./child”) == “#/elem/child” - elem.get_reference(relative_path=”#../child”) == “#/child” - elem.get_reference(relative_path=”#./child/grandchild”) == “#/elem/child/grandchild”
With follow_chain=True (if attr contains a reference to another reference): - elem.get_reference(attr=”chain_ref”, follow_chain=True) # returns ultimate target
- get_root() QuamRoot | None¶
Get the QuamRoot object of this object.
This function recursively searches the parent chain for a QuamRoot object. If no QuamRoot object is found, it will return the last instantiated QuamRoot if it exists, else None.
- Returns:
The root of this object, or None if no root is found.
- property inferred_LO_frequency: float¶
Inferred LO frequency by subtracting IF from RF
Can be used by having reference LO_frequency = “#./inferred_LO_frequency”
- Returns:
self.RF_frequency - self.intermediate_frequency
- property inferred_RF_frequency: float¶
Inferred RF frequency by adding LO and IF
Can be used by having reference RF_frequency = “#./inferred_RF_frequency” :returns: self.LO_frequency + self.intermediate_frequency
- property inferred_id: str | int¶
Get the id of this object inferred from its
idfield or parent position.If this object has a dataclass field named
idwith a concrete (non-reference, non-None) value, that value is returned. Otherwise the attribute name or key under which this object is stored in its parent is returned.- Returns:
The explicit id if set, or the attribute name / key in the parent as a string.
- Raises:
AttributeError – If no explicit id is set and this object has no parent.
- property inferred_intermediate_frequency: float¶
Inferred intermediate frequency by subtracting LO from RF
Can be used by having reference intermediate_frequency = “#./inferred_intermediate_frequency”
- Returns:
self.RF_frequency - self.LO_frequency
- iterate_components(skip_elems: Sequence[QuamBase] | None = None) Generator[QuamBase, None, None]¶
Iterate over all QuamBase objects in this object, including nested objects.
- Parameters:
skip_elems – A sequence of QuamBase objects to skip. This is used to prevent infinite loops when iterating over nested objects.
- Returns:
A generator of QuamBase objects.
- parent: ClassVar[QuamBase]¶
Descriptor for the parent attribute of QuamBase.
This descriptor is used to ensure that the parent attribute of a QuamBase object is not overwritten. This is to prevent the following situation:
``` parent1 = QuamBase() parent2 = QuamBase()
child = QuamBase() child.parent = parent1 # This is fine child.parent = parent2 # This raises an AttributeError ```
- play(pulse_name: str, amplitude_scale: QuaVariable[float] | QuaLiteral[float] | QuaBinaryOperation[float] | QuaArrayCell[float] | QuaArrayLength[float] | QuaLibFunctionOutput[float] | QuaFunctionOutput[float] | QuaBroadcast[float] | _QuaGlobalVarOperation[float] | float | Sequence[QuaVariable[float] | QuaLiteral[float] | QuaBinaryOperation[float] | QuaArrayCell[float] | QuaArrayLength[float] | QuaLibFunctionOutput[float] | QuaFunctionOutput[float] | QuaBroadcast[float] | _QuaGlobalVarOperation[float] | float] | None = None, duration: QuaVariable[int] | QuaLiteral[int] | QuaBinaryOperation[int] | QuaArrayCell[int] | QuaArrayLength[int] | QuaLibFunctionOutput[int] | QuaFunctionOutput[int] | QuaBroadcast[int] | _QuaGlobalVarOperation[int] | int = None, condition: QuaVariable[bool] | QuaLiteral[bool] | QuaBinaryOperation[bool] | QuaArrayCell[bool] | QuaArrayLength[bool] | QuaLibFunctionOutput[bool] | QuaFunctionOutput[bool] | QuaBroadcast[bool] | _QuaGlobalVarOperation[bool] | bool = None, chirp: Tuple[Iterable[int] | QuaArrayVariable[int] | QuaVariable[int] | QuaLiteral[int] | QuaBinaryOperation[int] | QuaArrayCell[int] | QuaArrayLength[int] | QuaLibFunctionOutput[int] | QuaFunctionOutput[int] | QuaBroadcast[int] | _QuaGlobalVarOperation[int] | int, Literal['Hz/nsec', 'GHz/sec', 'mHz/nsec', 'MHz/sec', 'uHz/nsec', 'KHz/sec', 'nHz/nsec', 'Hz/sec', 'pHz/nsec', 'mHz/sec']] | Tuple[Iterable[int], Iterable[int], Literal['Hz/nsec', 'GHz/sec', 'mHz/nsec', 'MHz/sec', 'uHz/nsec', 'KHz/sec', 'nHz/nsec', 'Hz/sec', 'pHz/nsec', 'mHz/sec']] = None, truncate: QuaVariable[int] | QuaLiteral[int] | QuaBinaryOperation[int] | QuaArrayCell[int] | QuaArrayLength[int] | QuaLibFunctionOutput[int] | QuaFunctionOutput[int] | QuaBroadcast[int] | _QuaGlobalVarOperation[int] | int = None, timestamp_stream: str | ResultStreamSource = None, continue_chirp: bool = False, target: str = '', validate: bool = True)¶
Play a pulse on this channel.
- Parameters:
pulse_name (str) – The name of the pulse to play. Should be registered in self.operations.
amplitude_scale (Optional[Union[ScalarFloat, Sequence[ScalarFloat]]]) – Amplitude scale of the pulse. Can be either a (qua) float, or a list of (qua) floats. If None, the pulse is played without amplitude scaling.
duration (Scalar[int]) – Duration of the 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.
chirp (Union[(list[int], str), (int, str)]) – 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’.
truncate (Scalar[int]) – 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).
condition (A logical expression to evaluate.) – Will play analog pulse only if the condition’s value is true. Any digital pulses associated with the operation will always play.
timestamp_stream (Union[str, _ResultSource]) – (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 samelabel.validate (bool) – If True (default), validate that the pulse is registered in Channel.operations.
Note
The element argument from qm.qua.play()`is not needed, as it is automatically set to `self.name.
- print_summary(indent: int = 0)¶
Print a summary of the QuamBase object.
- Parameters:
indent – The number of spaces to indent the summary.
- property pulse_mapping¶
- ramp(slope: QuaVariable[float] | QuaLiteral[float] | QuaBinaryOperation[float] | QuaArrayCell[float] | QuaArrayLength[float] | QuaLibFunctionOutput[float] | QuaFunctionOutput[float] | QuaBroadcast[float] | _QuaGlobalVarOperation[float] | float, duration: QuaVariable[int] | QuaLiteral[int] | QuaBinaryOperation[int] | QuaArrayCell[int] | QuaArrayLength[int] | QuaLibFunctionOutput[int] | QuaFunctionOutput[int] | QuaBroadcast[int] | _QuaGlobalVarOperation[int] | int)¶
Play a voltage ramp on this channel.
Generates a linear voltage ramp using QUA’s
ramp(slope)command.- Parameters:
Example
```python with program() as prog:
channel.ramp(slope=0.0001, duration=1000)
Note
This is equivalent to
play(ramp(slope), element, duration=duration)in QUA. The channel element is set automatically.
- ramp_to_zero(duration: int | None = None)¶
Ramp the channel output gradually to zero from its last DC value.
- Parameters:
duration (int, optional) – Duration of the ramp in multiples of 4 ns. Range: [4, 2^24]. If None, the duration is taken from the element’s sticky config (
StickyChannelAddon.duration).
Note
This does not protect against voltage jumps if the current output value is outside the [-0.5, 0.5 - 2^-16] range.
- reset_if_phase()¶
Resets the intermediate frequency phase of the oscillator, 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 (\(\\omega_{IF}\)) currently in use.
- set_at_reference(attr: str, value: Any, allow_non_reference: bool = True)¶
Follow the reference of an attribute and set the value at the reference.
This method follows reference chains recursively. If an attribute contains a reference to another reference, both references are preserved while the ultimate target value is updated.
- Parameters:
attr – The attribute to set the value at the reference of.
value – The value to set.
allow_non_reference – Whether to allow the attribute to be a non-reference. If True (default), non-reference attributes are allowed. If False, the attribute must be a reference or an error is raised.
- Raises:
ValueError – If the attribute is not a reference and allow_non_reference is False.
ValueError – If the reference is invalid, e.g. “#./” since it has no attribute.
- to_dict(follow_references: bool = False, include_defaults: bool = True) Dict[str, Any]¶
Convert this object to a dictionary.
- Parameters:
follow_references – Whether to follow references when getting the value. If False, the reference will be returned as a string.
include_defaults – Whether to include attributes that have the default value.
- Returns:
A dictionary representation of this object. Any QuamBase objects will be recursively converted to dictionaries.
Note
If the value of an attribute does not match the annotation, the “__class__” key will be added to the dictionary. This is to ensure that the object can be reconstructed when loading from a file.
- property upconverter_frequency: float¶
Determine the upconverter frequency from the opx_output.
If the upconverter frequency is not set, the upconverter frequency is inferred from the upconverters dictionary.
- Returns:
The upconverter frequency.
- Raises:
ValueError – If the upconverter frequency is not set and cannot be inferred.
- update_frequency(new_frequency: QuaVariable[int] | QuaLiteral[int] | QuaBinaryOperation[int] | QuaArrayCell[int] | QuaArrayLength[int] | QuaLibFunctionOutput[int] | QuaFunctionOutput[int] | QuaBroadcast[int] | _QuaGlobalVarOperation[int] | int, units: str = 'Hz', keep_phase: bool = False)¶
Dynamically update the frequency of the associated oscillator.
This changes the frequency from the value defined in the channel.
The behavior of the phase (continuous vs. coherent) is controlled by the
keep_phaseparameter and is discussed in the documentation.- Parameters:
new_frequency (Scalar[int]) – The new frequency value to set in units set by
unitsparameter. In steps of 1.units (str) – units of new frequency. Useful when sub-Hz precision is required. Allowed units are “Hz”, “mHz”, “uHz”, “nHz”, “pHz”
keep_phase (bool) – Determine whether phase will be continuous through the change (if
True) or it will be coherent, only the frequency will change (ifFalse).
Example
```python with program() as prog:
qua.update_frequency(“q1”, 4e6) # will set the frequency to 4 MHz
### Example for sub-Hz resolution # will set the frequency to 100 Hz (due to casting to int) qua.update_frequency(“q1”, 100.7)
# will set the frequency to 100.7 Hz qua.update_frequency(“q1”, 100700, units=’mHz’)
- wait(duration: QuaVariable[int] | QuaLiteral[int] | QuaBinaryOperation[int] | QuaArrayCell[int] | QuaArrayLength[int] | QuaLibFunctionOutput[int] | QuaFunctionOutput[int] | QuaBroadcast[int] | _QuaGlobalVarOperation[int] | int, *other_elements: str | Channel)¶
Wait for the given duration on all provided elements without outputting anything.
Duration is in units of the clock cycle (4ns)
- Parameters:
Warning
In case the value of this is outside the range above, unexpected results may occur.
Note
The current channel element is always included in the wait operation.
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.
- opx_output: MWFEMAnalogOutputPort¶
Module contents¶
- class semi_cr.core.quam_components.CryoSwitch(*, in_channel: InOutSingleChannel, channels: dict[str, InOutSingleChannel], amplitude: float = 0.1, intermediate_frequency: int = 100000000, readout_length: int = 1000)[source]¶
Bases:
QuamComponentQUAM component for a cryogenic RF switch / multiplexer.
Groups multiple
InOutSingleChannelinstances and exposes helpers to drive them together inside QUA programs (frequency sweeps, alignment, simultaneous measurements, etc.).- channels¶
Mapping from logical channel names to in/out reflectometry channels.
- in_channel: InOutSingleChannel¶
- wait(duration: QuaVariable[int] | QuaLiteral[int] | QuaBinaryOperation[int] | QuaArrayCell[int] | QuaArrayLength[int] | QuaLibFunctionOutput[int] | QuaFunctionOutput[int] | QuaBroadcast[int] | _QuaGlobalVarOperation[int] | int) None[source]¶
Wait on all selected channels without outputting a pulse.
- update_frequency(new_frequency: QuaVariable[int] | QuaLiteral[int] | QuaBinaryOperation[int] | QuaArrayCell[int] | QuaArrayLength[int] | QuaLibFunctionOutput[int] | QuaFunctionOutput[int] | QuaBroadcast[int] | _QuaGlobalVarOperation[int] | int, units: str = 'Hz', keep_phase: bool = False) None[source]¶
Update the intermediate frequency on all selected channels.
- apply_to_config(config: dict) None¶
Add information to the QUA configuration, such as pulses and waveforms.
- Parameters:
config – The QUA configuration dictionary. Initially this is a nearly empty dictionary, but
Note
This function is called by [QuamRoot.generate_config][quam.core.quam_classes.QuamRoot.generate_config].
Note
The config has a starting template, defined at [quam.core.qua_config_template][]
- get_attr_name(attr_val: Any) str¶
Get the name of an attribute that matches the value.
- Parameters:
attr_val – The value of the attribute.
- Returns:
The name of the attribute.
- Raises:
AttributeError if not found. –
- get_attrs(follow_references: bool = False, include_defaults: bool = True) Dict[str, Any]¶
Get all attributes and corresponding values of this object.
- Parameters:
follow_references – Whether to follow references when getting the value. If False, the reference will be returned as a string.
include_defaults – Whether to include attributes that have the default value.
- Returns:
A dictionary of attribute names and values.
- get_raw_value(attr: str) Any¶
Get the value of an attribute without following references.
If the value is a reference, the reference string is returned
- get_reference(attr: str | None = None, relative_path: str | None = None, follow_chain: bool = False) str | None¶
Get the reference path of this object or one of its attributes.
- Parameters:
attr – The optional attribute to get the reference path for. If None, the reference path of the object itself is returned.
relative_path – The optional relative path to join with the reference path.
follow_chain – If True and attr is a reference, follow the reference chain to return the ultimate target reference. Default is False for backward compatibility. Only applies when attr is specified.
- Returns:
The reference path of this object or the specified attribute.
- Raises:
ValueError – If both attr and relative_path are specified, or if follow_chain is True but attr is not a reference.
Examples
We assume a QuamRoot object with a component “elem”. - elem.get_reference() == “#/elem” - elem.get_reference(attr=”child”) == “#/elem/child” - elem.get_reference(relative_path=”#./child”) == “#/elem/child” - elem.get_reference(relative_path=”#../child”) == “#/child” - elem.get_reference(relative_path=”#./child/grandchild”) == “#/elem/child/grandchild”
With follow_chain=True (if attr contains a reference to another reference): - elem.get_reference(attr=”chain_ref”, follow_chain=True) # returns ultimate target
- get_root() QuamRoot | None¶
Get the QuamRoot object of this object.
This function recursively searches the parent chain for a QuamRoot object. If no QuamRoot object is found, it will return the last instantiated QuamRoot if it exists, else None.
- Returns:
The root of this object, or None if no root is found.
- property inferred_id: str | int¶
Get the id of this object inferred from its
idfield or parent position.If this object has a dataclass field named
idwith a concrete (non-reference, non-None) value, that value is returned. Otherwise the attribute name or key under which this object is stored in its parent is returned.- Returns:
The explicit id if set, or the attribute name / key in the parent as a string.
- Raises:
AttributeError – If no explicit id is set and this object has no parent.
- iterate_components(skip_elems: Sequence[QuamBase] | None = None) Generator[QuamBase, None, None]¶
Iterate over all QuamBase objects in this object, including nested objects.
- Parameters:
skip_elems – A sequence of QuamBase objects to skip. This is used to prevent infinite loops when iterating over nested objects.
- Returns:
A generator of QuamBase objects.
- parent: ClassVar[QuamBase]¶
Descriptor for the parent attribute of QuamBase.
This descriptor is used to ensure that the parent attribute of a QuamBase object is not overwritten. This is to prevent the following situation:
``` parent1 = QuamBase() parent2 = QuamBase()
child = QuamBase() child.parent = parent1 # This is fine child.parent = parent2 # This raises an AttributeError ```
- print_summary(indent: int = 0)¶
Print a summary of the QuamBase object.
- Parameters:
indent – The number of spaces to indent the summary.
- set_at_reference(attr: str, value: Any, allow_non_reference: bool = True)¶
Follow the reference of an attribute and set the value at the reference.
This method follows reference chains recursively. If an attribute contains a reference to another reference, both references are preserved while the ultimate target value is updated.
- Parameters:
attr – The attribute to set the value at the reference of.
value – The value to set.
allow_non_reference – Whether to allow the attribute to be a non-reference. If True (default), non-reference attributes are allowed. If False, the attribute must be a reference or an error is raised.
- Raises:
ValueError – If the attribute is not a reference and allow_non_reference is False.
ValueError – If the reference is invalid, e.g. “#./” since it has no attribute.
- to_dict(follow_references: bool = False, include_defaults: bool = True) Dict[str, Any]¶
Convert this object to a dictionary.
- Parameters:
follow_references – Whether to follow references when getting the value. If False, the reference will be returned as a string.
include_defaults – Whether to include attributes that have the default value.
- Returns:
A dictionary representation of this object. Any QuamBase objects will be recursively converted to dictionaries.
Note
If the value of an attribute does not match the annotation, the “__class__” key will be added to the dictionary. This is to ensure that the object can be reconstructed when loading from a file.