quri_parts.circuit.transpile.transpiler module#

quri_parts.circuit.transpile.transpiler.CircuitTranspiler#

CircuitTranspiler Interface. A function or callable object that can map NonParametricQuantumCircuit to NonParametricQuantumCircuit.

alias of Callable[[NonParametricQuantumCircuit], NonParametricQuantumCircuit]

class quri_parts.circuit.transpile.transpiler.CircuitTranspilerProtocol(*args, **kwargs)#

Bases: Protocol

Protocol of callable class that transpiles NonParametricQuantumCircuit to NonParametricQuantumCircuit.

class quri_parts.circuit.transpile.transpiler.SequentialTranspiler(transpilers: Sequence[Callable[[NonParametricQuantumCircuit], NonParametricQuantumCircuit]])#

Bases: CircuitTranspilerProtocol

CircuitTranspiler, which applies CircuitTranspilers in sequence.

Parameters:

transpilers – Sequence of CircuitTranspilers.

Examples

transpiler = SequentialTranspiler(
    [
        ATranspiler(),
        BTranspiler(arg..),
        ..
    ]
)
circuit = transpiler(circuit)
class quri_parts.circuit.transpile.transpiler.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: QuantumGate) bool#

Determine if a given gate is subject to decomposition.

Parameters:

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

abstract decompose(gate: QuantumGate) Sequence[QuantumGate]#

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

Parameters:

gate – The gates to be decomposed.

class quri_parts.circuit.transpile.transpiler.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: QuantumGate) bool#

Determine if a given gate is subject to decomposition.

Parameters:

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

class quri_parts.circuit.transpile.transpiler.ParallelDecomposer(decomposers: Sequence[GateKindDecomposer])#

Bases: CircuitTranspilerProtocol

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

Parameters:

decomposers – Sequence of GateKindDecomposer with no duplicate gate types to act on.