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

[Op. Arithm.] Improve performance #1 #3022

Merged
merged 20 commits into from
Sep 8, 2022
Merged

[Op. Arithm.] Improve performance #1 #3022

merged 20 commits into from
Sep 8, 2022

Conversation

AlbertMitjans
Copy link
Contributor

@AlbertMitjans AlbertMitjans commented Sep 2, 2022

  1. Use self.hash as a key for storing the eigendecomposition.
  2. Use the factors/summands eigvals and eigvecs when there are no overlapping wires.

Note: Check benchmarks below.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 2, 2022

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 Sep 2, 2022

Codecov Report

Merging #3022 (4f0b031) into master (54f76a9) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master    #3022   +/-   ##
=======================================
  Coverage   99.66%   99.66%           
=======================================
  Files         269      269           
  Lines       22845    22892   +47     
=======================================
+ Hits        22768    22815   +47     
  Misses         77       77           
Impacted Files Coverage Δ
pennylane/ops/op_math/prod.py 99.60% <100.00%> (+0.02%) ⬆️
pennylane/ops/op_math/sum.py 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@rmoyard rmoyard added this to the v0.26.0 milestone Sep 6, 2022
@AlbertMitjans
Copy link
Contributor Author

AlbertMitjans commented Sep 6, 2022

Comparison of the time taken to compute the expectation value of the sum of 15 tensor products of 9 Pauli operators acting on 9 different wires:

Note: The summands have overlapping wires, thus the full matrix is computed when calling eigvals and diagonalizing_gates.

  • Master branch:

image

  • This branch:

image

@AlbertMitjans
Copy link
Contributor Author

AlbertMitjans commented Sep 7, 2022

Comparison of the time taken to compute the eigenvalues of the operator:

(PauliZ(wires=[0]) @ PauliZ(wires=[47]) @ PauliZ(wires=[48]) @ PauliY(wires=[36]) @ PauliZ(wires=[13])) + 
(PauliZ(wires=[27]) @ PauliZ(wires=[30]) @ PauliX(wires=[6]) @ PauliY(wires=[41]) @ PauliY(wires=[1]))

Note: The summands and the factors of each summand have no overlapping wires.

  • Master:
    image

  • Branch:
    image

@AlbertMitjans
Copy link
Contributor Author

AlbertMitjans commented Sep 7, 2022

Comparison of the time taken to compute the diagonalising gates of the operator:

(PauliZ(wires=[0]) @ PauliZ(wires=[47]) @ PauliZ(wires=[48]) @ PauliY(wires=[36]) @ PauliZ(wires=[13])) + 
(PauliZ(wires=[27]) @ PauliZ(wires=[30]) @ PauliX(wires=[6]) @ PauliY(wires=[41]) @ PauliY(wires=[1]))

Note: The summands and the factors of each summand have no overlapping wires.

  • Master:
    image

  • Branch:
    image

@AlbertMitjans AlbertMitjans changed the title Improve performance for Prod class [Op. Arithm.] Improve performance #1 Sep 7, 2022
Copy link
Contributor

@Jaybsoni Jaybsoni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks really good! The performance boosts also look really nice 💯! As we discussed I think you can also add this logic into the sparse matrix method, and we should see similar improvements 👍🏼

Happy to approve once that is done and a changelog entry is added

@AlbertMitjans
Copy link
Contributor Author

AlbertMitjans commented Sep 8, 2022

Looks really good! The performance boosts also look really nice 💯! As we discussed I think you can also add this logic into the sparse matrix method, and we should see similar improvements 👍🏼

Happy to approve once that is done and a changelog entry is added

@Jaybsoni I believe the changes to the sparse_matrix should be done in PRs #3030 and #3031

Changelog entry added 👍

Copy link
Contributor

@albi3ro albi3ro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent!

@AlbertMitjans AlbertMitjans merged commit 74ba19e into master Sep 8, 2022
@AlbertMitjans AlbertMitjans deleted the prod_perf_improv branch September 8, 2022 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants