Skip to content

Conversation

wshanks
Copy link
Contributor

@wshanks wshanks 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).

@wshanks wshanks requested a review from a team as a code owner June 12, 2025 16:46
@wshanks wshanks 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
@qiskit-bot
Copy link
Collaborator

One or more of the following people are relevant to this code:

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

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).
@coveralls
Copy link

coveralls commented Jun 12, 2025

Pull Request Test Coverage Report for Build 15617205136

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 2 of 2 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall first build on qv-rng at 87.979%

Totals Coverage Status
Change from base Build 15607698218: 88.0%
Covered Lines: 83132
Relevant Lines: 94491

💛 - Coveralls

@mtreinish mtreinish added the stable backport potential The bug might be minimal and/or import enough to be port to stable label Jun 12, 2025
@mtreinish mtreinish added this to the 1.4.4 milestone Jun 12, 2025
@mtreinish
Copy link
Member

@Mergifyio backport stable/1.4 stable/2.0 stable/2.1

Copy link
Contributor

mergify bot commented Jun 12, 2025

backport stable/1.4 stable/2.0 stable/2.1

✅ Backports have been created

Copy link
Member

@mtreinish mtreinish left a comment

Choose a reason for hiding this comment

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

LGTM, this is a straightforward fix thanks for catching and fixing this

@mtreinish mtreinish added this pull request to the merge queue Jun 12, 2025
Merged via the queue into Qiskit:main with commit ba74b5c Jun 12, 2025
27 checks passed
mergify bot pushed a commit that referenced this pull request Jun 12, 2025
* 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)
mergify bot pushed a commit that referenced this pull request Jun 12, 2025
* 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)
mergify bot pushed a commit that referenced this pull request Jun 12, 2025
* 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)
github-merge-queue bot pushed a commit that referenced this pull request Jun 13, 2025
…#14592)

* 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)

Co-authored-by: Will Shanks <willshanks@us.ibm.com>
github-merge-queue bot pushed a commit that referenced this pull request Jun 13, 2025
…#14591)

* 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)

Co-authored-by: Will Shanks <willshanks@us.ibm.com>
github-merge-queue bot pushed a commit that referenced this pull request Jun 13, 2025
…#14590)

* 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)

Co-authored-by: Will Shanks <willshanks@us.ibm.com>
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 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.

4 participants