qat.pipelines.purr.sweep.flattener module
- class DeviceAssignSet(assigns)
Bases:
objectContains a set of device assignments to be applied to a builder.
- apply()
Temporarily applies the device assignments to the targets.
Warning
This will mutate the components of the hardware model, potentially invalidating any analysis already done on instantiation of pipelines. Futhermore, since this is used in conjuntion with sweeping, it is not thread safe. This is only intended to be used in the SweepPipeline, and should not be used elsewhere. It is recommended that this is used with a hardware model, or hardware model loader that is not shared with any other pipeline.
- class SweepFlattener(builder)
Bases:
objectExtracts sweeps and device assigns from a builder, and acts as a factory for creating a set of new builder that is free of sweeps and device assigns.
This can be used as an iterator to return a series of builders with the sweep values injected into the relevant instructions. This works by first extracting sweep instructions, and then locating all variables within instructions that match the sweep variable names. It only searches a single depth (e.g. within the top-level dictionary describing the instruction). This may be adjusted in the future if we need to perform a deeper search.
- Parameters:
builder¶ (
QuantumInstructionBuilder) – The instruction builder containing sweeps.
- create_flattened_builders()
Creates a list of builders with all combinations of sweep values injected.
Returns a list of instances of the builder, containing the variable values, the builder with the injected values, and the device assignments to be applied before compiling the builders (if any).
- Return type:
list[SweepInstance]
- class SweepInstance(variables, builder, device_assigns)
Bases:
objectContains a single instance of a sweep, with the variable names and values.
-
builder:
QuantumInstructionBuilder
-
device_assigns:
DeviceAssignSet
- property has_device_assigns: bool
-
variables:
dict[str,complex|float]
-
builder:
- class VariableAccessor(instruction_index, attribute, variable_name)
Bases:
objectContains the information needed to access a variable instance in an instruction builder.
-
attribute:
str
- classmethod create_accessors(instruction, index, names)
Creates a list of VariableAccessors for the given instruction, looking for variables with the given names.
- Return type:
list[VariableAccessor]
-
instruction_index:
int
-
variable_name:
str
-
attribute: