Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Applying a slight perturbation for ill-conditioned matrices (backport #13882) #13889

Merged
merged 1 commit into from
Feb 19, 2025

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Feb 19, 2025

Summary

Fix two failing tests for the 1.3.3 release:
test.python.quantum_info.operators.channel.test_kraus.TestKraus.test_circuit_init + one other very similar test.

The problem only occurs on aarch64 (arm linux), however the relevant matrix is ill-conditioned on my mac as well: the choi matrix has many eigenvalues that are negative and close to 0 (the "negative" is likely due to numerical imprecision errors), with the numpy.linalg.cond returning np.inf.

By doing a search on the internet, one of the recommended techniques is to apply regularization, in this case adding a small perturbation to the matrix. Update: as per @jakelishman's suggestion, we can in fact perfectly recover the eigenvalues of the original matrix from the matrix with the perturbation.


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

* Applying a slight perturbation for ill-conditioned matrices

* Further improving the fix based on discussion with Jake and Gadi, and adding bugfix release note

* Jake's suggestion from code review

(cherry picked from commit 69eb2aa)
@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:

  • @Qiskit/terra-core

@jakelishman jakelishman added the Changelog: Bugfix Include in the "Fixed" section of the changelog label Feb 19, 2025
@coveralls
Copy link

Pull Request Test Coverage Report for Build 13416331205

Details

  • 5 of 5 (100.0%) changed or added relevant lines in 1 file are covered.
  • 4 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.002%) to 88.103%

Files with Coverage Reduction New Missed Lines %
crates/qasm2/src/expr.rs 1 94.23%
crates/qasm2/src/lex.rs 3 92.48%
Totals Coverage Status
Change from base Build 13411473274: 0.002%
Covered Lines: 78354
Relevant Lines: 88935

💛 - Coveralls

@jakelishman jakelishman added this pull request to the merge queue Feb 19, 2025
Merged via the queue into main with commit 55c7904 Feb 19, 2025
21 checks passed
@mtreinish mtreinish deleted the mergify/bp/main/pr-13882 branch February 19, 2025 20:57
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Changelog: Bugfix Include in the "Fixed" section of the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants