fiqci.ems.transpiler_passes.zne_circuits#
Classes
|
A |
|
A pass to generate circuits for zero-noise extrapolation (ZNE) by folding gates. |
- class SelfInverseMoveGate(label: str | None = None)#
Bases:
MoveGateA
MoveGatethat reports itself as its own inverse.MoveGateis deliberately left without a definition so the transpiler cannot decompose it, which also makesinverse()raise. Folding needs an inverse, and MOVE is an involution on its invariant subspace: its off-diagonal entries are an undefined phase and that phase’s reciprocal, soMOVE MOVEis the identity whatever the phase happens to be. Subclassing keeps the gate’s name and type, so IQM serialisation and MOVE-sandwich validation see an ordinary MOVE.- inverse(annotated: bool = False) SelfInverseMoveGate#
Invert this instruction.
If annotated is False, the inverse instruction is implemented as a fresh instruction with the recursively inverted definition.
If annotated is True, the inverse instruction is implemented as
AnnotatedOperation, and corresponds to the given instruction annotated with the “inverse modifier”.Special instructions inheriting from Instruction can implement their own inverse (e.g. T and Tdg, Barrier, etc.) In particular, they can choose how to handle the argument
annotatedwhich may include ignoring it and always returning a concrete gate class if the inverse is defined as a standard gate.- Parameters:
annotated – if set to True the output inverse gate will be returned as
AnnotatedOperation.- Returns:
The inverse operation.
- Raises:
CircuitError – if the instruction is not composite and an inverse has not been implemented for it.
- class ZNECircuits(*args, **kwargs)#
Bases:
TransformationPassA pass to generate circuits for zero-noise extrapolation (ZNE) by folding gates.
- __init__(fold_gates: Iterable[str] | None = None, scale_factor: float = 1, folding_method: str = 'local', seed=None)#
Initialize the ZNECircuits pass.
- Parameters:
fold_gates – An optional iterable of gate names to fold. If None, every two-qubit gate is folded except MOVE, which is only folded when named explicitly. Ignored by global folding, which folds the whole circuit including MOVE.
scale_factor – The factor by which to scale the noise. Any real number >= 1. Non-odd-integer values are approximated by partially folding a randomly-sampled subset of gates.
folding_method – The method to use for folding gates (“local” or “global”).
seed – Seed or numpy Generator for the random gate sampling used to approximate non-odd-integer scale factors. Passing an existing Generator shares its state (and is returned unchanged by
np.random.default_rng), so a single Generator can drive many passes reproducibly.
- run(dag: DAGCircuit) DAGCircuit#
Run the ZNECircuits pass on the given DAGCircuit.
- Parameters:
dag – The input DAGCircuit to transform.
- Returns:
A new DAGCircuit with folded gates for ZNE.