quri_parts.circuit.transpile package#

class CliffordConversionTranspiler(target_gateset)#

Bases: CircuitTranspilerProtocol

A CircuitTranspiler that converts Clifford gates in a circuit into the desired Clifford gate sequences.

Convert the Clifford gates in the circuit into gate sequences containing only the user-specified Clifford gates. Such conversions are done on a best-effort basis and may leave non target Clifford gates in the output.

Clifford gates that could not be converted or non-Clifford gates will remain in place.

Parameters:

target_gateset (Iterable[CliffordGateNameType]) – A Sequence of Clifford gate names to output.

class CliffordRZSetTranspiler(epsilon=1e-09)#

Bases: SequentialTranspiler

CircuitTranspiler to transpile a QuntumCircuit into another QuantumCircuit containing only H, X, Y, Z, SqrtX, SqrtXdag, SqrtY, SqrtYdag, S, Sdg, RZ, CZ, and CNOT.

Since this transpiler involves fusing rotation gates, converting rotation gates to named gates with a certain precision, and removing Identity gates, the action of the circuit before and after the conversion may not be completely equivalent.

Parameters:

epsilon (float) –

class CliffordApproximationTranspiler(*args, **kwargs)#

Bases: GateDecomposer

CircuitTranspiler, which replaces the non_clifford gate into sequence of non-parametric Clifford gates.

If the input gate has angles, this transpiler replaces them with the closest value in the set \(\{\pi n /2| n\in\mathbb{Z}\}\). Then by using the rotation gate transpilers, it is decomposed into a sequence of non-parametric Clifford gates.

is_target_gate(gate)#

Determine if a given gate is subject to decomposition.

Parameters:

gate (QuantumGate) – Gates in the circuit that are scanned from the front.

Return type:

bool

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 CircuitTranspilerProtocol(*args, **kwargs)#

Bases: Protocol

Protocol of callable class that transpiles NonParametricQuantumCircuit to NonParametricQuantumCircuit.

class CNOT2CZHTranspiler(*args, **kwargs)#

Bases: GateKindDecomposer

CircuitTranspiler, which decomposes CNOT gates into sequences of H and CZ gates.

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 CZ2CNOTHTranspiler(*args, **kwargs)#

Bases: GateKindDecomposer

CircuitTranspiler, which decomposes CZ gates into sequences of H and CNOT gates.

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 CZ2RXRYCNOTTranspiler(*args, **kwargs)#

Bases: GateKindDecomposer

CircuitTranspiler, which decomposes CZ gates into sequences of RX, RY, and CNOT gates.

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 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 GateDecomposer(*args, **kwargs)#

Bases: CircuitTranspilerProtocol, ABC

Abstract class that represents CircuitTranspiler, such that target gates are selected by decision function and each target gate is replaced by a sequence of multiple gates.

abstract is_target_gate(gate)#

Determine if a given gate is subject to decomposition.

Parameters:

gate (QuantumGate) – Gates in the circuit that are scanned from the front.

Return type:

bool

abstract 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 GateKindDecomposer(*args, **kwargs)#

Bases: GateDecomposer, ABC

Abstract class that represents CircuitTranspiler, such that each gate is identified by its gate name and the target gate is replaced by a sequence of multiple gates.

Classes inheriting from this class can be used for ParallelDecomposer.

abstract property target_gate_names: Sequence[str]#

Returns the set of gate names to be decomposed.

is_target_gate(gate)#

Determine if a given gate is subject to decomposition.

Parameters:

gate (QuantumGate) – Gates in the circuit that are scanned from the front.

Return type:

bool

class GateSetConversionTranspiler(target_gateset, epsilon=1e-09)#

Bases: CircuitTranspilerProtocol

A CircuitTranspiler that converts the gate set of a circuit into the specified one.

Depending on the target gate set and the input circuit, the decomposition may fail and an exception may be raised.

Parameters:
  • target_gateset (Iterable[GateNameType]) – A Sequence of allowed output gate names.

  • epsilon (float) –

class H2RXRYTranspiler(*args, **kwargs)#

Bases: GateKindDecomposer

CircuitTranspiler, which decomposes H gates into sequences of RX and RY gates.

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 H2RZSqrtXTranspiler(*args, **kwargs)#

Bases: GateKindDecomposer

CircuitTranspiler, which decomposes H gates into sequences of RZ and SqrtX gates.

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 IdentityEliminationTranspiler(*args, **kwargs)#

Bases: CircuitTranspilerProtocol

Generate a new circuit by removing all Identity gates from the given circuit.

class IdentityInsertionTranspiler#

Bases: CircuitTranspilerProtocol

If there are qubits to which any gate has not been applied, Identity gates are added for those qubits.

The application of this transpiler ensures that every qubit has at least one gate acting on it.

class Identity2RZTranspiler(*args, **kwargs)#

Bases: GateKindDecomposer

CircuitTranspiler, which converts Identity gates into RZ gates.

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 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 ParallelDecomposer(decomposers)#

Bases: CircuitTranspilerProtocol

CircuitTranspiler, which executes given GateKindDecomposer within a single loop traversing the gate from the front.

Parameters:

decomposers (Sequence[GateKindDecomposer]) – Sequence of GateKindDecomposer with no duplicate gate types to act on.

class PauliDecomposeTranspiler#

Bases: GateKindDecomposer

CircuitTranspiler, which decompose multi-qubit Pauli gates into X, Y, and Z gates.

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 PauliRotationDecomposeTranspiler#

Bases: GateKindDecomposer

CircuitTranspiler, which decompose multi-qubit PauliRotation gates into H, RX, RZ, and CNOT gates.

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 QubitRemappingTranspiler(qubit_mapping)#

Bases: CircuitTranspilerProtocol

Remap qubits in the circuit with the specified mapping.

The mapping qubit_mapping should be specified with “from” qubit indices as keys and “to” qubit indices as values. For example, if you want to convert a circuit using qubits 0, 1, 2, 3 by mapping them as 0 → 4, 1 → 2, 2 → 5, 3 → 0, then the qubit_mapping should be {0: 4, 1: 2, 2: 5, 3: 0}. The qubit_count of the converted circuit is determined by the largest destination qubit index. In the above example, the largest index is 5, so the converted circuit is for 6 qubits.

Parameters:

qubit_mapping (Mapping[int, int]) –

class RotationConversionTranspiler(target_rotation, favorable_clifford=())#

Bases: CircuitTranspilerProtocol

A CircuitTranspiler that converts rotation gates (RX, RY, and RZ) in a circuit to each other.

Convert rotation gates in a circuit into the gate sequences containing only specified kinds of rotation gates and Clifford gates.

If there are 2 permitted rotation gate kinds, the rotation gates are converted into the rotation gates only; if there is 1 permitted rotation gate kind, the rotation gates are converted into the rotation gates and Clifford gates.

The more favorable Clifford gates can be indicated. However, the choice of Clifford gates is made on a best-effort basis. Clifford gate kinds included in the output is not guaranteed.

Parameters:
  • target_rotation (Iterable[GateNameType]) – A Sequence of rotation gate names to output.

  • favorable_clifford (Iterable[CliffordGateNameType]) – A Sequence of Clifford gate names to be prioritesed as an output.

class RX2RYRZTranspiler(*args, **kwargs)#

Bases: GateKindDecomposer

A CircuitTranspiler that converts RX gates in a circuit into the gate sequences containing RY and RZ gates.

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 RX2RZHTranspiler(*args, **kwargs)#

Bases: GateKindDecomposer

A CircuitTranspiler that converts RX gates in a circuit into the gate sequences containing RZ and H gates.

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 RY2RXRZTranspiler(*args, **kwargs)#

Bases: GateKindDecomposer

A CircuitTranspiler that converts RY gates in a circuit into the gate sequences containing RX and RZ gates.

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 RY2RZHTranspiler(*args, **kwargs)#

Bases: GateKindDecomposer

A CircuitTranspiler that converts RY gates in a circuit into the gate sequences containing RZ and H gates.

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 RZ2RXRYTranspiler(*args, **kwargs)#

Bases: GateKindDecomposer

A CircuitTranspiler that converts RZ gates in a circuit into the gate sequences containing RX and RY gates.

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]

RZSetTranspiler()#

CircuitTranspiler to transpile a QuntumCircuit into another QuantumCircuit containing only X, SqrtX, CNOT, and RZ. (UnitaryMatrix gate for 3 or more qubits are not decomposed.)

RotationSetTranspiler()#

CircuitTranspiler to transpile a QuntumCircuit into another QuantumCircuit containing only RX, RY, RZ, and CNOT. (UnitaryMatrix gate for 3 or more qubits are not decomposed.)

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 RX2RZSqrtXTranspiler(*args, **kwargs)#

Bases: GateKindDecomposer

CircuitTranspiler, which decomposes RX gates into sequences of RZ and SqrtX gates.

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 RY2RZSqrtXTranspiler(*args, **kwargs)#

Bases: GateKindDecomposer

CircuitTranspiler, which decomposes RY gates into sequences of RZ and SqrtX gates.

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 SequentialTranspiler(transpilers)#

Bases: CircuitTranspilerProtocol

CircuitTranspiler, which applies CircuitTranspilers in sequence.

Parameters:

transpilers (Sequence[CircuitTranspiler]) – Sequence of CircuitTranspilers.

Examples

transpiler = SequentialTranspiler(
    [
        ATranspiler(),
        BTranspiler(arg..),
        ..
    ]
)
circuit = transpiler(circuit)
class S2RZTranspiler(*args, **kwargs)#

Bases: GateKindDecomposer

CircuitTranspiler, which decomposes S gates into of gates.

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 Sdag2RZTranspiler(*args, **kwargs)#

Bases: GateKindDecomposer

CircuitTranspiler, which decomposes Sdag gates into RZ gates.

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 SingleQubitUnitaryMatrix2RYRZTranspiler(*args, **kwargs)#

Bases: GateDecomposer

CircuitTranspiler, which decomposes single qubit UnitaryMatrix gates into gate sequences containing RY and RZ gates.

Ref:
[1]: Tomonori Shirakawa, Hiroshi Ueda, and Seiji Yunoki,

Automatic quantum circuit encoding of a given arbitrary quantum state, arXiv:2112.14524v1, p.22, (2021).

[2]: Main functions are ported from the source code wrtitten by Sota Morisaki

in QunaSys intern project.

is_target_gate(gate)#

Determine if a given gate is subject to decomposition.

Parameters:

gate (QuantumGate) – Gates in the circuit that are scanned from the front.

Return type:

bool

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 SqrtX2RXTranspiler(*args, **kwargs)#

Bases: GateKindDecomposer

CircuitTranspiler, which converts SqrtX gates into RX gates.

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 SqrtX2RZHTranspiler(*args, **kwargs)#

Bases: GateKindDecomposer

CircuitTranspiler, which decomposes SqrtX gates into sequences of RZ and H gates.

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 SqrtXdag2RXTranspiler(*args, **kwargs)#

Bases: GateKindDecomposer

CircuitTranspiler, which converts SqrtXdag gates into RX gates.

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 SqrtXdag2RZSqrtXTranspiler(*args, **kwargs)#

Bases: GateKindDecomposer

CircuitTranspiler, which decomposes SqrtXdag gates into sequences of RZ and SqrtX gates.

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 SqrtY2RYTranspiler(*args, **kwargs)#

Bases: GateKindDecomposer

CircuitTranspiler, which converts SqrtY gates into RY gates.

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 SqrtY2RZSqrtXTranspiler(*args, **kwargs)#

Bases: GateKindDecomposer

CircuitTranspiler, which decomposes SqrtY gates into sequences of RZ and SqrtX gates.

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 SqrtYdag2RYTranspiler(*args, **kwargs)#

Bases: GateKindDecomposer

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 SqrtYdag2RZSqrtXTranspiler(*args, **kwargs)#

Bases: GateKindDecomposer

CircuitTranspiler, which decomposes SqrtYdag gates into sequences of RZ and SqrtX gates.

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 SWAP2CNOTTranspiler(*args, **kwargs)#

Bases: GateKindDecomposer

CircuitTranspiler, which decomposes SWAP gates into sequences of CNOT gates.

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]

STARSetTranspiler()#

CircuitTranspiler to transpile a QuntumCircuit into another QuantumCircuit containing only basic gates for STAR architecture (H, RZ, and CNOT). (UnitaryMatrix gate for 3 or more qubits are not decomposed.)

class T2RZTranspiler(*args, **kwargs)#

Bases: GateKindDecomposer

CircuitTranspiler, which decomposes T gates into RZ gates.

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 Tdag2RZTranspiler(*args, **kwargs)#

Bases: GateKindDecomposer

CircuitTranspiler, which decomposes Tdag gates into RZ gates.

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 TOFFOLI2HTTdagCNOTTranspiler(*args, **kwargs)#

Bases: GateKindDecomposer

CircuitTranspiler, which decomposes TOFFOLI gates into sequences of H, T, TDag, and CNOT gates.

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 TwoQubitUnitaryMatrixKAKTranspiler(*args, **kwargs)#

Bases: GateDecomposer

CircuitTranspiler, which decomposes two qubit UnitaryMatrix gates into gate sequences containing H, S, RX, RY, RZ, and CNOT gates.

Raises:

ValueError – Depending on the nature of the unitary matrix of the input UnitaryMatrix gate, the decomposition may fail and throw an error.

Ref:
[1]: Tomonori Shirakawa, Hiroshi Ueda, and Seiji Yunoki,

Automatic quantum circuit encoding of a given arbitrary quantum state, arXiv:2112.14524v1, pp.4-5, (2021).

[2]: Main functions are ported from the source code wrtitten by Sota Morisaki

in QunaSys intern project.

is_target_gate(gate)#

Determine if a given gate is subject to decomposition.

Parameters:

gate (QuantumGate) – Gates in the circuit that are scanned from the front.

Return type:

bool

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 U1ToRZTranspiler(*args, **kwargs)#

Bases: GateKindDecomposer

CircuitTranspiler, which decomposes U1 gates into RZ gates.

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 U2ToRXRZTranspiler(*args, **kwargs)#

Bases: GateKindDecomposer

CircuitTranspiler, which decomposes U2 gates into sequences of RX and RZ gates.

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 U2ToRZSqrtXTranspiler(*args, **kwargs)#

Bases: GateKindDecomposer

CircuitTranspiler, which decomposes U2 gates into sequences of RZ and SqrtX gates.

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 U3ToRXRZTranspiler(*args, **kwargs)#

Bases: GateKindDecomposer

CircuitTranspiler, which decomposes U3 gates into sequences of RX and RZ gates.

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 U3ToRZSqrtXTranspiler(*args, **kwargs)#

Bases: GateKindDecomposer

CircuitTranspiler, which decomposes U3 gates into sequences of RZ and SqrtX gates.

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 X2HZTranspiler(*args, **kwargs)#

Bases: GateKindDecomposer

CircuitTranspiler, which decomposes X gates into sequences of H and Z gates.

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 X2RXTranspiler(*args, **kwargs)#

Bases: GateKindDecomposer

CircuitTranspiler, which converts X gates into RX gates.

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 X2SqrtXTranspiler(*args, **kwargs)#

Bases: GateKindDecomposer

CircuitTranspiler, which decomposes X gates into sequences of SqrtX gates.

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 Y2RYTranspiler(*args, **kwargs)#

Bases: GateKindDecomposer

CircuitTranspiler, which converts Y gates into RY gates.

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 Y2RZXTranspiler(*args, **kwargs)#

Bases: GateKindDecomposer

CircuitTranspiler, which decomposes Y gates into sequences of RZ and T gates.

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 Z2HXTranspiler(*args, **kwargs)#

Bases: GateKindDecomposer

CircuitTranspiler, which decomposes Z gates into sequences of H and X gates.

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 Z2RZTranspiler(*args, **kwargs)#

Bases: GateKindDecomposer

CircuitTranspiler, which decomposes Z gates into RZ gates.

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 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]

su2_decompose(ut, eps=1e-15)#
Parameters:
  • ut (Sequence[Sequence[complex]]) –

  • eps (float) –

Return type:

ndarray[Any, dtype[float64]]

su4_decompose(ut, eiglim=1e-10)#
Parameters:
  • ut (Sequence[Sequence[complex]]) –

  • eiglim (float) –

Return type:

tuple[ndarray[Any, dtype[float64]], ndarray[Any, dtype[float64]], ndarray[Any, dtype[float64]]]

Submodules#