qat.backend.passes.transform module
- class DesugaringPass
Bases:
TransformPass
Transforms syntactic sugars and implicit effects. Not that it applies here, but a classical example of a sugar syntax is the ternary expression
"cond ? val1 : val2"
which is nothing more than an if else in disguise.The goal of this pass is to desugar any syntactic and semantic sugars. One of these sugars is iteration constructs such as
Sweep
andRepeat
.- run(ir, res_mgr, *args, **kwargs)
- Parameters:
ir¶ (
InstructionBuilder
) – The list of instructions stored in anInstructionBuilder
.
- class FreqShiftSanitisation(model=None)
Bases:
TransformPass
Looks for any active frequency shift pulse channels in the hardware model and adds square pulses for the duration of the shot.
- run(ir, res_mgr, *args, **kwargs)
- class LowerSyncsToDelays
Bases:
TransformPass
Lowers
Synchronize
instructions toDelay
instructions with static times.Increments through the instruction list, keeping track of the cumulative duration. When
Synchronize
instructions are encountered, it is replaced withDelay
instructions with timings calculated from the cumulative durations.Warning
Any manipulations of the instruction set that will alter the timeline and occur after this pass could invalidate the intention of the
Synchronize
instruction.- run(ir, *args, **kwargs)
- Return type:
- class PydReturnSanitisation
Bases:
TransformPass
Squashes all
Return
instructions into a single one. Adds aReturn
with all acquisitions if none is found.- run(ir, *args, **kwargs)
- Parameters:
ir¶ (
QuantumInstructionBuilder
) – The list of instructions stored in anQuantumInstructionBuilder
.
- class RepeatSanitisation(model=None)
Bases:
TransformPass
Fixes repeat instructions if any with default values from the HW model. Adds a repeat instructions if none is found.
- run(ir, *args, **kwargs)
- Parameters:
ir¶ (
InstructionBuilder
) – The list of instructions stored in anInstructionBuilder
.
- class ReturnSanitisation
Bases:
TransformPass
Squashes all
Return
instructions into a single one. Adds aReturn
with all acquisitions if none is found.- run(ir, *args, **kwargs)
- Parameters:
ir¶ (
InstructionBuilder
) – The list of instructions stored in anInstructionBuilder
.
- class ScopeSanitisation
Bases:
TransformPass
Bubbles up all sweeps and repeats to the beginning of the list. Adds delimiter instructions to the repeats and sweeps signifying the end of their scopes.
Intended for legacy existing builders and the relative order of instructions guarantees backwards compatibility.
- run(ir, *args, **kwargs)
- Parameters:
ir¶ (
InstructionBuilder
) – The list of instructions stored in anInstructionBuilder
.
- class SquashDelaysOptimisation
Bases:
TransformPass
Looks for consecutive
Delay
instructions on a pulse channel and squashes them into a single instruction.Because
Synchronize
instructions across multiple pulse channels are used so frequently to ensure pulses play at the correct timings, it means we can have sequences of many delays. Reducing the number of delays will simplify timing analysis later in the compilation.Delay
instructions commute with phase related instructions, so the only instructions that separate delays in a meaningful way are:Pulse
:,CustomPulse
andAcquire
instructions. We also need to be careful to not squash delays that contain a variable time.- run(ir, res_mgr, met_mgr, *args, **kwargs)
- Parameters:
ir¶ (
InstructionBuilder
) – The list of instructions stored in anInstructionBuilder
.res_mgr¶ (
ResultManager
) – The result manager to save the analysis results.met_mgr¶ (
MetricsManager
) – The metrics manager to store the number of instructions after optimisation.