qml.clifford_t_decomposition

clifford_t_decomposition(tape, epsilon=0.0001, max_expansion=None, method='sk', **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 and GlobalPhase 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.

Warning

The max_expansion argument is deprecated and will be removed in version 0.40.

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.

  • max_expansion (int) – The depth to be used for tape expansion before manual decomposition to Clifford+T basis is applied.

  • method (str) – Method to be used for Clifford+T decomposition. Default value is "sk" for Solovay-Kitaev.

  • **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 the sk_decomposition() method.

Raises
  • ValueError – If a gate operation does not have a decomposition when required.

  • NotImplementedError – If chosen decomposition method is not supported.

See also

sk_decomposition() for Solovay-Kitaev decomposition.

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