quri_parts.circuit.transpile.fuse module#

class AdjacentGateFuser(*args, **kwargs)#

Bases: CircuitTranspilerProtocol, ABC

Abstract base class of adjacent gates fusing transpilers.

abstract property target_gate_count: int#
abstract is_target_sequence(seq)#
Parameters:

seq (Sequence[QuantumGate]) –

Return type:

bool

abstract fuse(seq)#
Parameters:

seq (Sequence[QuantumGate]) –

Return type:

Sequence[QuantumGate]

class CNOTHCNOTFusingTranspiler(*args, **kwargs)#

Bases: AdjacentGateFuser

A 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#
is_target_sequence(seq)#
Parameters:

seq (Sequence[QuantumGate]) –

Return type:

bool

fuse(seq)#
Parameters:

seq (Sequence[QuantumGate]) –

Return type:

Sequence[QuantumGate]

class FuseRotationTranspiler(*args, **kwargs)#

Bases: AdjacentGateFuser

CircuitTranspiler, which fuses consecutive rotation gates of the same kind acting on the same qubit.

property target_gate_count: int#
is_target_sequence(seq)#
Parameters:

seq (Sequence[QuantumGate]) –

Return type:

bool

fuse(seq)#
Parameters:

seq (Sequence[QuantumGate]) –

Return type:

Sequence[QuantumGate]

class NormalizeRotationTranspiler(cycle_range=(0.0, 6.283185307179586), epsilon=1e-09)#

Bases: GateKindDecomposer

Normalize the parameters of the rotation gates (RX, RY, and RZ) so that they are in the specified range (0 to 2PI by default).

Parameters:
  • cycle_range (tuple[float, float]) – Specify a range of width 2PI in the form of (lower limit,

  • exclusive. (upper limit). Lower limit is inclusive and upper limit is) –

  • epsilon (float) –

property target_gate_names: Sequence[str]#

Returns the set of gate names to be decomposed.

decompose(gate)#

Describe the specific decomposition process. Only the target gates satisfying is_target_gate() method are passed.

Parameters:

gate (QuantumGate) – The gates to be decomposed.

Return type:

Sequence[QuantumGate]

class RX2NamedTranspiler(epsilon=1e-09)#

Bases: GateKindDecomposer

Convert 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)#

Describe the specific decomposition process. Only the target gates satisfying is_target_gate() method are passed.

Parameters:

gate (QuantumGate) – The gates to be decomposed.

Return type:

Sequence[QuantumGate]

class RY2NamedTranspiler(epsilon=1e-09)#

Bases: GateKindDecomposer

Convert 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)#

Describe the specific decomposition process. Only the target gates satisfying is_target_gate() method are passed.

Parameters:

gate (QuantumGate) – The gates to be decomposed.

Return type:

Sequence[QuantumGate]

class RZ2NamedTranspiler(epsilon=1e-09)#

Bases: GateKindDecomposer

Convert RZ gate to Identity, Z, S, Sdag, T, or Tdag gate if it is equivalent to a sequence of these gates.

Parameters:

epsilon (float) –

property target_gate_names: Sequence[str]#

Returns the set of gate names to be decomposed.

decompose(gate)#

Describe the specific decomposition process. Only the target gates satisfying is_target_gate() method are passed.

Parameters:

gate (QuantumGate) – The gates to be decomposed.

Return type:

Sequence[QuantumGate]

class Rotation2NamedTranspiler(epsilon=1e-09)#

Bases: SequentialTranspiler

Convert 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: GateKindDecomposer

Remove 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)#

Describe the specific decomposition process. Only the target gates satisfying is_target_gate() method are passed.

Parameters:

gate (QuantumGate) – The gates to be decomposed.

Return type:

Sequence[QuantumGate]