AddTags

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

Bases: TransformationPass

Inserts Tag annotations to all box instructions.

This pass finds all box nodes in the DAG and adds Tag annotations to them. The tagging mode controls how ref strings are assigned:

  • 'unique_box': the ref is a truncated hash of the box’s structural content (i.e. ignoring single-qubit gate, and see BoxKey), so structurally equivalent boxes share the same ref across circuits. Boxes with different Twirl specifications are treated as unique, but all other annotations are ignored when comparing boxes.

  • 'unique_instance': the ref is an incrementing counter (t0, t1, …), so every box in a circuit gets a unique ref. The counter resets on each call to run().

  • 'noise_ref': the ref is taken from the box’s InjectNoise annotation’s ref field joined by an underscore with its modifier_ref field when present. Boxes without an InjectNoise annotation are skipped.

Parameters:
  • mode – The tagging mode. 'unique_box' assigns the same ref to structurally equivalent boxes; 'unique_instance' assigns a unique ref to every box.

  • overwrite – Whether to overwrite Tag annotations that are already present in the circuit.

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

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.