3.1.3. qupulse.pulses package

3.1.3.1. Module contents

This is the central package for defining pulses. All PulseTemplate subclasses that are final and ready to be used are imported here with their recommended abbreviation as an alias.

qupulse.pulses.FunctionPT

alias of qupulse.pulses.function_pulse_template.FunctionPulseTemplate

qupulse.pulses.ForLoopPT

alias of qupulse.pulses.loop_pulse_template.ForLoopPulseTemplate

qupulse.pulses.AtomicMultiChannelPT

alias of qupulse.pulses.multi_channel_pulse_template.AtomicMultiChannelPulseTemplate

qupulse.pulses.MappingPT

alias of qupulse.pulses.mapping_pulse_template.MappingPulseTemplate

qupulse.pulses.RepetitionPT

alias of qupulse.pulses.repetition_pulse_template.RepetitionPulseTemplate

qupulse.pulses.SequencePT

alias of qupulse.pulses.sequence_pulse_template.SequencePulseTemplate

qupulse.pulses.TablePT

alias of qupulse.pulses.table_pulse_template.TablePulseTemplate

qupulse.pulses.PointPT

alias of qupulse.pulses.point_pulse_template.PointPulseTemplate

qupulse.pulses.AbstractPT

alias of qupulse.pulses.abstract_pulse_template.AbstractPulseTemplate

qupulse.pulses.ParallelConstantChannelPT

alias of qupulse.pulses.multi_channel_pulse_template.ParallelConstantChannelPulseTemplate

3.1.3.2. Submodules

3.1.3.3. qupulse.pulses.conditions module

This module defines conditions required for branching decisions in pulse execution.

Classes:
  • Condition: Base-class for conditions.
  • SoftwareCondition: A software-evaluated condition.
  • HardwareCondition: A hardware-evaluated condition.
  • ConditionEvaluationException.
  • ConditionMissingException.
class qupulse.pulses.conditions.Condition[source]

Bases: object

A condition on which the execution of a pulse may depend.

Conditions are used for branching and looping of pulses and thus relevant for BranchPulseTemplate and LoopPulseTemplate. Implementations of Condition may rely on software variables, measured data or be mere placeholders for hardware triggers.

build_sequence_branch(delegator, if_branch, else_branch, sequencer, parameters, conditions, measurement_mapping, channel_mapping, instruction_block)[source]

Translate a branching SequencingElement using this Condition into an instruction sequence for the given instruction block using sequencer and the given parameter sets.

Parameters:
  • delegator (SequencingElement) – The SequencingElement which has delegated the invocation of its build_sequence method to this Condition object.
  • if_branch (SequencingElement) – The SequencingElement representing the branch executed if the condition holds.
  • else_branch (SequencingElement) – The SequencingElement representing the branch executed if the condition does not hold.
  • parameters (Dict[str, Parameter]) – A mapping of parameter names to Parameter objects which will be passed to the loop body.
  • conditions (Dict[str, Condition]) – A mapping of condition identifier to Condition objects which will be passed to the loop body.
  • instruction_block (InstructionBlock) – The instruction block into which instructions resulting from the translation of this Condition object will be placed.

See also

SequencingElement.build_sequence()

Return type:None
build_sequence_loop(delegator, body, sequencer, parameters, conditions, measurement_mapping, channel_mapping, instruction_block)[source]

Translate a looping SequencingElement using this Condition into an instruction sequence for the given instruction block using sequencer and the given parameter sets.

Parameters:
  • delegator (SequencingElement) – The SequencingElement which has delegated the invocation of its build_sequence method to this Condition object.
  • body (SequencingElement) – The SequencingElement representing the loops body.
  • sequencer (Sequencer) – The Sequencer object coordinating the current sequencing process.
  • parameters (Dict[str, Parameter]) – A mapping of parameter names to Parameter objects which will be passed to the loop body.
  • conditions (Dict[str, Condition]) – A mapping of condition identifier to Condition objects which will be passed to the loop body.
  • instruction_block (InstructionBlock) – The instruction block into which instructions resulting from the translation of this Condition object will be placed.

See also

SequencingElement.build_sequence()

Return type:None
requires_stop()[source]

Query whether evaluating this Condition object requires an interruption in execution/ sequencing, e.g. because it depends on a value obtained during executin.

Return type:bool
Returns:True, if evaluation of this Condition object requires sequencing to be interrupted.
exception qupulse.pulses.conditions.ConditionEvaluationException[source]

Bases: Exception

Indicates that a SoftwareCondition cannot be evaluated yet.

exception qupulse.pulses.conditions.ConditionMissingException(condition_name)[source]

Bases: Exception

Indicates that a Condition object was not provided for a condition identifier.

class qupulse.pulses.conditions.SoftwareCondition(evaluation_callback)[source]

Bases: qupulse.pulses.conditions.Condition

A condition that will be evaluated in the software.

SoftwareConditions are evaluated in software, allowing them to rely on sophisticated measurement evaluation or to be used when the hardware device does not support trigger based jumping instructions.

On the downside, this means that a translation processes may be interrupted because a SoftwareCondition relying on measurement data cannot be evaluated before that data is acquired. In this case, the already translated part has to be executed, the measurement is made and in a subsequent translation, the SoftwareCondition is evaluated and the corresponding instructions of one branch/the loop body are generated without jumping instructions.

This interruption of pulse execution might not be feasible in some environments.

Create a new SoftwareCondition instance.

Parameters:evaluation_callback (Callable[[int], Optional[bool]]) – A function handle which accepts an integer arguments and returns a boolean value or None. The integer argument is the current iteration of loop (starting at zero before the first loop execution). For branch sequencing, this argument will always be zero. The callback’s return value must be None iff evaluation is currently not possible.
__init__(evaluation_callback)[source]

Create a new SoftwareCondition instance.

Parameters:evaluation_callback (Callable[[int], Optional[bool]]) – A function handle which accepts an integer arguments and returns a boolean value or None. The integer argument is the current iteration of loop (starting at zero before the first loop execution). For branch sequencing, this argument will always be zero. The callback’s return value must be None iff evaluation is currently not possible.
Return type:None
build_sequence_branch(delegator, if_branch, else_branch, sequencer, parameters, conditions, measurement_mapping, channel_mapping, instruction_block)[source]

Translate a branching SequencingElement using this Condition into an instruction sequence for the given instruction block using sequencer and the given parameter sets.

Parameters:
  • delegator (SequencingElement) – The SequencingElement which has delegated the invocation of its build_sequence method to this Condition object.
  • if_branch (SequencingElement) – The SequencingElement representing the branch executed if the condition holds.
  • else_branch (SequencingElement) – The SequencingElement representing the branch executed if the condition does not hold.
  • parameters (Dict[str, Parameter]) – A mapping of parameter names to Parameter objects which will be passed to the loop body.
  • conditions (Dict[str, Condition]) – A mapping of condition identifier to Condition objects which will be passed to the loop body.
  • instruction_block (InstructionBlock) – The instruction block into which instructions resulting from the translation of this Condition object will be placed.

See also

SequencingElement.build_sequence()

Return type:None
build_sequence_loop(delegator, body, sequencer, parameters, conditions, measurement_mapping, channel_mapping, instruction_block)[source]

Translate a looping SequencingElement using this Condition into an instruction sequence for the given instruction block using sequencer and the given parameter sets.

Parameters:
  • delegator (SequencingElement) – The SequencingElement which has delegated the invocation of its build_sequence method to this Condition object.
  • body (SequencingElement) – The SequencingElement representing the loops body.
  • sequencer (Sequencer) – The Sequencer object coordinating the current sequencing process.
  • parameters (Dict[str, Parameter]) – A mapping of parameter names to Parameter objects which will be passed to the loop body.
  • conditions (Dict[str, Condition]) – A mapping of condition identifier to Condition objects which will be passed to the loop body.
  • instruction_block (InstructionBlock) – The instruction block into which instructions resulting from the translation of this Condition object will be placed.

See also

SequencingElement.build_sequence()

Return type:None
requires_stop()[source]

Query whether evaluating this Condition object requires an interruption in execution/ sequencing, e.g. because it depends on a value obtained during executin.

Return type:bool
Returns:True, if evaluation of this Condition object requires sequencing to be interrupted.
class qupulse.pulses.conditions.HardwareCondition(trigger)[source]

Bases: qupulse.pulses.conditions.Condition

A condition that will be evaluated using hardware triggers.

The condition will be evaluate as true iff the trigger has fired before the hardware device makes the branching decision.

During the translation process, a HardwareCondition instance will produce code blocks for branches/loop bodies and the corresponding conditional jump instructions.

Create a new HardwareCondition instance.

Parameters:trigger (Trigger) – The trigger handle of the corresponding hardware device.
__init__(trigger)[source]

Create a new HardwareCondition instance.

Parameters:trigger (Trigger) – The trigger handle of the corresponding hardware device.
Return type:None
build_sequence_branch(delegator, if_branch, else_branch, sequencer, parameters, conditions, measurement_mapping, channel_mapping, instruction_block)[source]

Translate a branching SequencingElement using this Condition into an instruction sequence for the given instruction block using sequencer and the given parameter sets.

Parameters:
  • delegator (SequencingElement) – The SequencingElement which has delegated the invocation of its build_sequence method to this Condition object.
  • if_branch (SequencingElement) – The SequencingElement representing the branch executed if the condition holds.
  • else_branch (SequencingElement) – The SequencingElement representing the branch executed if the condition does not hold.
  • parameters (Dict[str, Parameter]) – A mapping of parameter names to Parameter objects which will be passed to the loop body.
  • conditions (Dict[str, Condition]) – A mapping of condition identifier to Condition objects which will be passed to the loop body.
  • instruction_block (InstructionBlock) – The instruction block into which instructions resulting from the translation of this Condition object will be placed.

See also

SequencingElement.build_sequence()

Return type:None
build_sequence_loop(delegator, body, sequencer, parameters, conditions, measurement_mapping, channel_mapping, instruction_block)[source]

Translate a looping SequencingElement using this Condition into an instruction sequence for the given instruction block using sequencer and the given parameter sets.

Parameters:
  • delegator (SequencingElement) – The SequencingElement which has delegated the invocation of its build_sequence method to this Condition object.
  • body (SequencingElement) – The SequencingElement representing the loops body.
  • sequencer (Sequencer) – The Sequencer object coordinating the current sequencing process.
  • parameters (Dict[str, Parameter]) – A mapping of parameter names to Parameter objects which will be passed to the loop body.
  • conditions (Dict[str, Condition]) – A mapping of condition identifier to Condition objects which will be passed to the loop body.
  • instruction_block (InstructionBlock) – The instruction block into which instructions resulting from the translation of this Condition object will be placed.

See also

SequencingElement.build_sequence()

Return type:None
requires_stop()[source]

Query whether evaluating this Condition object requires an interruption in execution/ sequencing, e.g. because it depends on a value obtained during executin.

Return type:bool
Returns:True, if evaluation of this Condition object requires sequencing to be interrupted.

3.1.3.4. qupulse.pulses.function_pulse_template module

This module defines the FunctionPulseTemplate, one of the elementary pulse templates and its waveform representation.

Classes:
  • FunctionPulseTemplate: Defines a pulse via a mathematical function.
class qupulse.pulses.function_pulse_template.FunctionPulseTemplate(expression, duration_expression, channel='default', identifier=None, *, measurements=None, parameter_constraints=None, registry=None)[source]

Bases: qupulse.pulses.pulse_template.AtomicPulseTemplate, qupulse.pulses.parameters.ParameterConstrainer

Defines a pulse via a time-domain expression.

FunctionPulseTemplate stores the expression and its external parameters. The user must provide two things: one expression that calculates the length of the pulse from the external parameters and the time-domain pulse shape itself as a expression. The required external parameters are derived from the free variables in the expressions themselves. Like other PulseTemplates the FunctionPulseTemplate can be declared to be a measurement pulse.

The independent variable for the time domain in the expression is expected to be called ‘t’.

Creates a new FunctionPulseTemplate object.

Parameters:
__init__(expression, duration_expression, channel='default', identifier=None, *, measurements=None, parameter_constraints=None, registry=None)[source]

Creates a new FunctionPulseTemplate object.

Parameters:
Return type:

None

build_waveform(parameters, channel_mapping)[source]

Implements build_waveform().

Return type:Optional[FunctionWaveform]
defined_channels

Implements defined_channels.

Return type:Set[Union[str, int]]
classmethod deserialize(serializer=None, **kwargs)[source]

Reconstructs the Serializable object from a dictionary.

Implementation hint: For greater clarity, implementations of this method should be precise in their return value, i.e., give their exact class name, and also replace the kwargs argument by a list of arguments required, i.e., those returned by get_serialization_data. Using old serialization routines, if this Serializable contains complex objects which are itself of type Serializable, their dictionary representations MUST be converted into objects using serializers deserialize() method. This is DEPRECATED behavior. Using the new routines, a serializable is only responsible to decode it’s own dictionary, not those of nested objects (i.e., all incoming arguments are already processed by the serialization routines). For the transition time where both variants are available, implementations of this method should support the old and new routines, using the presence of the serializer argument to differentiate between both. For the new routines, just call this base class function. After the transition period, subclasses likely need not implement deserialize separately anymore at all.

Parameters:
  • serializer (Optional[Serializer]) – DEPRECATED (May 2018). A serializer instance used when deserializing subelements.
  • **kwargs – All relevant properties of the object as keyword arguments. For every (key,value) pair returned by get_serialization_data, the same pair is given as keyword argument as input to this method.
Return type:

FunctionPulseTemplate

duration

Implements duration.

Return type:ExpressionScalar
expression
Return type:ExpressionScalar
function_parameters
Return type:Set[str]
get_serialization_data(serializer=None)[source]

Returns all data relevant for serialization as a dictionary containing only base types.

Implementation hint: In the old serialization routines, if the Serializable contains complex objects which are itself Serializables, a serialized representation for these MUST be obtained by calling the dictify() method of serializer. The reason is that serializer may decide to either return a dictionary to embed or only a reference to the Serializable subelement. This is DEPRECATED behavior as of May 2018. In the new routines, this will happen automatically and every Serializable is only responsible for returning it’s own data and leave nested Serializables in object form.

For the transition time where both implementations are available, implementations of this method should support the old and new routines, using the presence of the serializer argument to differentiate between both. Don’t make use of the implementation in this base class when implementing this method for the old routines.

Parameters:serializer (Serializer) – DEPRECATED (May 2018).A Serializer instance used to serialize complex subelements of this Serializable.
Return type:Dict[str, Any]
Returns:
A dictionary of Python base types (strings, integers, lists/tuples containing these,
etc..) which fully represent the relevant properties of this Serializable for storing and later reconstruction as a Python object.
integral

Implements integral.

Return type:Dict[Union[str, int], ExpressionScalar]
is_interruptable

Implements is_interruptable.

Return type:bool
parameter_names

Implements parameter_names.

Return type:Set[str]
requires_stop(parameters, conditions)[source]

Implements requires_stop().

Return type:bool

3.1.3.5. qupulse.pulses.interpolation module

This module defines strategies for interpolation between points in a pulse table or similar.

Classes:
  • InterpolationStrategy: Interface for interpolation strategies.
  • LinearInterpolationStrategy: Interpolates linearly between two points.
  • HoldInterpolationStrategy: Interpolates by holding the first point’s value.
  • JumpInterpolationStrategy: Interpolates by holding the second point’s value.
class qupulse.pulses.interpolation.InterpolationStrategy[source]

Bases: object

Defines a strategy to interpolate values between two points.

expression

Returns a symbolic expression of the interpolation strategy using (v0,t0) and (v1, t1) to represent start and end point and t as free variable. Note that the expression is only valid for values of t between t0 and t1.

Return type:ExpressionScalar
integral

Returns the symbolic integral of this interpolation strategy using (v0,t0) and (v1,t1) to represent start and end point.

Return type:ExpressionScalar
class qupulse.pulses.interpolation.HoldInterpolationStrategy[source]

Bases: qupulse.pulses.interpolation.InterpolationStrategy

An InterpolationStrategy that interpolates by holding the value of the start point for the entire intermediate space.

expression

Returns a symbolic expression of the interpolation strategy using (v0,t0) and (v1, t1) to represent start and end point and t as free variable. Note that the expression is only valid for values of t between t0 and t1.

Return type:ExpressionScalar
integral

Returns the symbolic integral of this interpolation strategy using (v0,t0) and (v1,t1) to represent start and end point.

Return type:ExpressionScalar
class qupulse.pulses.interpolation.JumpInterpolationStrategy[source]

Bases: qupulse.pulses.interpolation.InterpolationStrategy

An InterpolationStrategy that interpolates by holding the value of the end point for the entire intermediate space.

expression

Returns a symbolic expression of the interpolation strategy using (v0,t0) and (v1, t1) to represent start and end point and t as free variable. Note that the expression is only valid for values of t between t0 and t1.

Return type:ExpressionScalar
integral

Returns the symbolic integral of this interpolation strategy using (v0,t0) and (v1,t1) to represent start and end point.

Return type:ExpressionScalar
class qupulse.pulses.interpolation.LinearInterpolationStrategy[source]

Bases: qupulse.pulses.interpolation.InterpolationStrategy

An InterpolationStrategy that interpolates linearly between two points.

expression

Returns a symbolic expression of the interpolation strategy using (v0,t0) and (v1, t1) to represent start and end point and t as free variable. Note that the expression is only valid for values of t between t0 and t1.

Return type:ExpressionScalar
integral

Returns the symbolic integral of this interpolation strategy using (v0,t0) and (v1,t1) to represent start and end point.

Return type:ExpressionScalar

3.1.3.6. qupulse.pulses.loop_pulse_template module

This module defines LoopPulseTemplate, a higher-order hierarchical pulse template that loops another PulseTemplate based on a condition.

class qupulse.pulses.loop_pulse_template.ForLoopPulseTemplate(body, loop_index, loop_range, identifier=None, *, measurements=None, parameter_constraints=None, registry=None)[source]

Bases: qupulse.pulses.loop_pulse_template.LoopPulseTemplate, qupulse.pulses.measurement.MeasurementDefiner, qupulse.pulses.parameters.ParameterConstrainer

This pulse template allows looping through an parametrized integer range and provides the loop index as a parameter to the body. If you do not need the index in the pulse template, consider using RepetitionPulseTemplate

Parameters:
  • body (PulseTemplate) – The loop body. It is expected to have loop_index as an parameter
  • loop_index (str) – Loop index of the for loop
  • loop_range (Union[int, range, str, Tuple[Any, Any], Tuple[Any, Any, Any], ParametrizedRange]) – Range to loop through
  • identifier (Optional[str]) – Used for serialization
__init__(body, loop_index, loop_range, identifier=None, *, measurements=None, parameter_constraints=None, registry=None)[source]
Parameters:
  • body (PulseTemplate) – The loop body. It is expected to have loop_index as an parameter
  • loop_index (str) – Loop index of the for loop
  • loop_range (Union[int, range, str, Tuple[Any, Any], Tuple[Any, Any, Any], ParametrizedRange]) – Range to loop through
  • identifier (Optional[str]) – Used for serialization
Return type:

None

build_sequence(sequencer, parameters, conditions, measurement_mapping, channel_mapping, instruction_block)[source]

Implements build_sequence().

Return type:None
build_waveform(parameters)[source]
Return type:SequenceWaveform
classmethod deserialize(serializer=None, **kwargs)[source]

Reconstructs the Serializable object from a dictionary.

Implementation hint: For greater clarity, implementations of this method should be precise in their return value, i.e., give their exact class name, and also replace the kwargs argument by a list of arguments required, i.e., those returned by get_serialization_data. Using old serialization routines, if this Serializable contains complex objects which are itself of type Serializable, their dictionary representations MUST be converted into objects using serializers deserialize() method. This is DEPRECATED behavior. Using the new routines, a serializable is only responsible to decode it’s own dictionary, not those of nested objects (i.e., all incoming arguments are already processed by the serialization routines). For the transition time where both variants are available, implementations of this method should support the old and new routines, using the presence of the serializer argument to differentiate between both. For the new routines, just call this base class function. After the transition period, subclasses likely need not implement deserialize separately anymore at all.

Parameters:
  • serializer (Optional[Serializer]) – DEPRECATED (May 2018). A serializer instance used when deserializing subelements.
  • **kwargs – All relevant properties of the object as keyword arguments. For every (key,value) pair returned by get_serialization_data, the same pair is given as keyword argument as input to this method.
Return type:

ForLoopPulseTemplate

duration

Implements duration().

get_serialization_data(serializer=None)[source]

Returns all data relevant for serialization as a dictionary containing only base types.

Implementation hint: In the old serialization routines, if the Serializable contains complex objects which are itself Serializables, a serialized representation for these MUST be obtained by calling the dictify() method of serializer. The reason is that serializer may decide to either return a dictionary to embed or only a reference to the Serializable subelement. This is DEPRECATED behavior as of May 2018. In the new routines, this will happen automatically and every Serializable is only responsible for returning it’s own data and leave nested Serializables in object form.

For the transition time where both implementations are available, implementations of this method should support the old and new routines, using the presence of the serializer argument to differentiate between both. Don’t make use of the implementation in this base class when implementing this method for the old routines.

Parameters:serializer (Serializer) – DEPRECATED (May 2018).A Serializer instance used to serialize complex subelements of this Serializable.
Return type:Dict[str, Any]
Returns:
A dictionary of Python base types (strings, integers, lists/tuples containing these,
etc..) which fully represent the relevant properties of this Serializable for storing and later reconstruction as a Python object.
integral

Implements integral.

Return type:Dict[Union[str, int], ExpressionScalar]
loop_index
Return type:str
loop_range
Return type:ParametrizedRange
measurement_names

Implements measurement_names.

Return type:Set[str]
parameter_names

Implements parameter_names.

Return type:Set[str]
requires_stop(parameters, conditions)[source]

Implements requires_stop().

Return type:bool
class qupulse.pulses.loop_pulse_template.LoopPulseTemplate(body, identifier)[source]

Bases: qupulse.pulses.pulse_template.PulseTemplate

Base class for loop based pulse templates. This class is still abstract and cannot be instantiated.

body
Return type:PulseTemplate
defined_channels

Implements defined_channels.

Return type:Set[Union[str, int]]
is_interruptable

Implements is_interruptable.

measurement_names

Implements measurement_names.

Return type:Set[str]
exception qupulse.pulses.loop_pulse_template.LoopIndexNotUsedException(loop_index, body_parameter_names)[source]

Bases: Exception

3.1.3.7. qupulse.pulses.measurement module

class qupulse.pulses.measurement.MeasurementDefiner(measurements)[source]

Bases: object

get_measurement_windows(parameters, measurement_mapping)[source]

Calculate measurement windows with the given parameter set and rename them woth the measurement mapping

Return type:List[Tuple[str, Real, Real]]
insert_measurement_instruction(instruction_block, parameters, measurement_mapping)[source]
measurement_declarations
Return type:List[Tuple[str, Union[Expression, str, Real], Union[Expression, str, Real]]]
measurement_names

Implements measurement_names.

Return type:Set[str]
measurement_parameters
Return type:Set[str]

3.1.3.8. qupulse.pulses.multi_channel_pulse_template module

This module defines MultiChannelPulseTemplate, which allows the combination of several AtomicPulseTemplates into a single template spanning several channels.

Classes:
  • MultiChannelPulseTemplate: A pulse template defined for several channels by combining pulse
    templates
  • MultiChannelWaveform: A waveform defined for several channels by combining waveforms
class qupulse.pulses.multi_channel_pulse_template.AtomicMultiChannelPulseTemplate(*subtemplates, external_parameters=None, identifier=None, parameter_constraints=None, measurements=None, registry=None, duration=False)[source]

Bases: qupulse.pulses.pulse_template.AtomicPulseTemplate, qupulse.pulses.parameters.ParameterConstrainer

Combines multiple PulseTemplates that are defined on different channels into an AtomicPulseTemplate.

Parallels multiple AtomicPulseTemplates of the same duration. The duration equality check is performed on construction by default. If the duration keyword argument is given the check is performed on instantiation (when build_waveform is called). duration can be a Expression to enforce a certain duration or True for an unspecified duration.

Parameters:
  • *subtemplates – Positional arguments are subtemplates to combine.
  • identifier (Optional[str]) – Forwarded to AtomicPulseTemplate.__init__
  • parameter_constraints (Optional[List[~T]]) – Forwarded to ParameterConstrainer.__init__
  • measurements (Optional[List[Tuple[str, Union[Expression, str, Real], Union[Expression, str, Real]]]]) – Forwarded to AtomicPulseTemplate.__init__
  • duration (Union[str, Expression, bool]) – Enforced duration of the pulse template on instantiation. build_waveform checks all sub-waveforms
  • this duration. If True the equality of durations is only checked durtin instantiation not construction. (have) –
  • external_parameters (Optional[Set[str]]) – No functionality. (Deprecated)
__init__(*subtemplates, external_parameters=None, identifier=None, parameter_constraints=None, measurements=None, registry=None, duration=False)[source]

Parallels multiple AtomicPulseTemplates of the same duration. The duration equality check is performed on construction by default. If the duration keyword argument is given the check is performed on instantiation (when build_waveform is called). duration can be a Expression to enforce a certain duration or True for an unspecified duration.

Parameters:
  • *subtemplates – Positional arguments are subtemplates to combine.
  • identifier (Optional[str]) – Forwarded to AtomicPulseTemplate.__init__
  • parameter_constraints (Optional[List[~T]]) – Forwarded to ParameterConstrainer.__init__
  • measurements (Optional[List[Tuple[str, Union[Expression, str, Real], Union[Expression, str, Real]]]]) – Forwarded to AtomicPulseTemplate.__init__
  • duration (Union[str, Expression, bool]) – Enforced duration of the pulse template on instantiation. build_waveform checks all sub-waveforms
  • this duration. If True the equality of durations is only checked durtin instantiation not construction. (have) –
  • external_parameters (Optional[Set[str]]) – No functionality. (Deprecated)
Return type:

None

build_waveform(parameters, channel_mapping)[source]

Implements build_waveform().

Return type:Optional[Waveform]
defined_channels

Implements defined_channels.

Return type:Set[Union[str, int]]
classmethod deserialize(serializer=None, **kwargs)[source]

Reconstructs the Serializable object from a dictionary.

Implementation hint: For greater clarity, implementations of this method should be precise in their return value, i.e., give their exact class name, and also replace the kwargs argument by a list of arguments required, i.e., those returned by get_serialization_data. Using old serialization routines, if this Serializable contains complex objects which are itself of type Serializable, their dictionary representations MUST be converted into objects using serializers deserialize() method. This is DEPRECATED behavior. Using the new routines, a serializable is only responsible to decode it’s own dictionary, not those of nested objects (i.e., all incoming arguments are already processed by the serialization routines). For the transition time where both variants are available, implementations of this method should support the old and new routines, using the presence of the serializer argument to differentiate between both. For the new routines, just call this base class function. After the transition period, subclasses likely need not implement deserialize separately anymore at all.

Parameters:
  • serializer (Optional[Serializer]) – DEPRECATED (May 2018). A serializer instance used when deserializing subelements.
  • **kwargs – All relevant properties of the object as keyword arguments. For every (key,value) pair returned by get_serialization_data, the same pair is given as keyword argument as input to this method.
Return type:

AtomicMultiChannelPulseTemplate

duration

Implements duration.

Return type:ExpressionScalar
get_measurement_windows(parameters, measurement_mapping)[source]

Calculate measurement windows with the given parameter set and rename them woth the measurement mapping

Return type:List[Tuple[str, Real, Real]]
get_serialization_data(serializer=None)[source]

Returns all data relevant for serialization as a dictionary containing only base types.

Implementation hint: In the old serialization routines, if the Serializable contains complex objects which are itself Serializables, a serialized representation for these MUST be obtained by calling the dictify() method of serializer. The reason is that serializer may decide to either return a dictionary to embed or only a reference to the Serializable subelement. This is DEPRECATED behavior as of May 2018. In the new routines, this will happen automatically and every Serializable is only responsible for returning it’s own data and leave nested Serializables in object form.

For the transition time where both implementations are available, implementations of this method should support the old and new routines, using the presence of the serializer argument to differentiate between both. Don’t make use of the implementation in this base class when implementing this method for the old routines.

Parameters:serializer (Serializer) – DEPRECATED (May 2018).A Serializer instance used to serialize complex subelements of this Serializable.
Return type:Dict[str, Any]
Returns:
A dictionary of Python base types (strings, integers, lists/tuples containing these,
etc..) which fully represent the relevant properties of this Serializable for storing and later reconstruction as a Python object.
integral

Implements integral.

Return type:Dict[Union[str, int], ExpressionScalar]
measurement_names

Implements measurement_names.

Return type:Set[str]
parameter_names

Implements parameter_names.

Return type:Set[str]
requires_stop(parameters, conditions)[source]

Implements requires_stop().

Return type:bool
subtemplates
Return type:Sequence[Union[AtomicPulseTemplate, MappingPulseTemplate]]
class qupulse.pulses.multi_channel_pulse_template.ParallelConstantChannelPulseTemplate(template, overwritten_channels, *, identifier=None, registry=None)[source]

Bases: qupulse.pulses.pulse_template.PulseTemplate

build_sequence(*args, **kwargs)[source]

Implements build_sequence().

build_waveform(parameters, channel_mapping)[source]
Return type:Optional[Waveform]
defined_channels

Implements defined_channels.

Return type:Set[Union[str, int]]
duration

Implements duration.

Return type:ExpressionScalar
get_serialization_data(serializer=None)[source]

Returns all data relevant for serialization as a dictionary containing only base types.

Implementation hint: In the old serialization routines, if the Serializable contains complex objects which are itself Serializables, a serialized representation for these MUST be obtained by calling the dictify() method of serializer. The reason is that serializer may decide to either return a dictionary to embed or only a reference to the Serializable subelement. This is DEPRECATED behavior as of May 2018. In the new routines, this will happen automatically and every Serializable is only responsible for returning it’s own data and leave nested Serializables in object form.

For the transition time where both implementations are available, implementations of this method should support the old and new routines, using the presence of the serializer argument to differentiate between both. Don’t make use of the implementation in this base class when implementing this method for the old routines.

Parameters:serializer (Serializer) – DEPRECATED (May 2018).A Serializer instance used to serialize complex subelements of this Serializable.
Return type:Dict[str, Any]
Returns:
A dictionary of Python base types (strings, integers, lists/tuples containing these,
etc..) which fully represent the relevant properties of this Serializable for storing and later reconstruction as a Python object.
integral

Implements integral.

Return type:Dict[Union[str, int], ExpressionScalar]
is_interruptable

Implements is_interruptable.

Return type:bool
measurement_names

Implements measurement_names.

Return type:Set[str]
overwritten_channels
Return type:Mapping[str, ExpressionScalar]
parameter_names

Implements parameter_names.

requires_stop(*args, **kwargs)[source]

Implements requires_stop().

Return type:bool
template
Return type:PulseTemplate
transformation_parameters
Return type:Set[str]

3.1.3.9. qupulse.pulses.parameters module

This module defines parameters and parameter declaration for the usage in pulse modelling.

Classes:
  • Parameter: A base class representing a single pulse parameter.
  • ConstantParameter: A single parameter with a constant value.
  • MappedParameter: A parameter whose value is mathematically computed from another parameter.
  • ParameterNotProvidedException.
  • ParameterValueIllegalException.
class qupulse.pulses.parameters.Parameter[source]

Bases: object

A parameter for pulses.

Parameter specifies a concrete value which is inserted instead of the parameter declaration reference in a PulseTemplate if it satisfies the minimum and maximum boundary of the corresponding ParameterDeclaration. Implementations of Parameter may provide a single constant value or obtain values by computation (e.g. from measurement results).

get_value()[source]

Compute and return the parameter value.

Return type:Real
requires_stop

Query whether the evaluation of this Parameter instance requires an interruption in execution/sequencing, e.g., because it depends on data that is only measured in during the next execution.

Return type:bool
Returns:True, if evaluating this Parameter instance requires an interruption.
class qupulse.pulses.parameters.ConstantParameter(value)[source]

Bases: qupulse.pulses.parameters.Parameter

A pulse parameter with a constant value.

Create a ConstantParameter instance.

Parameters:value (Real) – The value of the parameter
__init__(value)[source]

Create a ConstantParameter instance.

Parameters:value (Real) – The value of the parameter
Return type:None
get_value()[source]

Implements get_value().

Return type:Union[Real, ndarray]
requires_stop

Implements requires_stop.

Return type:bool
exception qupulse.pulses.parameters.ParameterNotProvidedException(parameter_name)[source]

Bases: Exception

Indicates that a required parameter value was not provided.

exception qupulse.pulses.parameters.ParameterConstraintViolation(constraint, parameters)[source]

Bases: Exception

class qupulse.pulses.parameters.ParameterConstraint(relation)[source]

Bases: qupulse.serialization.AnonymousSerializable

A parameter constraint like ‘t_2 < 2.7’ that can be used to set bounds to parameters.

affected_parameters
Return type:Set[str]
get_serialization_data()[source]

Return all data relevant for serialization as a JSON compatible type that is accepted as constructor argument

Return type:str
Returns:A JSON compatible type that can be used to construct an equal object.
is_fulfilled(parameter)[source]
Return type:bool
sympified_expression
Return type:Expr

3.1.3.10. qupulse.pulses.plotting module

This module defines plotting functionality for instantiated PulseTemplates using matplotlib.

Classes:
  • PlottingNotPossibleException.
Functions:
  • plot: Plot a pulse using matplotlib.
qupulse.pulses.plotting.render(program, sample_rate=10.0, render_measurements=False, time_slice=None)[source]

‘Renders’ a pulse program.

Samples all contained waveforms into an array according to the control flow of the program.

Parameters:
  • program (Union[AbstractInstructionBlock, Loop]) – The pulse (sub)program to render. Can be represented either by a Loop object or the more old-fashioned InstructionBlock.
  • sample_rate (Real) – The sample rate in GHz.
  • render_measurements (bool) – If True, the third return value is a list of measurement windows.
  • time_slice (Optional[Tuple[Real, Real]]) – The time slice to be plotted. If None, the entire pulse will be shown.
Return type:

Union[Tuple[ndarray, Dict[Union[str, int], ndarray]], Tuple[ndarray, Dict[Union[str, int], ndarray], List[Tuple[str, Real, Real]]]]

Returns:

A tuple (times, values, measurements). times is a numpy.ndarray of dimensions sample_count where containing the time values. voltages is a dictionary of one numpy.ndarray of dimensions sample_count per defined channel containing corresponding sampled voltage values for that channel. measurements is a sequence of all measurements where each measurement is represented by a tuple (name, start_time, duration).

qupulse.pulses.plotting.plot(pulse, parameters=None, sample_rate=10, axes=None, show=True, plot_channels=None, plot_measurements=None, stepped=True, maximum_points=1000000, time_slice=None, **kwargs)[source]

Plots a pulse using matplotlib.

The given pulse template will first be turned into a pulse program (represented by a Loop object) with the provided parameters. The render() function is then invoked to obtain voltage samples over the entire duration of the pulse which are then plotted in a matplotlib figure.

Parameters:
  • pulse (PulseTemplate) – The pulse to be plotted.
  • parameters (Optional[Dict[str, Parameter]]) – An optional mapping of parameter names to Parameter objects.
  • sample_rate (Real) – The rate with which the waveforms are sampled for the plot in samples per time unit. (default = 10)
  • axes (Optional[Any]) – matplotlib Axes object the pulse will be drawn into if provided
  • show (bool) – If true, the figure will be shown
  • plot_channels (Optional[Set[Union[str, int]]]) – If specified only channels from this set will be plotted. If omitted all channels will be.
  • stepped (bool) – If true pyplot.step is used for plotting
  • plot_measurements (Optional[Set[str]]) – If specified measurements in this set will be plotted. If omitted no measurements will be.
  • maximum_points (int) – If the sampled waveform is bigger, it is not plotted
  • time_slice (Optional[Tuple[Real, Real]]) – The time slice to be plotted. If None, the entire pulse will be shown.
  • kwargs – Forwarded to pyplot. Overwrites other settings.
Return type:

Any

Returns:

matplotlib.pyplot.Figure instance in which the pulse is rendered

Raises:
  • PlottingNotPossibleException if the sequencing is interrupted before it finishes, e.g., – because a parameter value could not be evaluated
  • all Exceptions possibly raised during sequencing
exception qupulse.pulses.plotting.PlottingNotPossibleException(pulse, description=None)[source]

Bases: Exception

Indicates that plotting is not possible because the sequencing process did not translate the entire given PulseTemplate structure.

3.1.3.11. qupulse.pulses.point_pulse_template module

qupulse.pulses.point_pulse_template.PointWaveform

alias of qupulse._program.waveforms.TableWaveform

class qupulse.pulses.point_pulse_template.PointPulseTemplate(time_point_tuple_list, channel_names, *, parameter_constraints=None, measurements=None, identifier=None, registry=None)[source]

Bases: qupulse.pulses.pulse_template.AtomicPulseTemplate, qupulse.pulses.parameters.ParameterConstrainer

build_waveform(parameters, channel_mapping)[source]

Implements build_waveform().

Return type:Optional[TableWaveform]
defined_channels

Implements defined_channels.

Return type:Set[Union[str, int]]
duration

Implements duration.

Return type:Expression
get_serialization_data(serializer=None)[source]

Returns all data relevant for serialization as a dictionary containing only base types.

Implementation hint: In the old serialization routines, if the Serializable contains complex objects which are itself Serializables, a serialized representation for these MUST be obtained by calling the dictify() method of serializer. The reason is that serializer may decide to either return a dictionary to embed or only a reference to the Serializable subelement. This is DEPRECATED behavior as of May 2018. In the new routines, this will happen automatically and every Serializable is only responsible for returning it’s own data and leave nested Serializables in object form.

For the transition time where both implementations are available, implementations of this method should support the old and new routines, using the presence of the serializer argument to differentiate between both. Don’t make use of the implementation in this base class when implementing this method for the old routines.

Parameters:serializer (Serializer) – DEPRECATED (May 2018).A Serializer instance used to serialize complex subelements of this Serializable.
Return type:Dict[str, Any]
Returns:
A dictionary of Python base types (strings, integers, lists/tuples containing these,
etc..) which fully represent the relevant properties of this Serializable for storing and later reconstruction as a Python object.
integral

Implements integral.

Return type:Dict[Union[str, int], ExpressionScalar]
parameter_names

Implements parameter_names.

Return type:Set[str]
point_parameters
Return type:Set[str]
point_pulse_entries
Return type:Sequence[PointPulseEntry]
requires_stop(parameters, conditions)[source]

Implements requires_stop().

Return type:bool
class qupulse.pulses.point_pulse_template.PointPulseEntry[source]

Bases: qupulse.pulses.table_pulse_template.TableEntry

instantiate(parameters, num_channels)[source]
Return type:Sequence[TableWaveformEntry]
qupulse.pulses.point_pulse_template.PointWaveformEntry

alias of qupulse._program.waveforms.TableWaveformEntry

exception qupulse.pulses.point_pulse_template.InvalidPointDimension(expected, received)[source]

Bases: Exception

3.1.3.12. qupulse.pulses.pulse_template module

This module defines the abstract PulseTemplate class which is the basis of any pulse model in the qupulse.

Classes:
  • PulseTemplate: Represents the parametrized general structure of a pulse.
  • AtomicPulseTemplate: PulseTemplate that does imply any control flow disruptions and can be
    directly translated into a waveform.
class qupulse.pulses.pulse_template.PulseTemplate(*, identifier)[source]

Bases: qupulse.serialization.Serializable, qupulse.pulses.sequencing.SequencingElement

A PulseTemplate represents the parametrized general structure of a pulse.

A PulseTemplate described a pulse in an abstract way: It defines the structure of a pulse but might leave some timings or voltage levels undefined, thus declaring parameters. This allows to reuse a PulseTemplate for several pulses which have the same overall structure and differ only in concrete values for the parameters. Obtaining an actual pulse which can be executed by specifying values for these parameters is called instantiation of the PulseTemplate and achieved by invoking the sequencing process.

create_program(*, parameters=None, measurement_mapping=None, channel_mapping=None, global_transformation=None, to_single_waveform=None)[source]

Translates this PulseTemplate into a program Loop.

The returned Loop represents the PulseTemplate with all parameter values instantiated provided as dictated by the parameters argument. Optionally, channels and measurements defined in the PulseTemplate can be renamed/mapped via the channel_mapping and measurement_mapping arguments.

Parameters:
Return type:

Optional[Loop]

Returns:

A Loop object corresponding to this PulseTemplate.

defined_channels

Returns the number of hardware output channels this PulseTemplate defines.

Return type:Set[Union[str, int]]
duration

An expression for the duration of this PulseTemplate.

Return type:ExpressionScalar
integral

Returns an expression giving the integral over the pulse.

Return type:Dict[Union[str, int], ExpressionScalar]
is_interruptable

Return true, if this PulseTemplate contains points at which it can halt if interrupted.

Return type:bool
measurement_names

The set of measurement identifiers in this pulse template.

Return type:Set[str]
num_channels

The number of channels this PulseTemplate defines

Return type:int
parameter_names

The set of names of parameters required to instantiate this PulseTemplate.

Return type:Set[str]
class qupulse.pulses.pulse_template.AtomicPulseTemplate(*, identifier, measurements)[source]

Bases: qupulse.pulses.pulse_template.PulseTemplate, qupulse.pulses.measurement.MeasurementDefiner

A PulseTemplate that does not imply any control flow disruptions and can be directly translated into a waveform.

Implies that no AtomicPulseTemplate object is interruptable.

atomicity

Is the element translated to a single EXECInstruction with one waveform

Return type:bool
build_sequence(sequencer, parameters, conditions, measurement_mapping, channel_mapping, instruction_block)[source]

Implements build_sequence().

Return type:None
build_waveform(parameters, channel_mapping)[source]

Translate this PulseTemplate into a waveform according to the given parameters.

Subclasses of AtomicPulseTemplate must check for ParameterConstraintViolation errors in their build_waveform implementation and raise corresponding exceptions.

Parameters:
  • parameters (Dict(str -> Parameter)) – A mapping of parameter names to real numbers.
  • channel_mapping (Dict(ChannelID -> ChannelID) – A mapping of Channel IDs
Return type:

Optional[Waveform]

Returns:

Waveform object represented by this PulseTemplate object or None, if this object

does not represent a valid waveform of finite length.

is_interruptable()[source]

Implements is_interruptable().

Return type:bool
measurement_names

Implements measurement_names.

Return type:Set[str]
exception qupulse.pulses.pulse_template.DoubleParameterNameException(templateA, templateB, names)[source]

Bases: Exception

3.1.3.13. qupulse.pulses.mapping_pulse_template module

class qupulse.pulses.mapping_pulse_template.MappingPulseTemplate(template, *, identifier=None, parameter_mapping=None, measurement_mapping=None, channel_mapping=None, parameter_constraints=None, allow_partial_parameter_mapping=False, registry=None)[source]

Bases: qupulse.pulses.pulse_template.PulseTemplate, qupulse.pulses.parameters.ParameterConstrainer

This class can be used to remap parameters, the names of measurement windows and the names of channels. Besides the standard constructor, there is a static member function from_tuple for convenience. The class also allows constraining parameters by deriving from ParameterConstrainer

Standard constructor for the MappingPulseTemplate.

Mappings that are not specified are defaulted to identity mappings. Channels and measurement names of the encapsulated template can be mapped partially by default. F.i. if channel_mapping only contains one of two channels the other channel name is mapped to itself. However, if a parameter mapping is specified and one or more parameters are not mapped a MissingMappingException is raised. To allow partial mappings and enable the same behaviour as for the channel and measurement name mapping allow_partial_parameter_mapping must be set to True. Furthermore parameter constrains can be specified.

Parameters:
  • template (PulseTemplate) – The encapsulated pulse template whose parameters, measurement names and channels are mapped
  • parameter_mapping (Optional[Dict[str, str]]) – if not none, mappings for all parameters must be specified
  • measurement_mapping (Optional[Dict[str, str]]) – mappings for other measurement names are inserted
  • channel_mapping (Optional[Dict[Union[str, int], Union[str, int]]]) – mappings for other channels are auto inserted
  • parameter_constraints (Optional[List[str]]) –
  • allow_partial_parameter_mapping (bool) –
__init__(template, *, identifier=None, parameter_mapping=None, measurement_mapping=None, channel_mapping=None, parameter_constraints=None, allow_partial_parameter_mapping=False, registry=None)[source]

Standard constructor for the MappingPulseTemplate.

Mappings that are not specified are defaulted to identity mappings. Channels and measurement names of the encapsulated template can be mapped partially by default. F.i. if channel_mapping only contains one of two channels the other channel name is mapped to itself. However, if a parameter mapping is specified and one or more parameters are not mapped a MissingMappingException is raised. To allow partial mappings and enable the same behaviour as for the channel and measurement name mapping allow_partial_parameter_mapping must be set to True. Furthermore parameter constrains can be specified.

Parameters:
  • template (PulseTemplate) – The encapsulated pulse template whose parameters, measurement names and channels are mapped
  • parameter_mapping (Optional[Dict[str, str]]) – if not none, mappings for all parameters must be specified
  • measurement_mapping (Optional[Dict[str, str]]) – mappings for other measurement names are inserted
  • channel_mapping (Optional[Dict[Union[str, int], Union[str, int]]]) – mappings for other channels are auto inserted
  • parameter_constraints (Optional[List[str]]) –
  • allow_partial_parameter_mapping (bool) –
Return type:

None

build_sequence(sequencer, parameters, conditions, measurement_mapping, channel_mapping, instruction_block)[source]

Implements build_sequence().

Return type:None
build_waveform(parameters, channel_mapping)[source]

This gets called if the parent is atomic

Return type:Waveform
channel_mapping
Return type:Dict[Union[str, int], Union[str, int]]
defined_channels

Implements defined_channels.

Return type:Set[Union[str, int]]
classmethod deserialize(serializer=None, **kwargs)[source]

Reconstructs the Serializable object from a dictionary.

Implementation hint: For greater clarity, implementations of this method should be precise in their return value, i.e., give their exact class name, and also replace the kwargs argument by a list of arguments required, i.e., those returned by get_serialization_data. Using old serialization routines, if this Serializable contains complex objects which are itself of type Serializable, their dictionary representations MUST be converted into objects using serializers deserialize() method. This is DEPRECATED behavior. Using the new routines, a serializable is only responsible to decode it’s own dictionary, not those of nested objects (i.e., all incoming arguments are already processed by the serialization routines). For the transition time where both variants are available, implementations of this method should support the old and new routines, using the presence of the serializer argument to differentiate between both. For the new routines, just call this base class function. After the transition period, subclasses likely need not implement deserialize separately anymore at all.

Parameters:
  • serializer (Optional[Serializer]) – DEPRECATED (May 2018). A serializer instance used when deserializing subelements.
  • **kwargs – All relevant properties of the object as keyword arguments. For every (key,value) pair returned by get_serialization_data, the same pair is given as keyword argument as input to this method.
Return type:

MappingPulseTemplate

duration

Implements duration.

Return type:Expression
static from_tuple(mapping_tuple)[source]

Construct a MappingPulseTemplate from a tuple of mappings. The mappings are automatically assigned to the mapped elements based on their content. :type mapping_tuple: Union[Tuple[PulseTemplate], Tuple[PulseTemplate, Dict[~KT, ~VT]], Tuple[PulseTemplate, Dict[~KT, ~VT], Dict[~KT, ~VT]], Tuple[PulseTemplate, Dict[~KT, ~VT], Dict[~KT, ~VT], Dict[~KT, ~VT]]] :param mapping_tuple: A tuple of mappings :rtype: MappingPulseTemplate :return: Constructed MappingPulseTemplate

get_measurement_windows(parameters, measurement_mapping)[source]
Return type:List[~T]
get_serialization_data(serializer=None)[source]

Returns all data relevant for serialization as a dictionary containing only base types.

Implementation hint: In the old serialization routines, if the Serializable contains complex objects which are itself Serializables, a serialized representation for these MUST be obtained by calling the dictify() method of serializer. The reason is that serializer may decide to either return a dictionary to embed or only a reference to the Serializable subelement. This is DEPRECATED behavior as of May 2018. In the new routines, this will happen automatically and every Serializable is only responsible for returning it’s own data and leave nested Serializables in object form.

For the transition time where both implementations are available, implementations of this method should support the old and new routines, using the presence of the serializer argument to differentiate between both. Don’t make use of the implementation in this base class when implementing this method for the old routines.

Parameters:serializer (Serializer) – DEPRECATED (May 2018).A Serializer instance used to serialize complex subelements of this Serializable.
Return type:Dict[str, Any]
Returns:
A dictionary of Python base types (strings, integers, lists/tuples containing these,
etc..) which fully represent the relevant properties of this Serializable for storing and later reconstruction as a Python object.
get_updated_channel_mapping(channel_mapping)[source]
Return type:Dict[Union[str, int], Union[str, int]]
get_updated_measurement_mapping(measurement_mapping)[source]
Return type:Dict[str, str]
integral

Implements integral.

Return type:Dict[Union[str, int], ExpressionScalar]
is_interruptable

Implements is_interruptable.

Return type:bool
map_parameters(parameters)[source]

Map parameter values according to the defined mappings.

Parameters:parameters (Dict(str -> Parameter)) – A mapping of parameter names to Parameter objects/values.
Return type:Dict[str, Parameter]
Returns:A new dictionary which maps parameter names to parameter values which have been mapped according to the mappings defined for template.
measurement_mapping
Return type:Dict[str, str]
measurement_names

Implements measurement_names.

Return type:Set[str]
parameter_mapping
Return type:Dict[str, Expression]
parameter_names

Implements parameter_names.

Return type:Set[str]
requires_stop(parameters, conditions)[source]

Implements requires_stop().

Return type:bool
template
Return type:PulseTemplate
exception qupulse.pulses.mapping_pulse_template.MissingMappingException(template, key)[source]

Bases: Exception

Indicates that no mapping was specified for some parameter declaration of a SequencePulseTemplate’s subtemplate.

exception qupulse.pulses.mapping_pulse_template.UnnecessaryMappingException(template, key)[source]

Bases: Exception

Indicates that a mapping was provided that does not correspond to any of a SequencePulseTemplate’s subtemplate’s parameter declarations and is thus obsolete.

3.1.3.14. qupulse.pulses.repetition_pulse_template module

This module defines RepetitionPulseTemplate, a higher-order hierarchical pulse template that represents the n-times repetition of another PulseTemplate.

class qupulse.pulses.repetition_pulse_template.RepetitionPulseTemplate(body, repetition_count, identifier=None, *args, parameter_constraints=None, measurements=None, registry=None)[source]

Bases: qupulse.pulses.loop_pulse_template.LoopPulseTemplate, qupulse.pulses.parameters.ParameterConstrainer, qupulse.pulses.measurement.MeasurementDefiner

Repeats a PulseTemplate a constant number of times (possibly determined by a parameter value).

RepetitionPulseTemplate simply repeats the given body PulseTemplate with the same parameter set for the specified number of times. It does not provide a loop index to the subtemplate. If you need to loop over an integer range and provide an index to the repeated template (at the cost of sequencing performance), use ForLoopPulseTemplate.

Create a new RepetitionPulseTemplate instance.

Parameters:
  • body (PulseTemplate) – The PulseTemplate which will be repeated.
  • repetition_count (int or ParameterDeclaration) – The number of repetitions either as a constant integer value or as a parameter declaration.
  • identifier (str) – A unique identifier for use in serialization. (optional)
__init__(body, repetition_count, identifier=None, *args, parameter_constraints=None, measurements=None, registry=None)[source]

Create a new RepetitionPulseTemplate instance.

Parameters:
  • body (PulseTemplate) – The PulseTemplate which will be repeated.
  • repetition_count (int or ParameterDeclaration) – The number of repetitions either as a constant integer value or as a parameter declaration.
  • identifier (str) – A unique identifier for use in serialization. (optional)
Return type:

None

build_sequence(sequencer, parameters, conditions, measurement_mapping, channel_mapping, instruction_block)[source]

Implements build_sequence().

Return type:None
classmethod deserialize(serializer=None, **kwargs)[source]

Reconstructs the Serializable object from a dictionary.

Implementation hint: For greater clarity, implementations of this method should be precise in their return value, i.e., give their exact class name, and also replace the kwargs argument by a list of arguments required, i.e., those returned by get_serialization_data. Using old serialization routines, if this Serializable contains complex objects which are itself of type Serializable, their dictionary representations MUST be converted into objects using serializers deserialize() method. This is DEPRECATED behavior. Using the new routines, a serializable is only responsible to decode it’s own dictionary, not those of nested objects (i.e., all incoming arguments are already processed by the serialization routines). For the transition time where both variants are available, implementations of this method should support the old and new routines, using the presence of the serializer argument to differentiate between both. For the new routines, just call this base class function. After the transition period, subclasses likely need not implement deserialize separately anymore at all.

Parameters:
  • serializer (Optional[Serializer]) – DEPRECATED (May 2018). A serializer instance used when deserializing subelements.
  • **kwargs – All relevant properties of the object as keyword arguments. For every (key,value) pair returned by get_serialization_data, the same pair is given as keyword argument as input to this method.
Return type:

RepetitionPulseTemplate

duration

Implements duration.

Return type:ExpressionScalar
get_repetition_count_value(parameters)[source]
Return type:int
get_serialization_data(serializer=None)[source]

Returns all data relevant for serialization as a dictionary containing only base types.

Implementation hint: In the old serialization routines, if the Serializable contains complex objects which are itself Serializables, a serialized representation for these MUST be obtained by calling the dictify() method of serializer. The reason is that serializer may decide to either return a dictionary to embed or only a reference to the Serializable subelement. This is DEPRECATED behavior as of May 2018. In the new routines, this will happen automatically and every Serializable is only responsible for returning it’s own data and leave nested Serializables in object form.

For the transition time where both implementations are available, implementations of this method should support the old and new routines, using the presence of the serializer argument to differentiate between both. Don’t make use of the implementation in this base class when implementing this method for the old routines.

Parameters:serializer (Serializer) – DEPRECATED (May 2018).A Serializer instance used to serialize complex subelements of this Serializable.
Return type:Dict[str, Any]
Returns:
A dictionary of Python base types (strings, integers, lists/tuples containing these,
etc..) which fully represent the relevant properties of this Serializable for storing and later reconstruction as a Python object.
integral

Implements integral.

Return type:Dict[Union[str, int], ExpressionScalar]
measurement_names

Implements measurement_names.

Return type:Set[str]
parameter_names

Implements parameter_names.

Return type:Set[str]
repetition_count

The amount of repetitions. Either a constant integer or a ParameterDeclaration object.

Return type:ExpressionScalar
requires_stop(parameters, conditions)[source]

Implements requires_stop().

Return type:bool
exception qupulse.pulses.repetition_pulse_template.ParameterNotIntegerException(parameter_name, parameter_value)[source]

Bases: Exception

Indicates that the value of the parameter given as repetition count was not an integer.

3.1.3.15. qupulse.pulses.sequence_pulse_template module

This module defines SequencePulseTemplate, a higher-order hierarchical pulse template that combines several other PulseTemplate objects for sequential execution.

class qupulse.pulses.sequence_pulse_template.SequencePulseTemplate(*subtemplates, external_parameters=None, identifier=None, parameter_constraints=None, measurements=None, registry=None)[source]

Bases: qupulse.pulses.pulse_template.PulseTemplate, qupulse.pulses.parameters.ParameterConstrainer, qupulse.pulses.measurement.MeasurementDefiner

A sequence of different PulseTemplates.

SequencePulseTemplate allows to group several PulseTemplates (subtemplates) into one larger sequence, i.e., when instantiating a pulse from a SequencePulseTemplate all pulses instantiated from the subtemplates are queued for execution right after one another. SequencePulseTemplate requires to specify a mapping of parameter declarations from its subtemplates to its own, enabling renaming and mathematical transformation of parameters.

Create a new SequencePulseTemplate instance.

Requires a (correctly ordered) list of subtemplates in the form (PulseTemplate, Dict(str -> str)) where the dictionary is a mapping between the external parameters exposed by this SequencePulseTemplate to the parameters declared by the subtemplates, specifying how the latter are derived from the former, i.e., the mapping is subtemplate_parameter_name -> mapping_expression (as str) where the free variables in the mapping_expression are parameters declared by this SequencePulseTemplate.

The following requirements must be satisfied:
  • for each parameter declared by a subtemplate, a mapping expression must be provided
  • each free variable in a mapping expression must be declared as an external parameter
    of this SequencePulseTemplate
Parameters:
  • subtemplates (List(Subtemplate)) – The list of subtemplates of this SequencePulseTemplate as tuples of the form (PulseTemplate, Dict(str -> str)).
  • external_parameters (List(str)) – A set of names for external parameters of this SequencePulseTemplate. Deprecated.
  • identifier (str) – A unique identifier for use in serialization. (optional)
__init__(*subtemplates, external_parameters=None, identifier=None, parameter_constraints=None, measurements=None, registry=None)[source]

Create a new SequencePulseTemplate instance.

Requires a (correctly ordered) list of subtemplates in the form (PulseTemplate, Dict(str -> str)) where the dictionary is a mapping between the external parameters exposed by this SequencePulseTemplate to the parameters declared by the subtemplates, specifying how the latter are derived from the former, i.e., the mapping is subtemplate_parameter_name -> mapping_expression (as str) where the free variables in the mapping_expression are parameters declared by this SequencePulseTemplate.

The following requirements must be satisfied:
  • for each parameter declared by a subtemplate, a mapping expression must be provided
  • each free variable in a mapping expression must be declared as an external parameter
    of this SequencePulseTemplate
Parameters:
  • subtemplates (List(Subtemplate)) – The list of subtemplates of this SequencePulseTemplate as tuples of the form (PulseTemplate, Dict(str -> str)).
  • external_parameters (List(str)) – A set of names for external parameters of this SequencePulseTemplate. Deprecated.
  • identifier (str) – A unique identifier for use in serialization. (optional)
Return type:

None

build_sequence(sequencer, parameters, conditions, measurement_mapping, channel_mapping, instruction_block)[source]

Implements build_sequence().

Return type:None
build_waveform(parameters, channel_mapping)[source]
Return type:SequenceWaveform
classmethod concatenate(*pulse_templates, **kwargs)[source]

Sequences the given pulse templates by creating a SequencePulseTemplate. Pulse templates that are SequencePulseTemplates and do not carry additional information (identifier, measurements, parameter constraints) are not used directly but their sub templates are. :param *pulse_templates: Pulse templates to concatenate :param **kwargs: Forwarded to the __init__

Returns: Concatenated templates

Return type:SequencePulseTemplate
defined_channels

Implements defined_channels.

Return type:Set[Union[str, int]]
classmethod deserialize(serializer=None, **kwargs)[source]

Reconstructs the Serializable object from a dictionary.

Implementation hint: For greater clarity, implementations of this method should be precise in their return value, i.e., give their exact class name, and also replace the kwargs argument by a list of arguments required, i.e., those returned by get_serialization_data. Using old serialization routines, if this Serializable contains complex objects which are itself of type Serializable, their dictionary representations MUST be converted into objects using serializers deserialize() method. This is DEPRECATED behavior. Using the new routines, a serializable is only responsible to decode it’s own dictionary, not those of nested objects (i.e., all incoming arguments are already processed by the serialization routines). For the transition time where both variants are available, implementations of this method should support the old and new routines, using the presence of the serializer argument to differentiate between both. For the new routines, just call this base class function. After the transition period, subclasses likely need not implement deserialize separately anymore at all.

Parameters:
  • serializer (Optional[Serializer]) – DEPRECATED (May 2018). A serializer instance used when deserializing subelements.
  • **kwargs – All relevant properties of the object as keyword arguments. For every (key,value) pair returned by get_serialization_data, the same pair is given as keyword argument as input to this method.
Return type:

SequencePulseTemplate

duration

Implements duration().

get_serialization_data(serializer=None)[source]

Returns all data relevant for serialization as a dictionary containing only base types.

Implementation hint: In the old serialization routines, if the Serializable contains complex objects which are itself Serializables, a serialized representation for these MUST be obtained by calling the dictify() method of serializer. The reason is that serializer may decide to either return a dictionary to embed or only a reference to the Serializable subelement. This is DEPRECATED behavior as of May 2018. In the new routines, this will happen automatically and every Serializable is only responsible for returning it’s own data and leave nested Serializables in object form.

For the transition time where both implementations are available, implementations of this method should support the old and new routines, using the presence of the serializer argument to differentiate between both. Don’t make use of the implementation in this base class when implementing this method for the old routines.

Parameters:serializer (Serializer) – DEPRECATED (May 2018).A Serializer instance used to serialize complex subelements of this Serializable.
Return type:Dict[str, Any]
Returns:
A dictionary of Python base types (strings, integers, lists/tuples containing these,
etc..) which fully represent the relevant properties of this Serializable for storing and later reconstruction as a Python object.
integral

Implements integral.

Return type:Dict[Union[str, int], ExpressionScalar]
is_interruptable

Implements is_interruptable.

Return type:bool
measurement_names

Implements measurement_names.

Return type:Set[str]
parameter_names

Implements parameter_names.

Return type:Set[str]
requires_stop(parameters, conditions)[source]

Returns the stop requirement of the first subtemplate. If a later subtemplate requires a stop the SequencePulseTemplate can be partially sequenced.

Return type:bool
subtemplates
Return type:List[MappingPulseTemplate]

3.1.3.16. qupulse.pulses.sequencing module

This module provides sequencing functionality: It defines classes and algorithms required to translate PulseTemplates into a hardware understandable abstract instruction sequence of instantiated pulses or waveforms.

Classes:
  • SequencingElement: Interface for objects that can be translated into instruction sequences.
  • Sequencer: Controller of the sequencing/translation process.
class qupulse.pulses.sequencing.SequencingElement[source]

Bases: object

An entity which can be sequenced using Sequencer.

DEPRECATED (September 2018). This is outdated code. For obtaining pulses for execution from pulse templates, refer to PulseTemplate.create_program().

See also

Sequencer

atomicity()[source]

Is the element translated to a single EXECInstruction with one waveform

Return type:bool
build_sequence(sequencer, parameters, conditions, measurement_mapping, channel_mapping, instruction_block)[source]

Translate this SequencingElement into an instruction sequence for the given instruction_block using sequencer and the given parameter and condition sets.

Implementation guide: Use instruction_block methods to add instructions or create new InstructionBlocks. Use sequencer to push child elements to the translation stack.

Parameters:
  • sequencer (Sequencer) – The Sequencer object coordinating the current sequencing process.
  • parameters (Dict[str, Parameter]) – A mapping of parameter names to Parameter objects.
  • conditions (Dict[str, Condition]) – A mapping of condition identifiers to Condition
  • measurement_mapping (Dict[str, Optional[str]]) – A mapping of measurement window names. Windows that are mapped to None are omitted.
  • channel_mapping (Dict[Union[str, int], Union[str, int, None]]) – A mapping of channel names. Channels that are mapped to None are omitted.
  • instruction_block (InstructionBlock) – The instruction block into which instructions resulting from the translation of this SequencingElement will be placed.
Return type:

None

requires_stop(parameters, conditions)[source]

Return True if this SequencingElement cannot be translated yet.

Sequencer will check requires_stop() before calling build_sequence(). If requires_stop() returns True, Sequencer interrupts the current translation process and will not call build_sequence().

Implementation guide: requires_stop() should only return True, if this SequencingElement cannot be translated, i.e., the return value should only depend on the parameters/conditions of this SequencingElement, not on possible child elements. If this SequencingElement contains a child element which requires a stop, it should be pushed to the sequencing stack nonetheless. The requires_stop information of the child will be regarded during translation of that element.

Parameters:
  • parameters (Dict[str, Parameter]) – A mapping of parameter names to Parameter objects.
  • conditions (Dict[str, Condition]) – A mapping of condition identifiers to Condition objects.
Return type:

bool

Returns:

True, if this SequencingElement cannot be translated yet. False, otherwise.

class qupulse.pulses.sequencing.Sequencer[source]

Bases: object

Translates tree structures of SequencingElement objects to linear instruction sequences.

DEPRECATED (September 2018). This is outdated code. For obtaining pulses for execution from pulse templates, refer to PulseTemplate.create_program().

The concept of the sequencing process itself is described in detail in Section 1.4 of the documentation. Sequencer controls the process and invokes the translation functions of SequencingElements on the sequencing stack, which in turn implement the details of the translation of that specific SequencingElement.

Sequencer manages a main InstructionBlock into which all instructions are translated by default. Since additional InstructionBlocks may be created during the sequencing process due to looping and branching, Sequencer maintains several several sequencing stacks - one for each block - simultaneously and continues the translation until no stack holds objects that may be translated anymore before compiling the final sequence and interrupting or finishing the sequencing process.

See also

SequencingElement

Create a Sequencer.

StackElement = typing.Tuple[qupulse.pulses.sequencing.SequencingElement, typing.Dict[str, qupulse.pulses.parameters.Parameter], typing.Dict[str, ForwardRef('conditions.Condition')], typing.Dict[str, str]]
__init__()[source]

Create a Sequencer.

Return type:None
build()[source]

Start the translation process. Translate all elements currently on the translation stacks into an InstructionBlock hierarchy.

Processes all sequencing stacks (for each InstructionBlock) until each stack is either empty or its topmost element requires a stop. If build is called after a previous translation process where some elements required a stop (i.e., has_finished returned False), it will append new instructions to the previously generated and returned blocks.

Return type:ImmutableInstructionBlock
Returns:
The instruction block (hierarchy) resulting from the translation of the (remaining)
SequencingElements on the sequencing stacks.
has_finished()[source]

Check whether all translation stacks are empty. Indicates that the translation is complete.

Note that has_finished will return False, if there are stack elements that require a stop. In this case, calling build will only have an effect if these elements no longer require a stop, e.g. when required measurement results have been acquired since the last translation.

Return type:bool
Returns:Returns True, if all translation stacks are empty, i.e., the translation is complete.
push(sequencing_element, parameters=None, conditions=None, *, window_mapping=None, channel_mapping=None, target_block=None)[source]
Add an element to the translation stack of the target_block with the given set of
parameters.

The element will be on top of the stack, i.e., it is the first to be translated if no subsequent calls to push with the same target_block occur.

Parameters:
  • sequencing_element (SequencingElement) – The SequencingElement to push to the stack.
  • parameters (Dict(str -> (Parameter or float)) – A mapping of parameters names defined in the SequencingElement to Parameter objects or constant float values. In the latter case, the float values are encapsulated into ConstantParameter objects. Optional, if no conditions are defined by the SequencingElement. (default: None)
  • conditions (Dict(str -> Condition)) – A mapping of condition identifier defined by the SequencingElement to Condition objects. Optional, if no conditions are defined by the SequencingElement. (default: None)
  • window_mapping (Dict(str -> str)) – Mapping of the measurement window names of the sequence element
  • channel_mapping (Dict(ChannelID -> ChannelID)) – Mapping of the defined channels
  • target_block (InstructionBlock) – The instruction block into which instructions resulting from the translation of the SequencingElement will be placed. Optional. If not provided, the main instruction block will be targeted. (default: None)
Return type:

None

3.1.3.17. qupulse.pulses.table_pulse_template module

This module defines the TablePulseTemplate, one of the elementary pulse templates and its waveform representation.

Classes:
  • TablePulseTemplate: Defines a pulse via interpolation of a sequence of (time,voltage)-pairs.
  • TableWaveform: A waveform instantiated from a TablePulseTemplate by providing values for its
    declared parameters.
class qupulse.pulses.table_pulse_template.TablePulseTemplate(entries, identifier=None, *, parameter_constraints=None, measurements=None, consistency_check=True, registry=None)[source]

Bases: qupulse.pulses.pulse_template.AtomicPulseTemplate, qupulse.pulses.parameters.ParameterConstrainer

The TablePulseTemplate class implements pulses described by a table with time, voltage and interpolation strategy inputs. The interpolation strategy describes how the voltage between the entries is interpolated(see also InterpolationStrategy.) It can define multiple channels of which each has a separate table. If they do not have the same length the shorter channels are extended to the longest duration.

If the time entries of all channels are equal it is more convenient to use the :paramrefPointPulseTemplate`.

Construct a TablePulseTemplate from a dict which maps channels to their entries. By default the consistency of the provided entries is checked. There are two static functions for convenience construction: from_array and from_entry_list.

Parameters:
__init__(entries, identifier=None, *, parameter_constraints=None, measurements=None, consistency_check=True, registry=None)[source]

Construct a TablePulseTemplate from a dict which maps channels to their entries. By default the consistency of the provided entries is checked. There are two static functions for convenience construction: from_array and from_entry_list.

Parameters:
Return type:

None

build_waveform(parameters, channel_mapping)[source]

Implements build_waveform().

Return type:Union[TableWaveform, MultiChannelWaveform, None]
calculate_duration()[source]
Return type:ExpressionScalar
defined_channels

Implements defined_channels.

Return type:Set[Union[str, int]]
duration

Implements duration.

Return type:ExpressionScalar
entries
Return type:Dict[Union[str, int], List[TableEntry]]
static from_array(times, voltages, channels)[source]

Static constructor to build a TablePulse from numpy arrays.

Parameters:
  • times (ndarray) – 1D numpy array with time values
  • voltages (ndarray) – 1D or 2D numpy array with voltage values
  • channels (List[Union[str, int]]) – channels to define
Return type:

TablePulseTemplate

Returns:

TablePulseTemplate with the given values, hold interpolation everywhere and no free parameters.

static from_entry_list(entry_list, channel_names=None, **kwargs)[source]

Static constructor for a TablePulseTemplate where all channel’s entries share the same times.

Parameters:
  • entry_list (List[Tuple]) – List of tuples of the form (t, v_1, …, v_N[, interp])
  • channel_names (Optional[List[Union[str, int]]]) – Optional list of channel identifiers to use. Default is [0, …, N-1]
  • kwargs – Forwarded to TablePulseTemplate constructor
Return type:

TablePulseTemplate

Returns:

TablePulseTemplate with

get_entries_instantiated(parameters)[source]

Compute an instantiated list of the table’s entries.

Parameters:parameters (Dict(str -> Parameter)) – A mapping of parameter names to Parameter objects.
Return type:Dict[Union[str, int], List[TableWaveformEntry]]
Returns:
(float, float)-list of all table entries with concrete values provided by the given
parameters.
get_serialization_data(serializer=None)[source]

Returns all data relevant for serialization as a dictionary containing only base types.

Implementation hint: In the old serialization routines, if the Serializable contains complex objects which are itself Serializables, a serialized representation for these MUST be obtained by calling the dictify() method of serializer. The reason is that serializer may decide to either return a dictionary to embed or only a reference to the Serializable subelement. This is DEPRECATED behavior as of May 2018. In the new routines, this will happen automatically and every Serializable is only responsible for returning it’s own data and leave nested Serializables in object form.

For the transition time where both implementations are available, implementations of this method should support the old and new routines, using the presence of the serializer argument to differentiate between both. Don’t make use of the implementation in this base class when implementing this method for the old routines.

Parameters:serializer (Serializer) – DEPRECATED (May 2018).A Serializer instance used to serialize complex subelements of this Serializable.
Return type:Dict[str, Any]
Returns:
A dictionary of Python base types (strings, integers, lists/tuples containing these,
etc..) which fully represent the relevant properties of this Serializable for storing and later reconstruction as a Python object.
integral

Implements integral.

Return type:Dict[Union[str, int], ExpressionScalar]
interpolation_strategies = {'default': <Hold Interpolation>, 'hold': <Hold Interpolation>, 'jump': <Jump Interpolation>, 'linear': <Linear Interpolation>}
is_interruptable

Implements is_interruptable.

Return type:bool
parameter_names

Implements parameter_names.

Return type:Set[str]
requires_stop(parameters, conditions)[source]

Implements requires_stop().

Return type:bool
table_parameters
Return type:Set[str]
qupulse.pulses.table_pulse_template.concatenate(*table_pulse_templates, **kwargs)[source]

Concatenate two or more table pulse templates

Return type:TablePulseTemplate