Decomposition
Target backends typically are only able to execute a limited set of gates that make up the so-called native gate set. In most cases, the (lower-level) control software of a particular target backend will convert a circuit into these native gates.
To distinguish between native gates and the set of gates that the control software accepts, we refer to the latter as the primitive gate set.
In general, the native gate set is a subset of the primitive gate set, and the primitive gate set is a subset of the standard gate set, i.e., the gate set as supported by the cQASM language.
The input circuit may be written in terms of the gates as they are defined in the standard gate set, yet the output circuit will need to be in terms of the gates from the primitive gate set. To ensure the latter, the compiler can be used to decompose the gates into gates that are part of the primitive gate set.
The following decomposer passes are available in OpenSquirrel:
- ABA decomposer
- CNOT decomposer (
CNOTDecomposer) - CZ decomposer (
CZDecomposer) - McKay decomposer (
McKayDecomposer) - Predefined decomposers
- CNOT to CZ decomposer (
CNOT2CZDecomposer) - SWAP to CNOT decomposer (
SWAP2CNOTDecomposer) - SWAP to CZ decomposer (
SWAP2CZDecomposer)
- CNOT to CZ decomposer (
Note that the above decomposers are specific for single- or two-qubit gates; two-qubit gates are not decomposed by single-qubit gate decomposers, and vice versa.
Primitive gate validator
The primitive gate validator (PrimitiveGateValidator) can be used
to validate that the compiled circuit consists solely of gates that are part of the desired primitive gate set.
Global phase
After each decomposition a check is done to ensure that the result constitutes the same unitary operation up to a globale phase difference. Note that, in general, the global phase is not conserved. A difference in global phase can, in certain cases, lead to a semantically different circuit, therefore we urge the user to be aware of this risk.
More in depth decomposition tutorials can be found in the decomposition example Jupyter notebook.