3.1.2. qctoolkit.pulses package

3.1.2.1. Submodules

3.1.2.2. qctoolkit.pulses.branch_pulse_template module

3.1.2.3. qctoolkit.pulses.conditions module

class qctoolkit.pulses.conditions.Condition(*args, **kwargs) → None[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: qctoolkit.pulses.sequencing.SequencingElement, if_branch: qctoolkit.pulses.sequencing.SequencingElement, else_branch: qctoolkit.pulses.sequencing.SequencingElement, sequencer: qctoolkit.pulses.sequencing.Sequencer, parameters: typing.Dict[str, qctoolkit.pulses.parameters.Parameter], conditions: typing.Dict[str, typing.Condition], instruction_block: qctoolkit.pulses.instructions.InstructionBlock) → None[source]

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

delegator refers to the SequencingElement which has delegated the invocation of build_sequence to this Condition object. if_branch and else_branch are the elements to be translated into if and else branch instructions. See also SequencingElement.build_sequence().

build_sequence_loop(delegator: qctoolkit.pulses.sequencing.SequencingElement, body: qctoolkit.pulses.sequencing.SequencingElement, sequencer: qctoolkit.pulses.sequencing.Sequencer, parameters: typing.Dict[str, qctoolkit.pulses.parameters.Parameter], conditions: typing.Dict[str, typing.Condition], instruction_block: qctoolkit.pulses.instructions.InstructionBlock) → None[source]

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

delegator refers to the SequencingElement which has delegated the invocation of build_sequence to this Condition object. body is the loop body element. See also SequencingElement.build_sequence().

requires_stop() → bool[source]

Return True if evaluating this Condition is not possible in the current translation process.

exception qctoolkit.pulses.conditions.ConditionEvaluationException[source]

Bases: Exception

Indicates that a SoftwareCondition cannot be evaluated yet.

class qctoolkit.pulses.conditions.SoftwareCondition(evaluation_callback: typing.Callable[[int], typing.Union[bool, NoneType]]) → None[source]

Bases: qctoolkit.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.

build_sequence_branch(delegator: qctoolkit.pulses.sequencing.SequencingElement, if_branch: qctoolkit.pulses.sequencing.SequencingElement, else_branch: qctoolkit.pulses.sequencing.SequencingElement, sequencer: qctoolkit.pulses.sequencing.Sequencer, parameters: typing.Dict[str, qctoolkit.pulses.parameters.Parameter], conditions: typing.Dict[str, typing.Condition], instruction_block: qctoolkit.pulses.instructions.InstructionBlock) → None[source]
build_sequence_loop(delegator: qctoolkit.pulses.sequencing.SequencingElement, body: qctoolkit.pulses.sequencing.SequencingElement, sequencer: qctoolkit.pulses.sequencing.Sequencer, parameters: typing.Dict[str, qctoolkit.pulses.parameters.Parameter], conditions: typing.Dict[str, typing.Condition], instruction_block: qctoolkit.pulses.instructions.InstructionBlock) → None[source]
requires_stop() → bool[source]
class qctoolkit.pulses.conditions.HardwareCondition(trigger: qctoolkit.pulses.instructions.Trigger) → None[source]

Bases: qctoolkit.pulses.conditions.Condition

A condition that will be evaluated using hardware triggers.

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

build_sequence_branch(delegator: qctoolkit.pulses.sequencing.SequencingElement, if_branch: qctoolkit.pulses.sequencing.SequencingElement, else_branch: qctoolkit.pulses.sequencing.SequencingElement, sequencer: qctoolkit.pulses.sequencing.Sequencer, parameters: typing.Dict[str, qctoolkit.pulses.parameters.Parameter], conditions: typing.Dict[str, typing.Condition], instruction_block: qctoolkit.pulses.instructions.InstructionBlock) → None[source]
build_sequence_loop(delegator: qctoolkit.pulses.sequencing.SequencingElement, body: qctoolkit.pulses.sequencing.SequencingElement, sequencer: qctoolkit.pulses.sequencing.Sequencer, parameters: typing.Dict[str, qctoolkit.pulses.parameters.Parameter], conditions: typing.Dict[str, typing.Condition], instruction_block: qctoolkit.pulses.instructions.InstructionBlock) → None[source]
requires_stop() → bool[source]

3.1.2.4. qctoolkit.pulses.function_pulse_template module

class qctoolkit.pulses.function_pulse_template.FunctionPulseTemplate(expression: str, duration_expression: str, measurement: bool = False, identifier: str = None) → None[source]

Bases: qctoolkit.pulses.pulse_template.PulseTemplate

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 external parameters are derived from the expressions themselves. Like other PulseTemplates the FunctionPulseTemplate can be declared to be a measurement pulse.

The independent variable in the expression is called ‘t’ and is given in units of nano-seconds.

build_sequence(sequencer: qctoolkit.pulses.sequencing.Sequencer, parameters: typing.Dict[str, qctoolkit.pulses.parameters.Parameter], conditions: typing.Dict[str, typing.Condition], instruction_block: qctoolkit.pulses.instructions.InstructionBlock) → None[source]
static deserialize()[source]
get_measurement_windows(parameters: typing.Union[typing.Dict[str, qctoolkit.pulses.parameters.Parameter], NoneType] = {}) → typing.List[typing.Tuple[float, float]][source]

Return all measurement windows defined in this PulseTemplate.

A ExpressionPulseTemplate specifies either no measurement windows or exactly one that spans its entire duration, depending on whether the measurement_pulse flag was given during construction.

get_pulse_length(parameters: typing.Dict[str, qctoolkit.pulses.parameters.Parameter]) → float[source]

Return the length of this pulse for the given parameters.

get_serialization_data(serializer: qctoolkit.serialization.Serializer) → None[source]
is_interruptable

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

parameter_declarations

Return a set of all parameter declaration objects of this TablePulseTemplate.

parameter_names

Return the set of names of declared parameters.

requires_stop(parameters: typing.Dict[str, qctoolkit.pulses.parameters.Parameter], conditions: typing.Dict[str, typing.Condition]) → bool[source]
class qctoolkit.pulses.function_pulse_template.FunctionWaveform(parameters: typing.Dict[str, float], expression: qctoolkit.expressions.Expression, duration_expression: qctoolkit.expressions.Expression) → None[source]

Bases: qctoolkit.pulses.instructions.Waveform

duration
sample(sample_times: numpy.ndarray, first_offset: float = 0) → numpy.ndarray[source]

3.1.2.5. qctoolkit.pulses.instructions module

qctoolkit.pulses.instructions.WaveformTable

alias of Tuple

class qctoolkit.pulses.instructions.WaveformTableEntry(t, v, interp)

Bases: tuple

interp

Alias for field number 2

t

Alias for field number 0

v

Alias for field number 1

class qctoolkit.pulses.instructions.Waveform[source]

Bases: qctoolkit.comparable.Comparable

duration

Return the duration of the waveform in time units.

sample(sample_times: numpy.ndarray, first_offset: float = 0) → numpy.ndarray[source]

Sample the waveform.

Will be sampled at the given sample_times. These, however, will be normalized such that the lie in the range [0, waveform.duration] for interpolation. first_offset is the offset of the discrete first sample from the actual beginning of the waveform in a continuous time domain.

class qctoolkit.pulses.instructions.Trigger → None[source]

Bases: qctoolkit.comparable.Comparable

class qctoolkit.pulses.instructions.InstructionPointer(block: qctoolkit.pulses.instructions.InstructionBlock, offset: int) → None[source]

Bases: object

get_absolute_address() → int[source]
class qctoolkit.pulses.instructions.Instruction → None[source]

Bases: qctoolkit.comparable.Comparable

class qctoolkit.pulses.instructions.CJMPInstruction(trigger: qctoolkit.pulses.instructions.Trigger, block: qctoolkit.pulses.instructions.InstructionBlock, offset: int = 0) → None[source]

Bases: qctoolkit.pulses.instructions.Instruction

class qctoolkit.pulses.instructions.EXECInstruction(waveform: qctoolkit.pulses.instructions.Waveform) → None[source]

Bases: qctoolkit.pulses.instructions.Instruction

class qctoolkit.pulses.instructions.GOTOInstruction(block: qctoolkit.pulses.instructions.InstructionBlock, offset: int = 0) → None[source]

Bases: qctoolkit.pulses.instructions.Instruction

class qctoolkit.pulses.instructions.STOPInstruction → None[source]

Bases: qctoolkit.pulses.instructions.Instruction

class qctoolkit.pulses.instructions.InstructionBlock(outer_block: typing.Union[qctoolkit.pulses.instructions.InstructionBlock, NoneType] = None) → None[source]

Bases: object

add_instruction(instruction: qctoolkit.pulses.instructions.Instruction) → None[source]
add_instruction_cjmp(trigger: qctoolkit.pulses.instructions.Trigger, target_block: qctoolkit.pulses.instructions.InstructionBlock, offset: int = 0) → None[source]
add_instruction_exec(waveform: qctoolkit.pulses.instructions.Waveform) → None[source]
add_instruction_goto(target_block: qctoolkit.pulses.instructions.InstructionBlock, offset: int = 0) → None[source]
add_instruction_stop() → None[source]
compile_sequence() → typing.List[qctoolkit.pulses.instructions.Instruction][source]
create_embedded_block() → qctoolkit.pulses.instructions.InstructionBlock[source]
get_start_address() → int[source]
instructions
qctoolkit.pulses.instructions.InstructionSequence

alias of List

exception qctoolkit.pulses.instructions.InstructionBlockNotYetPlacedException[source]

Bases: Exception

Indicates that an attempt was made to obtain the start address of an InstructionBlock that was not yet placed inside the corresponding outer block.

exception qctoolkit.pulses.instructions.InstructionBlockAlreadyFinalizedException[source]

Bases: Exception

Indicates that an attempt was made to change an already finalized InstructionBlock.

exception qctoolkit.pulses.instructions.MissingReturnAddressException[source]

Bases: Exception

Indicates that an inner InstructionBlock has no return address.

3.1.2.6. qctoolkit.pulses.interpolation module

class qctoolkit.pulses.interpolation.InterpolationStrategy[source]

Bases: object

class qctoolkit.pulses.interpolation.HoldInterpolationStrategy[source]

Bases: qctoolkit.pulses.interpolation.InterpolationStrategy

Holds previous value and jumps to the current value at the last sample.

class qctoolkit.pulses.interpolation.JumpInterpolationStrategy[source]

Bases: qctoolkit.pulses.interpolation.InterpolationStrategy

Jumps to the current value at the first sample and holds.

class qctoolkit.pulses.interpolation.LinearInterpolationStrategy[source]

Bases: qctoolkit.pulses.interpolation.InterpolationStrategy

Interpolates linearly.

3.1.2.7. qctoolkit.pulses.loop_pulse_template module

class qctoolkit.pulses.loop_pulse_template.LoopPulseTemplate(condition: str, body: qctoolkit.pulses.pulse_template.PulseTemplate, identifier: typing.Union[str, NoneType] = None) → None[source]

Bases: qctoolkit.pulses.pulse_template.PulseTemplate

Conditional looping in a pulse.

A LoopPulseTemplate is a PulseTemplate which is repeated during execution as long as a certain condition holds.

body
build_sequence(sequencer: qctoolkit.pulses.sequencing.Sequencer, parameters: typing.Dict[str, qctoolkit.pulses.parameters.Parameter], conditions: typing.Dict[str, qctoolkit.pulses.conditions.Condition], instruction_block: qctoolkit.pulses.instructions.InstructionBlock) → None[source]
condition
static deserialize(serializer: qctoolkit.serialization.Serializer, condition: str, body: typing.Dict[str, typing.Any], identifier: typing.Union[str, NoneType] = None) → qctoolkit.pulses.loop_pulse_template.LoopPulseTemplate[source]
get_measurement_windows(parameters: typing.Dict[str, qctoolkit.pulses.parameters.Parameter] = None) → typing.Tuple[float, float][source]
get_serialization_data(serializer: qctoolkit.serialization.Serializer) → typing.Dict[str, typing.Any][source]
is_interruptable
parameter_declarations
parameter_names
requires_stop(parameters: typing.Dict[str, qctoolkit.pulses.parameters.Parameter], conditions: typing.Dict[str, qctoolkit.pulses.conditions.Condition]) → bool[source]
exception qctoolkit.pulses.loop_pulse_template.ConditionMissingException(condition_name: str) → None[source]

Bases: Exception

3.1.2.8. qctoolkit.pulses.parameters module

class qctoolkit.pulses.parameters.Parameter → None[source]

Bases: qctoolkit.serialization.Serializable

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() → float[source]

Compute and return the parameter value.

requires_stop

Return True if the evaluation of this Parameter instance requires a stop in execution/sequencing, e.g., because it depends on data that is only measured in during the next execution.

class qctoolkit.pulses.parameters.ParameterDeclaration(name: str, min: typing.Union[float, typing.ParameterDeclaration] = -inf, max: typing.Union[float, typing.ParameterDeclaration] = inf, default: typing.Union[float, NoneType] = None) → None[source]

Bases: qctoolkit.serialization.Serializable

A declaration of a parameter required by a pulse template.

PulseTemplates may declare parameters to allow for variations of values in an otherwise static pulse structure. ParameterDeclaration represents a declaration of such a parameter and allows for the definition of boundaries and a default value for a parameter.

BoundaryValue

alias of Union

absolute_max_value

Return this ParameterDeclaration’s maximum value.

If the maximum value of this ParameterDeclaration instance is a reference to another instance, references are resolved until a concrete value or None is obtained.

absolute_min_value

Return this ParameterDeclaration’s minimum value.

If the minimum value of this ParameterDeclaration instance is a reference to another instance, references are resolved until a concrete value or None is obtained.

default_value

Return this ParameterDeclaration’s default value.

static deserialize(serializer: qctoolkit.serialization.Serializer, name: str, min_value: typing.Union[str, float], max_value: typing.Union[str, float], default_value: float) → qctoolkit.pulses.parameters.ParameterDeclaration[source]
get_serialization_data(serializer: qctoolkit.serialization.Serializer) → typing.Dict[str, typing.Any][source]
get_value(parameters: typing.Dict[str, qctoolkit.pulses.parameters.Parameter]) → float[source]
is_parameter_valid(p: qctoolkit.pulses.parameters.Parameter) → bool[source]

Checks whether a given parameter satisfies this ParameterDeclaration.

A parameter is valid if all of the following statements hold: - If the declaration specifies a minimum value, the parameter’s value must be greater or equal - If the declaration specifies a maximum value, the parameter’s value must be less or equal

max_value

Return this ParameterDeclaration’s maximum value or reference.

min_value

Return this ParameterDeclaration’s minimum value or reference.

name
class qctoolkit.pulses.parameters.ConstantParameter(value: float) → None[source]

Bases: qctoolkit.pulses.parameters.Parameter

A pulse parameter with a constant value.

static deserialize(serializer: qctoolkit.serialization.Serializer, constant: float) → qctoolkit.pulses.parameters.ConstantParameter[source]
get_serialization_data(serializer: qctoolkit.serialization.Serializer) → typing.Dict[str, typing.Any][source]
get_value() → float[source]
requires_stop
exception qctoolkit.pulses.parameters.ParameterNotProvidedException(parameter_name: str) → None[source]

Bases: Exception

Indicates that a required parameter value was not provided.

exception qctoolkit.pulses.parameters.ParameterValueIllegalException(parameter_declaration: qctoolkit.pulses.parameters.ParameterDeclaration, parameter_value: float) → None[source]

Bases: Exception

Indicates that the value provided for a parameter is illegal, i.e., is outside the parameter’s bounds or of wrong type.

3.1.2.9. qctoolkit.pulses.plotting module

3.1.2.10. qctoolkit.pulses.pulse_template module

qctoolkit.pulses.pulse_template.MeasurementWindow

alias of Tuple

class qctoolkit.pulses.pulse_template.PulseTemplate(identifier: typing.Union[str, NoneType] = None) → None[source]

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

A PulseTemplate represents the parameterized 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.

get_measurement_windows(parameters: typing.Dict[str, qctoolkit.pulses.parameters.Parameter] = None) → typing.List[typing.Tuple[float, float]][source]

Return all measurement windows defined in this PulseTemplate.

is_interruptable

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

parameter_declarations

Return the set of ParameterDeclarations.

parameter_names

Return the set of names of declared parameters.

3.1.2.11. qctoolkit.pulses.repetition_pulse_template module

3.1.2.12. qctoolkit.pulses.sequence_pulse_template module

class qctoolkit.pulses.sequence_pulse_template.SequencePulseTemplate(subtemplates: typing.List[typing.Tuple[qctoolkit.pulses.pulse_template.PulseTemplate, typing.Dict[str, str]]], external_parameters: typing.List[str], identifier: typing.Union[str, NoneType] = None) → None[source]

Bases: qctoolkit.pulses.pulse_template.PulseTemplate

A sequence of different PulseTemplates.

SequencePulseTemplate allows to group smaller PulseTemplates (subtemplates) into on 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 allows to specify a mapping of parameter declarations from its subtemplates, enabling renaming and mathematical transformation of parameters. The default behavior is to exhibit the union of parameter declarations of all subtemplates. If two subpulses declare a parameter with the same name, it is mapped to both. If the declarations define different minimal and maximal values, the more restricitive is chosen, if possible. Otherwise, an error is thrown and an explicit mapping must be specified. ^outdated

build_sequence(sequencer: qctoolkit.pulses.sequencing.Sequencer, parameters: typing.Dict[str, qctoolkit.pulses.parameters.Parameter], conditions: typing.Dict[str, qctoolkit.pulses.conditions.Condition], instruction_block: qctoolkit.pulses.instructions.InstructionBlock) → None[source]
static deserialize(serializer: qctoolkit.serialization.Serializer, is_interruptable: bool, subtemplates: typing.Iterable[typing.Dict[str, typing.Union[str, typing.Dict[str, typing.Any]]]], external_parameters: typing.Iterable[str], identifier: typing.Union[str, NoneType] = None) → qctoolkit.pulses.sequence_pulse_template.SequencePulseTemplate[source]
get_measurement_windows(parameters: typing.Dict[str, qctoolkit.pulses.parameters.Parameter] = None) → typing.List[typing.Tuple[float, float]][source]
get_serialization_data(serializer: qctoolkit.serialization.Serializer) → typing.Dict[str, typing.Any][source]
is_interruptable
parameter_declarations
parameter_names
requires_stop(parameters: typing.Dict[str, qctoolkit.pulses.parameters.Parameter], conditions: typing.Dict[str, typing.Condition]) → bool[source]
exception qctoolkit.pulses.sequence_pulse_template.MissingMappingException(template, key) → None[source]

Bases: Exception

exception qctoolkit.pulses.sequence_pulse_template.MissingParameterDeclarationException(template: qctoolkit.pulses.pulse_template.PulseTemplate, missing_delcaration: str) → None[source]

Bases: Exception

exception qctoolkit.pulses.sequence_pulse_template.UnnecessaryMappingException(template: qctoolkit.pulses.pulse_template.PulseTemplate, key: str) → None[source]

Bases: Exception

3.1.2.13. qctoolkit.pulses.sequencing module

class qctoolkit.pulses.sequencing.SequencingElement → None[source]

Bases: object

An entity which can be sequenced using Sequencer.

build_sequence(sequencer: qctoolkit.pulses.sequencing.Sequencer, parameters: typing.Dict[str, qctoolkit.pulses.parameters.Parameter], conditions: typing.Dict[str, typing.Condition], instruction_block: qctoolkit.pulses.instructions.InstructionBlock) → None[source]

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

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

requires_stop(parameters: typing.Dict[str, qctoolkit.pulses.parameters.Parameter], conditions: typing.Dict[str, typing.Condition]) → bool[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 build, 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, this information will be regarded during translation of that element.

class qctoolkit.pulses.sequencing.Sequencer → None[source]

Bases: object

Translates tree structures of SequencingElement objects to linear instruction sequences contained in a InstructionBlock.

StackElement

alias of Tuple

build() → qctoolkit.pulses.instructions.InstructionBlock[source]
Start the translation process. Translate all elements currently on the translation stacks into a sequence
and return the InstructionBlock of the main sequence.

Processes all 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 modify the previously generated and returned main InstructionBlock. Make sure not to rely on that being unchanged.

has_finished() → bool[source]

Returns True, if all translation stacks are empty. Indicates that the translation is complete.

Note that has_finished 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.

push(sequencing_element: qctoolkit.pulses.sequencing.SequencingElement, parameters: typing.Dict[str, typing.Union[qctoolkit.pulses.parameters.Parameter, float]] = {}, conditions: typing.Dict[str, typing.Condition] = {}, target_block: qctoolkit.pulses.instructions.InstructionBlock = None) → 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.

3.1.2.14. qctoolkit.pulses.table_pulse_template module

3.1.2.15. Module contents