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

Add a helper in math/quantum to calculate the matrix square root of sparse, hermitian matrices #6976

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

JerryChen97
Copy link
Contributor

@JerryChen97 JerryChen97 commented Feb 18, 2025

Context:
This need arose from #6963 where we realized that scipy.sparse could NOT help with a sparsity-preserved sqrtm as a sparse counterpart of its own scipy.linalg.sqrtm using Schur decomposition. Soon we realized that there could be a long list of lost functionality, e.g. eigh, sqrtm etc. We would like to update step by step such that when we implement the sparse representation for various matrices we do not have to convert them into dense repr, but this might involve quite some effort considering performance benchmark and lack of references. Therefore, we need some temporary solution that helps with specific Operator such as BlockEncode to avoid an explicit cast back to dense, thought the performance might vary.

For the BlockEncode considered in this PR, it specifically used sqrtm for a special class of matrices $Id - A^\dagger A$ where $A$ is the input matrix to encode into quantum circuits. This is very close to our own sqrt_matrix in qml.math.quantum that deals with the square root computation of a density matrix; our previous dense-matrix algorithm also made this assumption and directly called sqrt_matrix in the needed place. Hence we put forward a commonly used iterative method here suitable for similar Hermitian matrices to have square roots.

A quick introduction of what is the Denman–Beavers iteration used by this PR can be found at Wikipedia.

Description of the Change:
Provide a new helper in quantum.py

Benefits:
Enable the sparse version of BlockEncode

Possible Drawbacks:
No major. This method might have poor performance if used improperly.

Related GitHub Issues:
[sc-84693]

@JerryChen97 JerryChen97 changed the title Add a helper in math/quantum to calculate the matrix square root of sparse, hermitian matrices Add a helper in math/quantum to calculate the matrix square root of sparse, hermitian matrices Feb 18, 2025
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.

@JerryChen97 JerryChen97 self-assigned this Feb 18, 2025
@JerryChen97 JerryChen97 added WIP 🚧 Work-in-progress enhancement ✨ New feature or request labels Feb 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement ✨ New feature or request WIP 🚧 Work-in-progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant