Annotation
class qiskit.circuit.Annotation
Bases: object
An arbitrary annotation for instructions.
The annotation framework is a new and evolving component of Qiskit. We expect the functionality of this and its first-class support within the transpiler to expand as we get more evidence of how it is used.
This base class alone has very little prescribed behavior or semantics. The primary interaction is by user- or library subclassing. See Custom annotation subclasses for more detail.
This is a framework for structuring additional metadata that can be attached to BoxOp
instructions within a QuantumCircuit
and DAGCircuit
in ways that can be tracked and consumed by arbitrary transpiler passes, including custom passes that are not in Qiskit core.
While the stateful PropertySet
used during a compilation also supplies a way for custom transpiler passes to store arbitrary “state” objects into the compilation workflow that can be retrieved by later compiler passes, the PropertySet
is stored next to the circuit, and so is most suitable for analyses that relate to the circuit as a whole. An Annotation
is intended to be more local in scope, applying to a box of instructions, and further, may still be present in the output of transpile
, if it is intended for further consumption by a lower-level part of your backend’s execution machinery (for example, an annotation might include metadata instructing an error-mitigation routine to treat a particular box in a special way).
The PassManager
currently does not make any effort to track and validate pre-conditions on the validity of an Annotation
. That is, if you apply a custom annotation to a box of instructions that would be invalidated by certain transformations (such as routing, basis-gate decomposition, etc), it is currently up to you as the caller of transpile()
or generate_preset_pass_manager()
to ensure that the compiler passes selected will not invalidate the annotation. We expect to have more first-class support for annotations to declare their validity requirements in the future.
Attributes
namespace
Default value: ''