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

Fix zero-jvps with shot vectors #6219

Merged
merged 9 commits into from
Sep 10, 2024
Merged

Fix zero-jvps with shot vectors #6219

merged 9 commits into from
Sep 10, 2024

Conversation

dwierichs
Copy link
Contributor

@dwierichs dwierichs commented Sep 5, 2024

Context:
If a tape has no trainable parameters, generic zero-valued JVPs are created for it in JVP calculations.
However, these generic calculations are not taking shot vectors correctly into account, also because they do not use MeasurementProcess.shape correctly.

Description of the Change:
Change the generic zero-valued JVPs so they are compatible with shot vectors.

Benefits:
One bug less.

Possible Drawbacks:
N/A

Related GitHub Issues:
Fixes #6220

Related Shortcut Stories:
[sc-73033]

@dwierichs dwierichs marked this pull request as ready for review September 5, 2024 17:35
@dwierichs dwierichs requested a review from astralcai September 5, 2024 17:46
Copy link
Contributor

@astralcai astralcai left a comment

Choose a reason for hiding this comment

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

LGTM, thank you for fixing this!

Copy link

codecov bot commented Sep 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.63%. Comparing base (38ee38e) to head (1bf10f0).
Report is 338 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #6219   +/-   ##
=======================================
  Coverage   99.63%   99.63%           
=======================================
  Files         445      445           
  Lines       42411    42417    +6     
=======================================
+ Hits        42255    42261    +6     
  Misses        156      156           

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

pennylane/gradients/jvp.py Outdated Show resolved Hide resolved
pennylane/gradients/jvp.py Outdated Show resolved Hide resolved
@dwierichs dwierichs requested a review from albi3ro September 9, 2024 10:28
@dwierichs dwierichs enabled auto-merge (squash) September 10, 2024 07:32
@dwierichs dwierichs merged commit b0a9c61 into master Sep 10, 2024
37 checks passed
@dwierichs dwierichs deleted the fix-jvp-shots branch September 10, 2024 07:49
mudit2812 pushed a commit that referenced this pull request Sep 10, 2024
**Context:**
If a tape has no trainable parameters, generic zero-valued JVPs are
created for it in JVP calculations.
However, these generic calculations are not taking shot vectors
correctly into account, also because they do not use
`MeasurementProcess.shape` correctly.

**Description of the Change:**
Change the generic zero-valued JVPs so they are compatible with shot
vectors.

**Benefits:**
One bug less.

**Possible Drawbacks:**
N/A

**Related GitHub Issues:**
Fixes #6220 

[sc-73033]

---------

Co-authored-by: Christina Lee <[email protected]>
mudit2812 pushed a commit that referenced this pull request Sep 12, 2024
**Context:**
If a tape has no trainable parameters, generic zero-valued JVPs are
created for it in JVP calculations.
However, these generic calculations are not taking shot vectors
correctly into account, also because they do not use
`MeasurementProcess.shape` correctly.

**Description of the Change:**
Change the generic zero-valued JVPs so they are compatible with shot
vectors.

**Benefits:**
One bug less.

**Possible Drawbacks:**
N/A

**Related GitHub Issues:**
Fixes #6220 

[sc-73033]

---------

Co-authored-by: Christina Lee <[email protected]>
mudit2812 pushed a commit that referenced this pull request Sep 16, 2024
**Context:**
If a tape has no trainable parameters, generic zero-valued JVPs are
created for it in JVP calculations.
However, these generic calculations are not taking shot vectors
correctly into account, also because they do not use
`MeasurementProcess.shape` correctly.

**Description of the Change:**
Change the generic zero-valued JVPs so they are compatible with shot
vectors.

**Benefits:**
One bug less.

**Possible Drawbacks:**
N/A

**Related GitHub Issues:**
Fixes #6220 

[sc-73033]

---------

Co-authored-by: Christina Lee <[email protected]>
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.

[BUG] Zero-valued JVPs of gradient-free tapes with shot vectors have the wrong shape
3 participants