Applying a slight perturbation for ill-conditioned matrices (backport #13882) #13889
+20
−0
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
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
returningnp.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).