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

Support eigvals for sparse hamiltonians #2333

Merged
merged 36 commits into from
Mar 18, 2022
Merged

Conversation

soranjh
Copy link
Contributor

@soranjh soranjh commented Mar 15, 2022

Context:
Adds functionality for returning the eigenvalues of a sparse Hamiltonian. The eigendecomposition of sparse Hamiltonians is much more efficient with the scipy sparse linear algebra tools.

Description of the Change:
The qml.eigvals function is modified to recognize a SparseHamiltonian object and use scipy.sparse.linalg.eigsh for the eigendecomposition.

Benefits:
The new addition provides a very efficient way for obtaining the eigenvalues of a sparse Hamiltonian.

Possible Drawbacks:
scipy.sparse.linalg.eigsh computes k ( = 6 by default) eigenvalues and eigenvectors only.

Related GitHub Issues:
#2308

@github-actions
Copy link
Contributor

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.

@soranjh soranjh added enhancement ✨ New feature or request WIP 🚧 Work-in-progress labels Mar 15, 2022
@codecov
Copy link

codecov bot commented Mar 15, 2022

Codecov Report

Merging #2333 (a455d60) into master (d360afd) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master    #2333   +/-   ##
=======================================
  Coverage   99.39%   99.39%           
=======================================
  Files         229      229           
  Lines       17442    17448    +6     
=======================================
+ Hits        17336    17342    +6     
  Misses        106      106           
Impacted Files Coverage Δ
pennylane/ops/functions/eigvals.py 100.00% <100.00%> (ø)

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 d360afd...a455d60. Read the comment docs.

@soranjh soranjh changed the title [WIP] suuport eigvals for sparse hamiltonians Suuport eigvals for sparse hamiltonians Mar 16, 2022
@soranjh soranjh removed the WIP 🚧 Work-in-progress label Mar 16, 2022
@soranjh soranjh marked this pull request as ready for review March 16, 2022 15:24
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.

Just a few small things, but other then that it looks good 👍🏼 Should be quite a good speed up!

pennylane/ops/functions/eigvals.py Outdated Show resolved Hide resolved
pennylane/ops/functions/eigvals.py Outdated Show resolved Hide resolved
pennylane/ops/functions/eigvals.py Outdated Show resolved Hide resolved
@Jaybsoni Jaybsoni changed the title Suuport eigvals for sparse hamiltonians Suport eigvals for sparse hamiltonians Mar 16, 2022
@Jaybsoni Jaybsoni changed the title Suport eigvals for sparse hamiltonians Support eigvals for sparse hamiltonians Mar 16, 2022
pennylane/ops/functions/eigvals.py Outdated Show resolved Hide resolved
tests/ops/functions/test_eigvals.py Show resolved Hide resolved
Copy link
Contributor

@KetpuntoG KetpuntoG left a comment

Choose a reason for hiding this comment

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

Just a small comment on the doc, the rest I see it perfect! 💪

pennylane/ops/functions/eigvals.py Outdated Show resolved Hide resolved
Copy link
Contributor

@ixfoduap ixfoduap left a comment

Choose a reason for hiding this comment

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

Looks good! Just maybe good to add a short explanation on what the possible which methods refer to.

pennylane/ops/functions/eigvals.py Outdated Show resolved Hide resolved
@soranjh soranjh merged commit 7694a2b into master Mar 18, 2022
@soranjh soranjh deleted the eigvals_sparse_hamiltonian branch March 18, 2022 23:14
@josh146 josh146 linked an issue Mar 21, 2022 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement ✨ New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Eigendecomposition
5 participants