qat.purr.compiler.builders module

class Axis(value)

Bases: Enum

An enumeration.

X = 1
Y = 2
Z = 3
class FluidBuilderWrapper(*args, **kwargs)

Bases: tuple

Wrapper to allow builders to return a tuple of values while also allowing fluid API consumption if those values are not required. Think of it like optional return values that don’t require unpacking to discard.

Examples of the two ways you should be able to call a builder when using this class.

builder = ...
    .builder_method()
    .wrapped_value_returned()
    .builder_method()

    builder, value = ...
        .builder_method()
        .wrapped_value_returned()

    builder.builder_method(value)
        .builder_method()
class InstructionBuilder(hardware_model, instructions=None)

Bases: object

Base instruction builder class that leaves unimplemented the methods that vary on a hardware-by-hardware basis.

ECR(control, target)
S(target)
SX(target)
SXdg(target)
Sdg(target)
T(target)
Tdg(target)
U(target, theta, phi, lamb)
X(target, radii=None)
Y(target, radii=None)
Z(target, radii=None)
acquire(*args, **kwargs)
add(components)

Adds an instruction to this builder. All methods should use this instead of accessing the instructions list directly as it deals with nested builders and merging.

assign(name, value)
cX(controllers, target, radii=None)
cY(controllers, target, radii=None)
cZ(controllers, target, radii=None)
ccnot(controllers, target_qubit)
clear()

Resets builder internal state for building a new set of instructions.

cnot(control, target_qubit)
controlled(controllers, builder)
create_label(name=None)

Creates and returns a label. Generates a non-clashing name if none is provided.

cswap(controllers, target, destination)
delay(target, time)
static deserialize(blob)
Return type:

InstructionBuilder

device_assign(target, attribute, value)

Special node that allows manipulation of device attributes during execution.

get_child_builder(inherit=False)
had(qubit)
insert(components, index)

Inserts one or more instruction(s) into this builder, starting at index. All methods should use this instead of accessing the instructions list directly as it deals with nested builders and merging.

property instructions
jump(label, condition=None)
measure(target, axis=None, output_variable=None)
Return type:

InstructionBuilder

measure_mean_signal(target, output_variable=None)
measure_mean_z(target, axis=None, output_variable=None)
measure_single_shot_signal(target, axis=None, output_variable=None)
measure_single_shot_z(target, axis=None, output_variable=None)
merge_builder(other_builder, index=None)

Merge this builder into the current instance. Checks for label name clashes and resolves them if any are found.

Parameters:

index (int) – index of self at which to insert the instructions of other_builder.

Returns:

the next index to use for additional inserts.

Return type:

int

phase_shift(target, phase)
post_processing(acq, process, axes=None, target=None, args=None)
pulse(*args, **kwargs)
repeat(repeat_value, repetition_period=None)
reset(qubits)
results_processing(variable, res_format)
returns(variables=None)

Add return statement.

serialize()

Currently only serializes the instructions, not the supporting objects of the builder itself. This could be supported pretty easily, but not required right now.

splice()

Clears the builder and returns its current instructions.

swap(target, destination)
sweep(variables_and_values)
synchronize(targets)
class QuantumInstructionBuilder(hardware_model, instructions=None)

Bases: InstructionBuilder

ECR(control, target)
U(target, theta, phi, lamb)
X(target, radii=None)
Y(target, radii=None)
Z(target, radii=None)
acquire(channel, *args, delay=None, **kwargs)
cnot(controlled_qubit, target_qubit)
delay(target, time)
frequency_shift(target, frequency)
get_child_builder(inherit=False)
measure(qubit, axis=None, output_variable=None, **kwargs)

Adds a measure instruction. Important note: this only adds the instruction, not any post-processing instructions as well. If you’re wanting to perform generic common operations use the more specific measurement types, as they add all the additional information.

Return type:

QuantumInstructionBuilder

measure_mean_signal(target, output_variable=None)
measure_mean_z(target, axis=None, output_variable=None)
measure_scope_mode(target, output_variable=None)
measure_single_shot_binned(target, axis=None, output_variable=None)
measure_single_shot_signal(target, axis=None, output_variable=None)
measure_single_shot_z(target, axis=None, output_variable=None)
phase_shift(target, phase)
post_processing(acq, process, axes=None, qubit=None, args=None)
pulse(*args, **kwargs)
sweep(variables_and_values)
synchronize(targets)