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

[sc-69429] SPSA keyword argument bug fix #6027

Merged
merged 8 commits into from
Jul 23, 2024
Merged

Conversation

isaacdevlugt
Copy link
Contributor

@isaacdevlugt isaacdevlugt commented Jul 22, 2024

Context: SPSAOptimizer's step_and_cost method was ignoring keyword arguments in the objective function.

Description of the Change: SPSAOptimizer.step_and_cost no longer ignores kwargs.

Benefits: Your keyword arguments are heard <3

Possible Drawbacks: None

Related github issue: #6028

Copy link
Contributor

@Shiro-Raven Shiro-Raven left a comment

Choose a reason for hiding this comment

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

Is there a reason why no tests are added to address this fix? Was a test failing before? Or an issue that brought attention to this bug?

Copy link
Contributor

@dwierichs dwierichs left a comment

Choose a reason for hiding this comment

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

Thanks for the quick fix, @isaacdevlugt ! 🎉
I am wondering whether the function evaluation that needed fixing actually is required, or whether we can get the output shape from the evaluations we are doing anyways? And it might be nice to have a test that catches this bug, i.e. fails on current master.

pennylane/optimize/spsa.py Show resolved Hide resolved
tests/optimize/test_spsa.py Show resolved Hide resolved
Copy link

codecov bot commented Jul 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.65%. Comparing base (3ad15d7) to head (9c1bedb).
Report is 4 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6027      +/-   ##
==========================================
- Coverage   99.66%   99.65%   -0.01%     
==========================================
  Files         427      427              
  Lines       41057    40764     -293     
==========================================
- Hits        40919    40624     -295     
- Misses        138      140       +2     

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

@isaacdevlugt isaacdevlugt changed the title SPSA keyword argument bug fix [sc-69429] SPSA keyword argument bug fix Jul 22, 2024
Copy link
Contributor

@dwierichs dwierichs left a comment

Choose a reason for hiding this comment

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

Could continue discussing the necessity for the extra evaluation for extracting the shape, but as this is not the purpose of the PR, also good to merge without addressing it for now.
Thanks!

pennylane/optimize/spsa.py Show resolved Hide resolved
tests/optimize/test_spsa.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.

Looks great! Thanks for working on this

@isaacdevlugt isaacdevlugt enabled auto-merge (squash) July 23, 2024 14:28
@isaacdevlugt isaacdevlugt merged commit f454f59 into master Jul 23, 2024
40 checks passed
@isaacdevlugt isaacdevlugt deleted the spsa-kwarg-bug branch July 23, 2024 17:09
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.

4 participants