-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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 bug in backend primitives with bound_pass_manager
#9629
Conversation
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:
|
Pull Request Test Coverage Report for Build 4263458829
💛 - Coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great catch. I did not know this spec of pass manager. LGTM if a test is passed.
with self.assertLogs(logger, level="INFO") as cm: | ||
_ = estimator.run(qc, op).result() | ||
expected = ["bound_pass_manager"] | ||
self.assertEqual([record.message for record in cm.records], expected) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it better to access cm
within the with
block?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure of what the implications are, but just in case I moved it inside the with
block :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering whether cm
is valid after the with-statement because cm.__exit__
is called. If you are sure that cm
is valid after the with-statement, I'm fine with the original code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
* Fix pass, add unit test * Fix black * Fix lint * Fix tests * Add reno * Move assert to within cm * black --------- Co-authored-by: ikkoham <ikkoham@users.noreply.github.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> (cherry picked from commit 05310bd)
* Fix pass, add unit test * Fix black * Fix lint * Fix tests * Add reno * Move assert to within cm * black --------- Co-authored-by: ikkoham <ikkoham@users.noreply.github.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> (cherry picked from commit 05310bd) Co-authored-by: ElePT <57907331+ElePT@users.noreply.github.com>
Summary
While working on the quantum instance migration guide, I noticed that setting a custom
bound_pass_manager
on theBackendSampler
would make it fail withValueError: Inconsistent number of experiments across data fields
, only when running single circuits (with circuit batches, there would be no error).I traced this back to the
_bound_pass_manager_run
, which was not casting its output to alist
in the case of single circuits.This PR fixes this issue in both
BackendSampler
andBackendEstimator
and adds the corresponding unit tests to check that the transpiler passes are running and no errors are raised.Details and comments
To reproduce the original error, revert the changes on
BackendSampler
and run the proposed unit test.