Skip to content

Commit

Permalink
Solovay-Kitaev Decomposition Algorithm (#4801)
Browse files Browse the repository at this point in the history
**Context:** Implements the `Solovay-Kitaev` decomposition algorithm
using the description mentioned in
[arXiv:0505030](https://arxiv.org/abs/quant-ph/0505030)

**Description of the Change:** This adds a Solovay-Kitaev decomposition
for the Clifford+T workflow in the `solovay_kitaev.py` file.

1. `sk_decomposition` technique is the parent method, which takes in any
single-qubit operator and uses its `SU(2)` representation for finding
its decomposition in the specified basis up to a global phase via
recursive implementation contained in `_solovay_kitaev` function.
2. `_approximate_set` method allows us to build an approximate set of
Clifford sequences that are used in the base case return for the above
`_solovay_kitaev` recursive call.
3. `_group_commutator_decompose` allows us to perform the group
commutation decomposition and uses the recipe mentioned in Sec 4.1
[arXiv:0505030](https://arxiv.org/abs/quant-ph/0505030).

**Benefits:** Should allow one to do the Clifford+T decomposition.

**Possible Drawbacks:** Better algorithms exist in the literature,
specifically for decomposing rotation gates.

**Related GitHub Issues:**

---------

Co-authored-by: Matthew Silverman <[email protected]>
Co-authored-by: Tom Bromley <[email protected]>
Co-authored-by: soranjh <[email protected]>
  • Loading branch information
4 people authored Nov 24, 2023
1 parent d13cf3d commit 370d9d4
Show file tree
Hide file tree
Showing 7 changed files with 606 additions and 4 deletions.
4 changes: 4 additions & 0 deletions doc/releases/changelog-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

<h4>Decompose circuits into the Clifford+T gateset 🧩</h4>

* `qml.transforms.decompositions.sk_decomposition` method implements the Solovay-Kitaev algorithm for
approximately decomposing any single-qubit operation to Clifford+T basis.
[(#4801)](https://github.com/PennyLaneAI/pennylane/pull/4801)

<h4>Transforms (TODO: better title) 🤖</h4>

<h4>Use an iterative approach for quantum phase estimation 🔄</h4>
Expand Down
8 changes: 4 additions & 4 deletions pennylane/ops/functions/map_wires.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,17 @@ def map_wires(
return new_op
return input.map_wires(wire_map=wire_map)
if isinstance(input, (QuantumScript, QNode)) or callable(input):
return _map_wires_transform(input, wire_map=wire_map)
return _map_wires_transform(input, wire_map=wire_map, queue=queue)

raise ValueError(f"Cannot map wires of object {input} of type {type(input)}.")


@partial(transform)
def _map_wires_transform(
tape: qml.tape.QuantumTape, wire_map=None
tape: qml.tape.QuantumTape, wire_map=None, queue=False
) -> (Sequence[qml.tape.QuantumTape], Callable):
ops = [map_wires(op, wire_map) for op in tape.operations]
measurements = [map_wires(m, wire_map) for m in tape.measurements]
ops = [map_wires(op, wire_map, queue=queue) for op in tape.operations]
measurements = [map_wires(m, wire_map, queue=queue) for m in tape.measurements]

out = tape.__class__(ops=ops, measurements=measurements, shots=tape.shots)
out.trainable_params = tape.trainable_params
Expand Down
11 changes: 11 additions & 0 deletions pennylane/transforms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,16 @@
~transforms.CommutationDAG
~transforms.CommutationDAGNode
Transform for Clifford+T compilation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The following functions assist in decomposing operations to the Clifford+T basis.
.. autosummary::
:toctree: api
~transforms.sk_decomposition
Transform for circuit cutting
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -230,6 +240,7 @@
from .decompositions import (
one_qubit_decomposition,
two_qubit_decomposition,
sk_decomposition,
)
from .defer_measurements import defer_measurements
from .sign_expand import sign_expand
Expand Down
2 changes: 2 additions & 0 deletions pennylane/transforms/decompositions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@

from .single_qubit_unitary import one_qubit_decomposition
from .two_qubit_unitary import two_qubit_decomposition

from .clifford_t import sk_decomposition
16 changes: 16 additions & 0 deletions pennylane/transforms/decompositions/clifford_t/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2018-2023 Xanadu Quantum Technologies Inc.

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""This module contains methods related to Clifford+T decomposition"""

from .solovay_kitaev import sk_decomposition
Loading

0 comments on commit 370d9d4

Please sign in to comment.