qml.clifford_t_decomposition¶
- clifford_t_decomposition(tape, epsilon=0.0001, method='sk', cache_size=1000, cache_eps_rtol=None, **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,RZandGlobalPhaseoperations (and their adjoints). The Clifford gates include the following PennyLane operations:Then, the leftover single qubit
RZoperations 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 themethodto"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.cache_eps_rtol (Optional[float]) – The relative tolerance for
epsilonvalues between which the cache may be reused. Defaults toNone, which means that a cached decomposition will be used if it is at least as precise as the requested error.**method_kwargs – Keyword argument to pass options for the
methodused 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
methodis 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