Skip to content

Fix random number generator seed argument for quantum_volume (backport #14586) #14591

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

Merged
merged 1 commit into from
Jun 13, 2025

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Jun 12, 2025

The seed argument to quantum_volume being a numpy.random.Generator resulted in integers being called with 0 for the low argument. When called with only a low argument like this, this value is taken as one more than the maximum and 0 is treated as the minimum. This resulted in a TypeError because the range is from 0 to -1. Here the handling of Generator was updated to match how the deprecated QuantumVolume class handled seed (which was slightly odd -- it caps the range at the int64 limit even though the argument is a u64 in the Rust function -- but probably fine; keeping the range helps keep the behavior consistent between QuantumVolume and quantum_volume for a generator with the same seed).


This is an automatic backport of pull request #14586 done by [Mergify](https://mergify.com).

* Fix random number generator seed argument for quantum_volume

The `seed` argument to `quantum_volume` being a `numpy.random.Generator`
resulted in `integers` being called with 0 for the `low` argument. When
called with only a `low` argument like this, this value is taken as one
more than the maximum and 0 is treated as the minimum. This resulted in a
`TypeError` because the range is from 0 to -1. Here the handling of
`Generator` was updated to match how the deprecated `QuantumVolume`
class handled `seed` (which was slightly odd -- it caps the range at the
int64 limit even though the argument is a `u64` in the Rust function --
but probably fine; keeping the range helps keep the behavior consistent
between `QuantumVolume` and `quantum_volume` for a generator with the
same seed).

* Address pylint's misunderstanding of the test import

(cherry picked from commit ba74b5c)
@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 following people are relevant to this code:

  • @Cryoris
  • @Qiskit/terra-core
  • @ajavadia

@github-actions github-actions bot added Changelog: Bugfix Include in the "Fixed" section of the changelog mod: circuit Related to the core of the `QuantumCircuit` class or the circuit library labels Jun 12, 2025
@github-actions github-actions bot added this to the 1.4.4 milestone Jun 12, 2025
@coveralls
Copy link

Pull Request Test Coverage Report for Build 15621930851

Details

  • 2 of 2 (100.0%) changed or added relevant lines in 1 file are covered.
  • 7 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.01%) to 88.144%

Files with Coverage Reduction New Missed Lines %
crates/accelerate/src/unitary_synthesis.rs 1 94.81%
crates/qasm2/src/lex.rs 6 92.23%
Totals Coverage Status
Change from base Build 15609988797: 0.01%
Covered Lines: 72965
Relevant Lines: 82779

💛 - Coveralls

@ElePT ElePT added this pull request to the merge queue Jun 13, 2025
Merged via the queue into stable/2.0 with commit 7e96e33 Jun 13, 2025
27 checks passed
@ElePT ElePT deleted the mergify/bp/stable/2.0/pr-14586 branch June 13, 2025 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: Bugfix Include in the "Fixed" section of the changelog mod: circuit Related to the core of the `QuantumCircuit` class or the circuit library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants