Skip to content

Add is_cptp predicate #4365

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

Merged
merged 4 commits into from
Jul 29, 2021
Merged

Add is_cptp predicate #4365

merged 4 commits into from
Jul 29, 2021

Conversation

95-martin-orion
Copy link
Collaborator

As requested in #4194. Can be used for #2271.

This predicate is meant to be invoked when constructing a channel to verify that the provided Kraus operators actually describe a valid quantum channel. Recommendations for cleaner is_cptp behavior or additional test cases are welcome.

@95-martin-orion 95-martin-orion requested review from cduck, vtomole and a team as code owners July 29, 2021 16:36
@google-cla google-cla bot added the cla: yes Makes googlebot stop complaining. label Jul 29, 2021
Copy link
Collaborator

@MichaelBroughton MichaelBroughton left a comment

Choose a reason for hiding this comment

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

Looks good. The only thing I would change is in the test if we could try and cut out the dependency on other library pieces if we can. Also might be useful:

A random set of kraus operators can be made by doing (Totally untested :P):

one_qubit_u = cirq.testing.random_unitary(8)
one_qubit_kraus = np.reshape(one_qubit_u[:, :2], (-1, 2, 2))  # make 4 2x2 kraus ops.

or

two_qubit_u = cirq.testing.random_unitary(64)
two_qubit_kraaus = np.reshape(two_qubit_u[:, :4], (-1, 4, 4))  # make 16 4x4 kraus ops.

@@ -149,6 +149,21 @@ def is_normal(matrix: np.ndarray, *, rtol: float = 1e-5, atol: float = 1e-8) ->
return matrix_commutes(matrix, matrix.T.conj(), rtol=rtol, atol=atol)


def is_cptp(kraus_ops: Sequence[np.ndarray], *, rtol: float = 1e-5, atol: float = 1e-8):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do people like @viathor or @Strilanc have any strong opinions on whether we should try to support kraus ops and choi or other things one could use to specify a map ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If we'd like to add such support, I recommend we make a note of it in #2271 and follow up later. AFAIK there's no Choi / superoperator equivalent of #4194 in the works yet, but it would be good to have this if and when that appears.

Copy link
Contributor

Choose a reason for hiding this comment

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

A reasonable way to ensure this is forward compatible with changing that choice is to force keyword args for kraus_ops. We can weaken it later that way if we decide to stick with it, or add other args if we want to extend.

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 point - moved kraus_ops into kwargs.

@95-martin-orion
Copy link
Collaborator Author

Added the recommended random tests.

Copy link
Collaborator

@MichaelBroughton MichaelBroughton left a comment

Choose a reason for hiding this comment

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

LGTM

@MichaelBroughton MichaelBroughton added the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Jul 29, 2021
@CirqBot CirqBot added the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Jul 29, 2021
@CirqBot CirqBot merged commit 9467ad3 into quantumlib:master Jul 29, 2021
@CirqBot CirqBot removed automerge Tells CirqBot to sync and merge this PR. (If it's running.) front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. labels Jul 29, 2021
@95-martin-orion 95-martin-orion deleted the cirq-cptp branch July 29, 2021 21:36
rht pushed a commit to rht/Cirq that referenced this pull request May 1, 2023
As requested in quantumlib#4194. Can be used for quantumlib#2271.

This predicate is meant to be invoked when constructing a channel to verify that the provided Kraus operators actually describe a valid quantum channel. Recommendations for cleaner `is_cptp` behavior or additional test cases are welcome.
harry-phasecraft pushed a commit to PhaseCraft/Cirq that referenced this pull request Oct 31, 2024
As requested in quantumlib#4194. Can be used for quantumlib#2271.

This predicate is meant to be invoked when constructing a channel to verify that the provided Kraus operators actually describe a valid quantum channel. Recommendations for cleaner `is_cptp` behavior or additional test cases are welcome.
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.

4 participants