qat.middleend.passes.transform module
- class AcquireSanitisation
Bases:
TransformPass
Sanitises the
Acquire
instruction: the first per pulse channel is split into anAcquire
and aDelay
, and other acquisitions have their delay removed.Acquire
instructions are defined by a “duration” for which they instruct the target to readout. They also contain a “delay” attribute, which instructions the acquisition to start after some given time. This pass separates acqusitions with a delay into two instructions for the first acquire that acts on the channel. For multiple acquisitions on a single channel, the delay is not needed for the following acquisitions, and is set to zero.- run(ir, *args, **kwargs)
- Parameters:
ir¶ (
InstructionBuilder
) – The list of instructions stored in anInstructionBuilder
.- Return type:
- class EndOfTaskResetSanitisation
Bases:
TransformPass
Checks for a reset on each active qubit at the end of a task, and adds Reset operations if not found.
After each shot, it is expected that the qubit is returned to its ground state, ready for the next shot. This pass ensures this is the case by checking if the last “active” operation on an qubit is a
Reset
, and if not, adds aReset
to the end of the instruction list.Reset
instructions currently sit in a weird place. Their targets are drive channels to match the semantics of other quantum instructions (but are instantiated with a :class:Qubit). However, like measurements, resets are a qubit-level operation. You cannot reset the state of a pulse channel, the state is a property of the qubit! To avoid breaking changes, we’ll just deal with that for now, but hope to do better in the refactored instructions…- run(ir, res_mgr, *args, **kwargs)
- Parameters:
ir¶ (
InstructionBuilder
) – The list of instructions stored in anInstructionBuilder
.res_mgr¶ (
ResultManager
) – The result manager to store the analysis results.
- Return type:
- class InactivePulseChannelSanitisation
Bases:
TransformPass
Removes instructions that act on inactive pulse channels.
Many channels that aren’t actually needed to execute the program contain instructions, mainly
Synchronize
instructions andPhaseShift
instructions which can happen when either of the instructions are applied to qubits. To simplify analysis and optimisations in later passes, it makes sense to filter these out to reduce the overall instruction amount.Note
This pass requires results from the
ActivePulseChannelAnalysis
to be stored in the results manager.- run(ir, res_mgr, *args, **kwargs)
- Parameters:
ir¶ (
InstructionBuilder
) – The list of instructions stored in anInstructionBuilder
.res_mgr¶ (
ResultManager
) – The result manager to store the analysis results.
- Return type:
- class InitialPhaseResetSanitisation
Bases:
TransformPass
Checks if every active pulse channel has a phase reset in the beginning.
Warning
This pass implies that an ActiveChannelAnalysis is performed prior to this pass.
- run(ir, res_mgr, *args, **kwargs)
- class InstructionGranularitySanitisation(clock_cycle=8e-09)
Bases:
TransformPass
Rounds up the durations of quantum instructions so they are multiples of the clock cycle.
Only supports quantum instructions with static non-zero durations. Assumes that instructions with a non-zero duration only act on a single pulse channel. The santisiation is done for all instructions simultaneously using numpy for performance.
The Pydantic version of the pass will require the (pydantic equivalent) pass
ActivePulseChannelAnalysis
to have run, with results saved to the results manager to extract pulse channel information.Warning
This pass has the potential to invalidate the timings for sequences of instructions that are time-sensitive. For example, if a pulse has an invalid time, it will round it up to the nearest integer multiple. Furthemore, it will assume that
Acquire
instructions have no delay. This can be forced explicitly using theAcquireSanitisation
pass.- Parameters:
clock_cycle¶ (
float
) – The clock cycle to round to.
- run(ir, *args, **kwargs)
- Parameters:
ir¶ (
InstructionBuilder
) – The list of instructions stored in anInstructionBuilder
.- Return type:
- class InstructionLengthSanitisation(duration_limit=0.001)
Bases:
TransformPass
Checks if quantum instructions are too long and splits if necessary.
- Parameters:
duration_limit¶ (
float
) – The maximum allowed clock cycles per instruction.
Warning
The pass will assume that the durations of instructions are sanitised to the granularity of the pulse channels. If instructions that do not meet the criteria are provided, it might produce incorrect instructions (i.e., instructions that are shorter than the clock cycle). This can be enforced using the
InstructionGranularitySanitisation
pass.- run(ir, *args, **kwargs)
- Parameters:
ir¶ (
InstructionBuilder
) – The list of instructions stored in anInstructionBuilder
.
- class MeasurePhaseResetSanitisation
Bases:
TransformPass
Adds a phase reset before every measure pulse.
- run(ir, *args, **kwargs)
- class PhaseOptimisation
Bases:
TransformPass
Iterates through the list of instructions and compresses contiguous
PhaseShift
instructions.- 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.
- class PostProcessingSanitisation
Bases:
TransformPass
Checks that the
PostProcessing
instructions that follow an acquisition are suitable for the acquisition mode, and removes them if not.Extracted from
qat.purr.backends.live.LiveDeviceEngine.optimize()
.- run(ir, _, met_mgr, *args, **kwargs)
- Parameters:
ir¶ (
InstructionBuilder
) – The list of instructions stored in anInstructionBuilder
.met_mgr¶ (
MetricsManager
) – The metrics manager to store the number of instructions after optimisation.
- class PydPhaseOptimisation
Bases:
TransformPass
Iterates through the list of instructions and compresses contiguous
PhaseShift
instructions.- run(ir, res_mgr, met_mgr, *args, **kwargs)
- Parameters:
ir¶ (
QuantumInstructionBuilder
) – 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.
- class PydPostProcessingSanitisation
Bases:
TransformPass
Checks that the
PostProcessing
instructions that follow an acquisition are suitable for the acquisition mode, and removes them if not.Extracted from
qat.purr.backends.live.LiveDeviceEngine.optimize()
.- run(ir, _, met_mgr, *args, **kwargs)
- Parameters:
ir¶ (
QuantumInstructionBuilder
) – The list of instructions stored in anInstructionBuilder
.met_mgr¶ (
MetricsManager
) – The metrics manager to store the number of instructions after optimisation.
- class SynchronizeTask
Bases:
TransformPass
Synchronizes all active pulse channels in a task.
Adds a synchronize to the end of the instruction list for all active pulse channels, which is extracted from the
ActivePulseChannelAnalysis
pass. This is useful to do before resetting the qubits, as it ensures no qubit is reset while the task is still “active”, reducing the effects of cross-talk.- run(ir, res_mgr, *args, **kwargs)
- Parameters:
ir¶ (
InstructionBuilder
) – The list of instructions stored in anInstructionBuilder
.res_mgr¶ (
ResultManager
) – The result manager to store the analysis results.
- Return type: