Skip to content
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

Compute a Kraus representation from the Choi matrix #4549

Merged
merged 5 commits into from Oct 5, 2021

Conversation

viathor
Copy link
Collaborator

@viathor viathor commented Oct 4, 2021

The new cirq.choi_to_kraus function is like the existing cirq.kraus_to_choi but in the opposite direction.

Note that the former chooses one of many admissible Kraus representations while the latter maps all valid Kraus representations to the Choi. Therefore, cirq.kraus_to_choi(cirq.choi_to_kraus(c)) == c, but it is not necessarily the case that cirq.choi_to_kraus(cirq.kraus_to_choi(ks)) == ks. Check out section and retraction if you like this sort of thing.

Example future use-cases: channel comparisons, obtaining Kraus representation of a noisy circuit.

Some context: #3248.

@viathor viathor requested review from cduck, vtomole and a team as code owners October 4, 2021 21:24
@google-cla google-cla bot added the cla: yes Makes googlebot stop complaining. label Oct 4, 2021
@CirqBot CirqBot added the size: M 50< lines changed <250 label Oct 4, 2021
Copy link
Collaborator

@mpharrigan mpharrigan left a comment

Choose a reason for hiding this comment

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

LGTM after responding to questions

if choi.shape != (d * d, d * d):
raise ValueError(f"Invalid Choi matrix shape, expected {(d * d, d * d)}, got {choi.shape}")
if not np.allclose(choi, choi.T.conj()):
raise ValueError("Choi matrix must be Hermitian")
Copy link
Collaborator

Choose a reason for hiding this comment

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

atol?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

if not np.allclose(choi, choi.T.conj()):
raise ValueError("Choi matrix must be Hermitian")

w, v = np.linalg.eig(choi)
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we use eigh here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good catch! Done.

@viathor viathor merged commit 02b4658 into quantumlib:master Oct 5, 2021
@viathor viathor deleted the choi_to_kraus branch October 5, 2021 01:51
rht pushed a commit to rht/Cirq that referenced this pull request May 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Makes googlebot stop complaining. size: M 50< lines changed <250
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants