qat.middleend.decompositions.gates module
- class DefaultGateDecompositions(end_nodes=None, extend_end_nodes=None)
Bases:
GateDecompositionBase
Implements the standard gate decompositions used in OQC hardware.
Provides decomposition rules for the native gate set {
Z_phase
,X_pi_2
,ZX_pi_4
}.- Parameters:
end_nodes¶ (
Optional
[list
[QubitInstruction
]]) – Optionally specify the nodes to end the decomposition recursion at. Defaults todecompositions.end_nodes
.extend_end_nodes¶ (
Optional
[list
[QubitInstruction
]]) – By default the decomposition will recurse until all gates are aNativeGate
. You can optionally add additional (nonNativeGate
) gates to terminate at. This argument should only be specified ifend_nodes=None
.
- decompose_op(gate)
Implements the definition of a decomposition of a gate.
The definition does not have to be in terms of native gates, but decompositions must form a DAG. For example,
CNOT -> {ECR, X, Z} -> {ZX_pi_4, Z_phase, X_pi_2} U -> {x_pi_2, Z_phase}
- end_nodes = (<class 'qat.ir.gates.native.Z_phase'>, <class 'qat.ir.gates.native.X_pi_2'>, <class 'qat.ir.gates.native.ZX_pi_4'>)
- class GateDecompositionBase(end_nodes=None, extend_end_nodes=None)
Bases:
DecompositionBase
Base object for implementing decompositions of gates with
NativeGate
for end nodes.This handles decompositions of gates to gates, and should not be used to lower gates to pulse instructions. While it is recommended to use
DefaultGateDecompositons
, custom gate decompositions strategies can be implemented via this class. This could be used, for example, if targeting machines that have a different native gate set, or trying out approximate decompositions that have a cheaper implementation cost.- Parameters:
end_nodes¶ (
Optional
[list
[QubitInstruction
]]) – Optionally specify the nodes to end the decomposition recursion at. Defaults todecompositions.end_nodes
.extend_end_nodes¶ (
Optional
[list
[QubitInstruction
]]) – By default the decomposition will recurse until all gates are aNativeGate
. You can optionally add additional (nonNativeGate
) gates to terminate at. This argument should only be specified ifend_nodes=None
.
- end_nodes = (<class 'qat.ir.gates.native.NativeGate'>,)