qat.purr.compiler.transform_passes module

class DeviceUpdateSanitisation

Bases: TransformPass

Duplicate DeviceUpdate instructions upsets the device injection mechanism, which causes corruption of the HW model.

In fact, a DeviceInjector is currently 1-1 associated with a DeviceUpdate instruction. When multiple DeviceUpdate instructions (sequentially) inject the same “target”, the first DeviceInjector assigns the (correct) value of the attribute (on the target) to the revert_value. At this point the HW model (or any other target kind) is dirty, and any subsequent DeviceInjector updater would surely assign the (wrong, usually a placeholder Variable) to its revert_value. This results in a corrupt HW model whereby reversion wouldn’t have the desired effect.

This pass is a (lazy) fix, which is to analyse when such cases happen and eliminate duplicate DeviceUpdate instructions that target THE SAME “attribute” on THE SAME “target” with THE SAME variable.

run(ir, res_mgr, met_mgr, *args, **kwargs)
class PhaseOptimisation

Bases: TransformPass

Extracted from QuantumExecutionEngine.optimize()

run(ir, res_mgr, met_mgr, *args, **kwargs)
class PostProcessingSanitisation

Bases: TransformPass

Extracted from LiveDeviceEngine.optimize() Better pass name/id ?

run(ir, res_mgr, met_mgr, *args, **kwargs)