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

Channel matrix #4146

Merged
merged 9 commits into from
Jun 2, 2021
Merged

Channel matrix #4146

merged 9 commits into from
Jun 2, 2021

Conversation

viathor
Copy link
Collaborator

@viathor viathor commented May 27, 2021

Utility for computing perhaps the most obvious representation of quantum channels: as a matrix.

This representation allows channel application via simple matrix multiplication (where input and output density operators are vectorized) and efficient computation of entanglement fidelity (follow-up).

@viathor viathor requested review from cduck, vtomole and a team as code owners May 27, 2021 22:54
@viathor viathor requested a review from dstrain115 May 27, 2021 22:54
@google-cla google-cla bot added the cla: yes Makes googlebot stop complaining. label May 27, 2021
Copy link
Collaborator

@95-martin-orion 95-martin-orion left a comment

Choose a reason for hiding this comment

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

One formatting comment before diving into implementation.


@pytest.mark.parametrize(
'kraus_operators, expected_channel_matrix',
(
Copy link
Collaborator

Choose a reason for hiding this comment

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

It looks like these parameterizations are reused across tests. Could you define constants for them?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Most of the repeated constants were the Kraus operators of the completely depolarizing channel. I changed the code to use a short cirq expression to generate those instead of hardcoding. I also changed Kraus operators in another test case. The remaining constants are either different or very short (e.g. np.eye(2)). This cuts away almost all duplication (the Choi and channel matrices were of course different all along) while keeping all inputs local so the reader does not need to scroll to examine correctness.

Copy link
Collaborator

@95-martin-orion 95-martin-orion left a comment

Choose a reason for hiding this comment

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

No implementation worries, but one more formatting comment on the tests.

),
),
)
def test_kraus_to_channel_matrix(kraus_operators, expected_channel_matrix):
Copy link
Collaborator

Choose a reason for hiding this comment

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

To avoid confusion, expected_channel_matrix should not be reused here since it's already the name of a function in this file.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Renamed functions to use verbs in the name.

@viathor viathor merged commit 7065c6d into quantumlib:master Jun 2, 2021
@viathor viathor deleted the channel_matrix branch June 2, 2021 20:01
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants