Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Commutation dag #1712

Merged
merged 123 commits into from
Mar 1, 2022
Merged

Commutation dag #1712

merged 123 commits into from
Mar 1, 2022

Conversation

rmoyard
Copy link
Contributor

@rmoyard rmoyard commented Oct 1, 2021

Context:

This PR adds a

  1. Function is_commuting checks if two operations commute, it does not use matrices multiplications but a truth table. It also uses some matrix multiplication for edge cases.
commutation = qml.is_commuting(qml.CNOT(wires=[0, 1]), qml.Toffoli(wires= [0, 1, 2]))
  1. A DAG that represents the pairwise commutation structure of the quantum circuit.
def circuit():
    qml.CNOT(wires=[0, 1])
    qml.CNOT(wires=[0, 2])
    qml.PauliZ(wires=[0])
    qml.CNOT(wires=[2, 0])

dag = qml.transforms.commutation_dag(circuit)()

Benefits:
A commutation function that does not use matrices multiplication and takes any two operations as inputs. A new DAG that represents the commutation structure of quantum circuits and is useful for quantum circuits optimization.

@rmoyard rmoyard added the WIP 🚧 Work-in-progress label Oct 1, 2021
@github-actions
Copy link
Contributor

github-actions bot commented Oct 1, 2021

Hello. You may have forgotten to update the changelog!
Please edit doc/releases/changelog-dev.md with:

  • A one-to-two sentence description of the change. You may include a small working example for new features.
  • A link back to this PR.
  • Your name (or GitHub username) in the contributors section.

@codecov
Copy link

codecov bot commented Oct 14, 2021

Codecov Report

Merging #1712 (00c9af7) into master (d4931e7) will increase coverage by 0.05%.
The diff coverage is 99.68%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1712      +/-   ##
==========================================
+ Coverage   99.22%   99.27%   +0.05%     
==========================================
  Files         231      232       +1     
  Lines       18392    18708     +316     
==========================================
+ Hits        18249    18573     +324     
+ Misses        143      135       -8     
Impacted Files Coverage Δ
pennylane/__init__.py 100.00% <ø> (ø)
pennylane/operation.py 95.99% <ø> (ø)
pennylane/templates/subroutines/qpe.py 100.00% <ø> (ø)
pennylane/transforms/commutation_dag.py 99.67% <99.67%> (ø)
pennylane/transforms/__init__.py 100.00% <100.00%> (ø)
pennylane/transforms/control.py 100.00% <100.00%> (ø)
pennylane/_device.py 97.98% <0.00%> (+0.33%) ⬆️
pennylane/ops/qubit/non_parametric_ops.py 100.00% <0.00%> (+0.44%) ⬆️
pennylane/_qubit_device.py 98.72% <0.00%> (+1.91%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d4931e7...00c9af7. Read the comment docs.

rmoyard and others added 12 commits March 1, 2022 03:07
Co-authored-by: Josh Izaac <josh146@gmail.com>
Co-authored-by: Josh Izaac <josh146@gmail.com>
Co-authored-by: Josh Izaac <josh146@gmail.com>
Co-authored-by: Josh Izaac <josh146@gmail.com>
Co-authored-by: Josh Izaac <josh146@gmail.com>
Co-authored-by: Josh Izaac <josh146@gmail.com>
Co-authored-by: Josh Izaac <josh146@gmail.com>
Co-authored-by: Josh Izaac <josh146@gmail.com>
Co-authored-by: Josh Izaac <josh146@gmail.com>
@rmoyard rmoyard merged commit 5a6c2f5 into master Mar 1, 2022
@rmoyard rmoyard deleted the commutation_dag branch March 1, 2022 14:34
@antalszava
Copy link
Contributor

[sc-15667]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
review-ready 👌 PRs which are ready for review by someone from the core team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants