PennyLaneAI / pennylane

PennyLane is a cross-platform Python library for quantum computing, quantum machine learning, and quantum chemistry. Train a quantum computer the same way as a neural network.
https://pennylane.ai
Apache License 2.0
2.35k stars 603 forks source link

[unitaryhack] Define decomposition for `qml.Toffoli` #1305

Closed antalszava closed 3 years ago

antalszava commented 3 years ago

This issue has been tagged for contributions during unitaryHACK

Each PennyLane operation defines a decomposition. The decomposition of an operation is an ordered list of other operations. Applying this list of operations evolves quantum states the same way as applying the operation itself does. In most cases, this list includes elementary gates that are often supported by most quantum devices.

We would like to add the decomposition of the qml.Toffoli operation by:

  1. Defining the decomposition method for the qml.Toffoli operation that has the following signature:
    @staticmethod
    def decomposition(wires):

    Other operations in the pennylane/ops/qubit.py file can serve as an example for defining this method (e.g., see qml.Hadamard).

  2. Including a test case for the decomposition of qml.Toffoli in the tests/ops/test_qubit_ops.py file to verify its correctness.
tgag17 commented 3 years ago

Hi! I would like to work on this issue. Would it be a good idea to decompose the Toffoli gate to a list of Hadamard, CNOT and T gates?

antalszava commented 3 years ago

Hi @tgag17, that's great :tada: Yes, using the Hadamard, CNOT and T gates for the decomposition would work nicely. :slightly_smiling_face:

Feel free to open up a PR (even if it's still a work in progress) and ask any questions that you may have.

tgag17 commented 3 years ago

Great! Thank you.