qml.clifford_t_decomposition¶
- clifford_t_decomposition(tape, epsilon=0.0001, method='sk', cache_size=1000, **method_kwargs)[source]¶
Decomposes a circuit into the Clifford+T basis.
This method first decomposes the gate operations to a basis comprised of Clifford,
T
,RZ
andGlobalPhase
operations (and their adjoints). The Clifford gates include the following PennyLane operations:Then, the leftover single qubit
RZ
operations are approximated in the Clifford+T basis with \(\epsilon > 0\) error. By default, we use the Solovay-Kitaev algorithm described in Dawson and Nielsen (2005) for this. Alternatively, the Ross-Selinger algorithm described in Ross and Selinger (2016) can be used by setting themethod
to"gridsynth"
.- Parameters:
tape (QNode or QuantumTape or Callable) – The quantum circuit to be decomposed.
epsilon (float) – The maximum permissible operator norm error of the complete circuit decomposition. Defaults to
0.0001
.method (str) – Method to be used for Clifford+T decomposition. Default value is
"sk"
for Solovay-Kitaev. Alternatively, the Ross-Selinger algorithm can be used with"gridsynth"
.cache_size (int) – The size of the cache built for the decomposition function based on the angle. Defaults to
1000
.**method_kwargs – Keyword argument to pass options for the
method
used for decompositions.
- Returns:
The transformed circuit as described in the
qml.transform
.- Return type:
qnode (QNode) or quantum function (Callable) or tuple[List[QuantumTape], function]
Keyword Arguments
- Solovay-Kitaev decomposition –
max_depth (int), basis_set (list[str]), basis_length (int) – arguments for the
"sk"
method, where the decomposition is performed using thesk_decomposition()
method.
- Ross-Selinger (
gridsynth
) decomposition – max_search_trials (int), max_factoring_trials (int) – arguments for the
"gridsynth"
method, where the decomposition is performed using thers_decomposition()
method.
- Ross-Selinger (
- Raises:
ValueError – If a gate operation does not have a decomposition when required.
NotImplementedError – If chosen decomposition
method
is not supported.
See also
rs_decomposition()
andsk_decomposition()
for Ross-Selinger and Solovay-Kitaev decomposition methods, respectively.Example
@qml.qnode(qml.device("default.qubit")) def circuit(x, y): qml.RX(x, 0) qml.CNOT([0, 1]) qml.RY(y, 0) return qml.expval(qml.Z(0)) x, y = 1.1, 2.2 decomposed_circuit = qml.transforms.clifford_t_decomposition(circuit) result = circuit(x, y) approx = decomposed_circuit(x, y)
>>> qml.math.allclose(result, approx, atol=1e-4) True