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

Enhance Sparse Observable Handling and Expand State Initialization #1068

Merged
merged 57 commits into from
Mar 10, 2025

Conversation

AmintorDusko
Copy link
Contributor

@AmintorDusko AmintorDusko commented Feb 24, 2025

Enhance Sparse Observable Handling and Expand State Initialization

Summary:

This PR expands the capabilities of our sparse observable handling and add support for state vector initialization with sparse data. Key changes include:

  • Sparse Input Support for State Vector Initialization: Enables the initialization of state vectors from sparse input formats, offering improved efficiency for large, sparse systems.
  • Extended expval, var, and measures with samples Support: Modified the expval, var, and measures with samples to accept general SparseHermitianObs objects, allowing for extending the calculation of expectation values, variances, and measures with samples to other sparse observables.

Detailed Changes:

  • State Vector Initialization:
    • Implemented logic to handle sparse data as input for state vector initialization.
    • Added necessary checks and conversions to ensure compatibility with the internal state representation.
  • expval, var, and measures with samples:
    • Modified the functions to accept SparseHermitianObs objects as arguments.
    • Generalized the class handling to make it expandable to other sparse observables.

Related issues

[sc-86157] [sc-85831]

@AmintorDusko AmintorDusko added do not merge Do not merge PR until this label is removed ci:use-multi-gpu-runner Enable usage of Multi-GPU runner for this Pull Request ci:build_wheels Activate wheel building. ci:use-gpu-runner Enable usage of GPU runner for this Pull Request draft Indicates that the PR is still in draft mode, but needs CIs. labels Feb 24, 2025
Copy link
Contributor

Hello. You may have forgotten to update the changelog!
Please edit .github/CHANGELOG.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.

Copy link

codecov bot commented Feb 24, 2025

Codecov Report

Attention: Patch coverage is 98.07692% with 1 line in your changes missing coverage. Please review.

Project coverage is 98.94%. Comparing base (9e26a91) to head (2216056).
Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
pennylane_lightning/lightning_gpu/_state_vector.py 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1068      +/-   ##
==========================================
+ Coverage   97.98%   98.94%   +0.95%     
==========================================
  Files         233      266      +33     
  Lines       40090    44752    +4662     
==========================================
+ Hits        39284    44281    +4997     
+ Misses        806      471     -335     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@AmintorDusko AmintorDusko requested a review from JerryChen97 March 6, 2025 20:05
Copy link
Contributor

@JerryChen97 JerryChen97 left a comment

Choose a reason for hiding this comment

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

Thanks a lot! I don't have any blocking suggestions. Just one last question on the scope: from several changes to docstr, it looks like we dropped the wording for batched state. Is it because in the past we didn't actually support the batched states in these interface, or there's plan to move it around somewhere else?

@AmintorDusko
Copy link
Contributor Author

Thanks a lot! I don't have any blocking suggestions. Just one last question on the scope: from several changes to docstr, it looks like we dropped the wording for batched state. Is it because in the past we didn't actually support the batched states in these interface, or there's plan to move it around somewhere else?

@JerryChen97, I don't have a good answer for you. Perhaps @maliasadi can clarify this subject.

@AmintorDusko AmintorDusko requested a review from JerryChen97 March 7, 2025 14:12
Copy link
Contributor

@josephleekl josephleekl left a comment

Choose a reason for hiding this comment

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

Thanks @AmintorDusko! 🎆 Happy to approve, just a non-blocking comment. Also just want to make sure the GPU coverage is OK once all the tests complete

Copy link
Member

@multiphaseCFD multiphaseCFD left a comment

Choose a reason for hiding this comment

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

Thanks @AmintorDusko . Nice work. Would you mind to trigger the mpi tests as changes are made to the mpi part? Happy to approve once all CIs turn green.

@AmintorDusko AmintorDusko added the ci:use-multi-gpu-runner Enable usage of Multi-GPU runner for this Pull Request label Mar 10, 2025
@AmintorDusko
Copy link
Contributor Author

Thanks @AmintorDusko . Nice work. Would you mind to trigger the mpi tests as changes are made to the mpi part? Happy to approve once all CIs turn green.

Thank you very much!

@AmintorDusko AmintorDusko merged commit 79328b1 into master Mar 10, 2025
113 of 115 checks passed
@AmintorDusko AmintorDusko deleted the implement/Lightning_Sparse_Gates branch March 10, 2025 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci:build_wheels Activate wheel building. ci:use-gpu-runner Enable usage of GPU runner for this Pull Request ci:use-multi-gpu-runner Enable usage of Multi-GPU runner for this Pull Request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants