quri_parts.circuit.transpile.fuse module¶
- class AdjacentGateFuser(*args, **kwargs)¶
Bases:
CircuitTranspilerProtocol,ABCAbstract base class of adjacent gates fusing transpilers.
- abstract property target_gate_count: int¶
Returns the number of adjacent gates a single fuse() call consumes.
- abstract is_target_sequence(seq)¶
Determine if a given gate sequence is subject to fusing.
- Parameters:
seq (Sequence[QuantumGate])
- Return type:
bool
- abstract fuse(seq)¶
Fuse a target gate sequence into a replacement gate sequence.
- Parameters:
seq (Sequence[QuantumGate])
- Return type:
Sequence[QuantumGate]
- class CNOTHCNOTFusingTranspiler(*args, **kwargs)¶
Bases:
AdjacentGateFuserA CircuitTranspiler that reduces the number of CNOT gates by replacing partial circuits that satisfy certain conditions with equivalent circuits.
The number of Clifford gates (here H, S, Sdag) and the circuit depth will increase, but the number of CNOT gates will decrease, which is expected to help reduce the error rate of the circuit in typical NISQ devices.
- Ref:
Joshua Goings, et al., Molecular Symmetry in VQE: A Dual Approach for Trapped-Ion Simulations of Benzene, arXiv:2308.00667v1, pp.3-4, (2023).
- property target_gate_count: int¶
Returns the number of adjacent gates a single fuse() call consumes.
- is_target_sequence(seq)¶
Returns True if seq is a CNOT-H-CNOT sequence sharing a control/target qubit pair.
- Parameters:
seq (Sequence[QuantumGate])
- Return type:
bool
- fuse(seq)¶
Replace a CNOT-H-CNOT sequence with an equivalent, CNOT-count- reduced sequence.
- Parameters:
seq (Sequence[QuantumGate])
- Return type:
Sequence[QuantumGate]
- class FuseRotationTranspiler(*args, **kwargs)¶
Bases:
AdjacentGateFuserCircuitTranspiler, which fuses consecutive rotation gates of the same kind acting on the same qubit.
- property target_gate_count: int¶
Returns the number of adjacent gates a single fuse() call consumes.
- is_target_sequence(seq)¶
Returns True if seq is two consecutive rotation gates of the same kind on the same qubit.
- Parameters:
seq (Sequence[QuantumGate])
- Return type:
bool
- fuse(seq)¶
Combine two consecutive same-axis rotation gates into one.
- Parameters:
seq (Sequence[QuantumGate])
- Return type:
Sequence[QuantumGate]
- class NormalizeRotationTranspiler(cycle_range=(0.0, 12.566370614359172), epsilon=1e-09)¶
Bases:
GateKindDecomposerNormalize the parameters of the rotation gates (RX, RY, and RZ) so that they are in the specified range (0 to 4PI by default).
RX, RY, and RZ have period 4PI as matrices (e.g. RX(t) = exp(-i*t/2*X)), not 2PI: RX(t + 2*PI) = -RX(t). A cycle_range narrower than 4PI (e.g. the legacy default of width 2PI) therefore does not preserve the gate’s matrix exactly, only up to a global phase of -1. Use a range of width 4PI (the default) to preserve the exact matrix.
- Parameters:
cycle_range (tuple[float, float]) – Specify a range of width 4PI (or a multiple of 2PI, for
of (callers that only need equivalence up to global phase) in the form)
limit ((lower)
is (upper limit). Lower limit is inclusive and upper limit)
exclusive.
epsilon (float)
- property target_gate_names: Sequence[str]¶
Returns the set of gate names to be decomposed.
- decompose(gate)¶
Replace gate with an equivalent one whose angle is normalized into cycle_range.
- Parameters:
gate (QuantumGate)
- Return type:
Sequence[QuantumGate]
- class RX2NamedTranspiler(epsilon=1e-09)¶
Bases:
GateKindDecomposerConvert RX gate to Identity or X gate if it is equivalent to Identity, X, SqrtX, or SqrtXdag gate.
- Parameters:
epsilon (float)
- property target_gate_names: Sequence[str]¶
Returns the set of gate names to be decomposed.
- decompose(gate)¶
Replace gate with the named gate it matches (up to global phase), or leave it unchanged.
- Parameters:
gate (QuantumGate)
- Return type:
Sequence[QuantumGate]
- class RY2NamedTranspiler(epsilon=1e-09)¶
Bases:
GateKindDecomposerConvert RY gate to Identity or Y gate if it is equivalent to Identity, Y, SqrtY, or SqrtYdag gate.
- Parameters:
epsilon (float)
- property target_gate_names: Sequence[str]¶
Returns the set of gate names to be decomposed.
- decompose(gate)¶
Replace gate with the named gate it matches (up to global phase), or leave it unchanged.
- Parameters:
gate (QuantumGate)
- Return type:
Sequence[QuantumGate]
- class RZ2NamedTranspiler(epsilon=1e-09, allow_t_tdag=True)¶
Bases:
GateKindDecomposerConvert RZ gate to Identity, Z, S, Sdag, T, or Tdag gate if it is equivalent to a sequence of these gates.
- Parameters:
epsilon (float)
allow_t_tdag (bool)
- property target_gate_names: Sequence[str]¶
Returns the set of gate names to be decomposed.
- decompose(gate)¶
Replace gate with the named gate(s) it matches (up to global phase), or leave it unchanged.
- Parameters:
gate (QuantumGate)
- Return type:
Sequence[QuantumGate]
- class Rotation2NamedTranspiler(epsilon=1e-09)¶
Bases:
SequentialTranspilerConvert rotation gates (RX, RY, and RZ) to Identity, Z, S, Sdag, T, or Tdag gates if it is equivalent to a sequence of these gates.
- Parameters:
epsilon (float)
- class ZeroRotationEliminationTranspiler(epsilon=1e-09)¶
Bases:
GateKindDecomposerRemove rotation gates (RX, RY, and RZ) with rotation angles smaller than epsilon.
- Parameters:
epsilon (float)
- property target_gate_names: Sequence[str]¶
Returns the set of gate names to be decomposed.
- decompose(gate)¶
Drop gate if its angle is (equivalent to) zero, otherwise leave it unchanged.
- Parameters:
gate (QuantumGate)
- Return type:
Sequence[QuantumGate]