AddInjectNoise

class samplomatic.transpiler.passes.AddInjectNoise(*args, **kwargs)[source]

Bases: TransformationPass

Inserts InjectNoise annotations to all the unique boxes with twirling annotation.

This pass finds boxes matching the conditions implied by targets, adds inject noise to their annotations, and replaces them with new boxes with the updated annotations.

Parameters:
  • strategy – The noise injection strategy.

  • overwrite – Whether to overwrite the ref of inject noise annotations that are already present in the circuit.

  • prefix_ref – A prefix to all the ref generated by this class.

  • prefix_modifier_ref – A prefix to all the modifier_refs generated by this class.

  • targets

    The class of annotated boxes to target. The supported values are:

    • 'none' to avoid annotating boxes of any kind.

    • 'gates' to target only the twirl-annotated boxes that contain entanglers.

    • 'measures' to target only the twirl-annotated boxes that own classical

      registers.

    • 'all' to target all the twirl-annotated boxes that contain entanglers

      and/or own classical registers.

Note

Every ref is generated by appending a counter to prefix_ref. The counter is shared across all the instances of this class. In order to avoid collisions, it is incremented every time that a new ref is created. The same mechanism (with a different counter) is used to generate the modifier_refs.

Methods Summary

run(dag)

Run a pass on the DAGCircuit.

Methods Documentation

run(dag: DAGCircuit) DAGCircuit[source]

Run a pass on the DAGCircuit. This is implemented by the pass developer.

Parameters:

dag – the dag on which the pass is run.

Raises:

NotImplementedError – when this is left unimplemented for a pass.