-
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
Assert properties not specifics of DenseLayout
results
#10901
Merged
jakelishman
merged 1 commit into
Qiskit:main
from
jakelishman:dense-layout-stable-tests
Sep 27, 2023
Merged
Assert properties not specifics of DenseLayout
results
#10901
jakelishman
merged 1 commit into
Qiskit:main
from
jakelishman:dense-layout-stable-tests
Sep 27, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
`DenseLayout` is a deterministic pass, so there's no risk of RNG manipulations changing the output. Internally, however, the use of the sparse-matrix bandwidth-reduction algorithm in Scipy's `reverse_cuthill_mckee` uses `numpy.argsort` internally with the unstable default sorting algorithm, which means the output _can_ be dependent on the way that sort is implemented. The arrays that are sorted are directly related to the input coupling map, and are likely to include degeneracies, which pose problems when the implementation of the unstable sort changes. This was the case moving from Numpy 1.24 to Numpy 1.25. This commit instead changes the tests from asserting that a precise layout was returned to asserting that the returned layout contains only a connected subgraph of qubits. The "most" connected component that `DenseLayout` finds must be _at least_ connected, though this assertion is not quite as strong as finding the _densest_. The extra test accounts for this weakening.
jakelishman
added
type: qa
Issues and PRs that relate to testing and code quality
stable backport potential
The bug might be minimal and/or import enough to be port to stable
Changelog: None
Do not include in changelog
labels
Sep 26, 2023
One or more of the the following people are requested to review this:
|
kdk
approved these changes
Sep 27, 2023
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.
This approach LGTM.
mergify bot
pushed a commit
that referenced
this pull request
Sep 27, 2023
`DenseLayout` is a deterministic pass, so there's no risk of RNG manipulations changing the output. Internally, however, the use of the sparse-matrix bandwidth-reduction algorithm in Scipy's `reverse_cuthill_mckee` uses `numpy.argsort` internally with the unstable default sorting algorithm, which means the output _can_ be dependent on the way that sort is implemented. The arrays that are sorted are directly related to the input coupling map, and are likely to include degeneracies, which pose problems when the implementation of the unstable sort changes. This was the case moving from Numpy 1.24 to Numpy 1.25. This commit instead changes the tests from asserting that a precise layout was returned to asserting that the returned layout contains only a connected subgraph of qubits. The "most" connected component that `DenseLayout` finds must be _at least_ connected, though this assertion is not quite as strong as finding the _densest_. The extra test accounts for this weakening. (cherry picked from commit 0f66cdf)
github-merge-queue bot
pushed a commit
that referenced
this pull request
Sep 29, 2023
…0901) (#10907) * Assert properties not specifics of `DenseLayout` results (#10901) `DenseLayout` is a deterministic pass, so there's no risk of RNG manipulations changing the output. Internally, however, the use of the sparse-matrix bandwidth-reduction algorithm in Scipy's `reverse_cuthill_mckee` uses `numpy.argsort` internally with the unstable default sorting algorithm, which means the output _can_ be dependent on the way that sort is implemented. The arrays that are sorted are directly related to the input coupling map, and are likely to include degeneracies, which pose problems when the implementation of the unstable sort changes. This was the case moving from Numpy 1.24 to Numpy 1.25. This commit instead changes the tests from asserting that a precise layout was returned to asserting that the returned layout contains only a connected subgraph of qubits. The "most" connected component that `DenseLayout` finds must be _at least_ connected, though this assertion is not quite as strong as finding the _densest_. The extra test accounts for this weakening. (cherry picked from commit 0f66cdf) * Avoid use of un-backported kwarg * Update test/python/transpiler/test_dense_layout.py --------- Co-authored-by: Jake Lishman <[email protected]>
rupeshknn
pushed a commit
to rupeshknn/qiskit
that referenced
this pull request
Oct 9, 2023
`DenseLayout` is a deterministic pass, so there's no risk of RNG manipulations changing the output. Internally, however, the use of the sparse-matrix bandwidth-reduction algorithm in Scipy's `reverse_cuthill_mckee` uses `numpy.argsort` internally with the unstable default sorting algorithm, which means the output _can_ be dependent on the way that sort is implemented. The arrays that are sorted are directly related to the input coupling map, and are likely to include degeneracies, which pose problems when the implementation of the unstable sort changes. This was the case moving from Numpy 1.24 to Numpy 1.25. This commit instead changes the tests from asserting that a precise layout was returned to asserting that the returned layout contains only a connected subgraph of qubits. The "most" connected component that `DenseLayout` finds must be _at least_ connected, though this assertion is not quite as strong as finding the _densest_. The extra test accounts for this weakening.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Changelog: None
Do not include in changelog
stable backport potential
The bug might be minimal and/or import enough to be port to stable
type: qa
Issues and PRs that relate to testing and code quality
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
DenseLayout
is a deterministic pass, so there's no risk of RNG manipulations changing the output. Internally, however, the use of the sparse-matrix bandwidth-reduction algorithm in Scipy'sreverse_cuthill_mckee
usesnumpy.argsort
internally with the unstable default sorting algorithm, which means the output can be dependent on the way that sort is implemented. The arrays that are sorted are directly related to the input coupling map, and are likely to include degeneracies, which pose problems when the implementation of the unstable sort changes. This was the case moving from Numpy 1.24 to Numpy 1.25.This commit instead changes the tests from asserting that a precise layout was returned to asserting that the returned layout contains only a connected subgraph of qubits. The "most" connected component that
DenseLayout
finds must be at least connected, though this assertion is not quite as strong as finding the densest. The extra test accounts for this weakening.Details and comments
This is another case where our tests were incompatible with Numpy 1.25+ (see #10305), and a simpler one to fix than the others noted in that issue; it's not an unsoundness of the library, just a sort-method instability that we can make the tests more resilient against.