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

Enforce the positivity of prob inside ProbMP.process_density_matrix #6727

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

Conversation

JerryChen97
Copy link
Contributor

@JerryChen97 JerryChen97 commented Dec 16, 2024

Context:
This missing line might lead to specific nan error in the downstreaming gradient process especially ag/jax related. Check out https://github.com/PennyLaneAI/pennylane/actions/runs/12360643306/job/34496071685?pr=6684 and https://github.com/PennyLaneAI/pennylane/actions/runs/12360643306/job/34496077651?pr=6684 for concrete examples

P.S. How did the legacy device deal with this issue? It explicitly calls its own analytic prob method and did similar things

return qnp.where(probs < 0, -probs, probs)

Description of the Change:
use clip with min value eps to enforce the positivity.

Benefits:
More reliability

Possible Drawbacks:
None realized

Related GitHub Issues:

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 changed the title Enforce the positivity of prob inside ProbMP.process_density_matrix Enforce the positivity of prob inside ProbMP.process_density_matrix Dec 16, 2024
Copy link

codecov bot commented Dec 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.62%. Comparing base (579e70d) to head (94bb291).
Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff            @@
##           master    #6727    +/-   ##
========================================
  Coverage   99.62%   99.62%            
========================================
  Files         476      477     +1     
  Lines       44733    44890   +157     
========================================
+ Hits        44564    44721   +157     
  Misses        169      169            

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

@JerryChen97 JerryChen97 self-assigned this Dec 17, 2024
@andrijapau andrijapau self-requested a review December 17, 2024 15:56
@JerryChen97 JerryChen97 marked this pull request as draft December 18, 2024 19:27
@JerryChen97
Copy link
Contributor Author

We will leave this open for discussion furthermore after new year when everyone is back

@JerryChen97
Copy link
Contributor Author

We will leave this open for discussion furthermore after new year when everyone is back

Concern here: there used to be issues with the use of eps in differentiability debugging before

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.

2 participants