-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Choi representation #4132
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
Choi representation #4132
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like we may be able to use this to speed up density matrix simulations, since (if I'm reading this correctly) the current implementation must apply each Kraus operator to the state independently.
@95-martin-orion Each way of representing a channel has its own way of applying it to a density matrix and it's quite likely their costs are different. Also, the cost depends on the channel, e.g. applying unitary/isometric channels using a Kraus representation is probably fairly fast. Applying a channel using its Choi matrix involves transposing the density matrix, tensoring it with identity, multiplying by the Choi and tracing out the input space. It's not immediately clear that this is cheaper. However, a follow-up PR to this is a matrix representation of a channel (aka "the natural representation" in John Watrous' book). In this representation, applying a channel to a density matrix is just matrix multiplication (though the matrices involved are larger). It's quite possible that this would be the fastest way in the worst case. |
cirq-core/cirq/qis/channels.py
Outdated
def choi(operation: 'protocols.SupportsChannel') -> np.ndarray: | ||
"""Returns the unique Choi matrix associated with a superoperator.""" | ||
ks = protocols.channel(operation) | ||
d = np.prod(ks[0].shape) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we extract a kraus_to_choi here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
cirq-core/cirq/__init__.py
Outdated
@@ -330,6 +330,7 @@ | |||
|
|||
from cirq.qis import ( | |||
bloch_vector_from_state_vector, | |||
choi, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be a more specific name here to avoid future naming conflict? operation_to_choi
or something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, it does appear we might have a protocol named choi
in near future.
This implements a simple utility for computing the Choi matrix of a channel from its Kraus representation.
Choi representation is more compact than Kraus representations and - unlike the Kraus representation - it is unique for every channel, so we can use this to e.g. compare channels.
The PR is a small step towards #3248. In particular, it does not introduce any new protocols. As discussed on the issue, we might at some point want a protocol to enable channel classes to implement something like
__choi__
if there are cases where folks would prefer to specify channels using their Choi matrix rather than the Kraus operators. If we end up doing this, I suppose the protocol will use the utility in this PR to handle channels that provide Kraus operators.