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: QNSPSA with max_evals_grouped exceeding 1 #9182

Merged
merged 2 commits into from
Nov 23, 2022

Conversation

mrossinek
Copy link
Member

Summary

Fixes a bug with QNSPSA when max_evals_grouped exceeds 1

Details and comments

@mrossinek mrossinek added bug Something isn't working stable backport potential The bug might be minimal and/or import enough to be port to stable mod: algorithms Related to the Algorithms module labels Nov 22, 2022
@qiskit-bot
Copy link
Collaborator

Thank you for opening a new pull request.

Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient.

While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone.

One or more of the the following people are requested to review this:

Copy link
Member

@jakelishman jakelishman left a comment

Choose a reason for hiding this comment

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

The logic here all looks correct to me, thanks.

Comment on lines +317 to +321
values_x = np.reshape(values_x, (-1, num_parameters)).tolist()
batch_size_x = len(values_x)

values_y = np.reshape(values_y, (-1, num_parameters)).tolist()
batch_size_y = len(values_y)
Copy link
Member

Choose a reason for hiding this comment

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

Do the primitives not accept Numpy array inputs for parameters? That seems a bit unusual, but this is fine if they don't.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's probably my bad, we used that in the (Sampling)VQE but actually the primitives just need Sequence[Sequence[float]] which should work with 2d numpy arrays 🙂

Copy link
Member

Choose a reason for hiding this comment

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

Numpy arrays aren't technically Sequence because they don't implement the methods index and count - it's an unfortunate implication from the collections.abc module defining explicit mixin methods as part of the interface, and (as far as I know), there's no built-in Python type that implies the existence of the core iterable/sequence methods, but not the ones with generic definitions.

test/python/algorithms/optimizers/test_spsa.py Outdated Show resolved Hide resolved
@coveralls
Copy link

coveralls commented Nov 22, 2022

Pull Request Test Coverage Report for Build 3531644067

  • 6 of 6 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.001%) to 84.221%

Totals Coverage Status
Change from base Build 3530789808: 0.001%
Covered Lines: 62405
Relevant Lines: 74097

💛 - Coveralls

Co-authored-by: Julien Gacon <gaconju@gmail.com>
Copy link
Member

@jakelishman jakelishman left a comment

Choose a reason for hiding this comment

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

Looks good to me, thanks!

@mergify mergify bot merged commit 324c875 into Qiskit:main Nov 23, 2022
mergify bot pushed a commit that referenced this pull request Nov 23, 2022
Co-authored-by: Julien Gacon <gaconju@gmail.com>

Co-authored-by: Julien Gacon <gaconju@gmail.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
(cherry picked from commit 324c875)
@mrossinek mrossinek deleted the qnspsa-batching branch November 23, 2022 13:08
mergify bot added a commit that referenced this pull request Nov 23, 2022
Co-authored-by: Julien Gacon <gaconju@gmail.com>

Co-authored-by: Julien Gacon <gaconju@gmail.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
(cherry picked from commit 324c875)

Co-authored-by: Max Rossmannek <oss@zurich.ibm.com>
Cryoris added a commit to Cryoris/qiskit-terra that referenced this pull request Jan 12, 2023
Co-authored-by: Julien Gacon <gaconju@gmail.com>

Co-authored-by: Julien Gacon <gaconju@gmail.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
ElePT pushed a commit to ElePT/qiskit that referenced this pull request Jun 27, 2023
Co-authored-by: Julien Gacon <gaconju@gmail.com>

Co-authored-by: Julien Gacon <gaconju@gmail.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
ElePT pushed a commit to ElePT/qiskit-algorithms-test that referenced this pull request Jul 17, 2023
Co-authored-by: Julien Gacon <gaconju@gmail.com>

Co-authored-by: Julien Gacon <gaconju@gmail.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working mod: algorithms Related to the Algorithms module stable backport potential The bug might be minimal and/or import enough to be port to stable
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants