sandialabs / pyGSTi

A python implementation of Gate Set Tomography
http://www.pygsti.info
Apache License 2.0
132 stars 55 forks source link

Bugfix kraus decomp with degeneracies #422

Closed enielse closed 2 months ago

enielse commented 2 months ago

Fixes a bug in DenseOperator.kraus_operators when Choi matrix has degenerate spectrum.

Switches a numpy.linalg.eig call to numpy.linalg.eigh to ensure that the matrix of eigenvectors is unitary. This is not always the case for eig (in particular for matrices with degenerate spectra), and is assumed by the code in kraus_operators. The eig routine has had a history of not always giving a correct diagonalization, and so this PR also adds an assertion to ensure this is the case.

Also adds a unit test that verifies Kraus decomposition works as expected for a depolarizing channel (one example of a channel with a degenerate Choi matrix spectrum).

rileyjmurray commented 2 months ago

@enielse, this PR initially had pygsti's master branch as the target. This made it look like your changes were much farther reaching than they actually are, and that caused GitHub to unnecessarily add a bunch of people as required PR reviewers. You should probably close this PR and open a new PR that targets develop (rather than master) from the beginning.

enielse commented 2 months ago

Ah, thanks Riley -- I must have missed that. I'll close this and reopen another.