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

ExpvalCost when optimize=True with shots batch #1897

Merged
merged 7 commits into from
Nov 16, 2021
Merged

Conversation

rmoyard
Copy link
Contributor

@rmoyard rmoyard commented Nov 15, 2021

Context:
ExpvalCost returns wrong values when optimize=True because of the shape of results due to shots (e.g (8000,5)).

Description of the Change:
Change the function to take into account the shape of the results.

Benefits:
It now returns the correct values.

Related GitHub Issues:
Closes #1480

@github-actions
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.

@rmoyard rmoyard requested a review from dime10 November 15, 2021 22:45
@codecov
Copy link

codecov bot commented Nov 15, 2021

Codecov Report

Merging #1897 (457a917) into master (ec0b048) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1897   +/-   ##
=======================================
  Coverage   98.98%   98.98%           
=======================================
  Files         219      219           
  Lines       16555    16564    +9     
=======================================
+ Hits        16387    16396    +9     
  Misses        168      168           
Impacted Files Coverage Δ
pennylane/vqe/vqe.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ec0b048...457a917. Read the comment docs.

Copy link
Contributor

@dime10 dime10 left a comment

Choose a reason for hiding this comment

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

Thanks @rmoyard, this looks good to me!

tests/test_vqe.py Show resolved Hide resolved
@rmoyard rmoyard merged commit e3ff42d into master Nov 16, 2021
@rmoyard rmoyard deleted the expval_cost_shots branch November 16, 2021 19:35
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] Incorrect shot batching behaviour in ExpvalCost when optimize=True
2 participants