Cirq icon indicating copy to clipboard operation
Cirq copied to clipboard

Channel testing utilities

Open viathor opened this issue 5 years ago • 2 comments

Is your feature request related to a use case or problem? Please describe.

Elementary objects in cirq (e.g. quantum gates) are represented as classes with overspecified properties. In other words, they directly provide information that can be computed from other information already available. For example, a quantum gate may provide an implementation of _apply_unitary_ as well as _unitary_ and/or _decompose_. At the same time, we ensure consistency of this information using a number of utilities implemented in cirq.testing. This is a nice approach as it shifts the cost of computation from the user to testing.

With the addition of superoperator and Choi representations of channels to cirq, we will soon have redundant specifications of channels. This calls for suitable consistency checks to be implemented in cirq.testing.

Describe the solution you'd like

We should check that for each channel Kraus, Choi and superoperator representations describe the same channel. We should also implement consistency checks between existing channel-related protocols unitary, kraus and mixture. In addition, the new testing utilities could verify other related properties such as:

  • all unital single-qubit channels have a mixture representation (which would have prevented #4578),
  • all Kraus representations are minimal (i.e. return the number of Kraus operators equal to the rank of the Choi matrix).

[optional] Describe alternatives/workarounds you've considered

[optional] Additional context (e.g. screenshots)

What is the urgency from your perspective for this issue? Is it blocking important work?

P3 - I'm not really blocked by it, it is an idea I'd like to discuss / suggestion based on principle

viathor avatar Oct 15 '21 18:10 viathor

The utilities should also validate the behavior of _has_*_ methods.

viathor avatar Dec 08 '21 02:12 viathor

Hi, I'd like to work on this if it's still wanted. I'd keep the first PR small: a helper in cirq.testing that checks the Kraus, Choi and superoperator representations of a channel describe the same map, and also checks that the _has_*_ methods agree with what the protocols actually return. Then I'd run it over the built-in channels. The unital single-qubit mixture check and the minimal Kraus check could follow in a separate PR.

Does that split sound okay?

Tejendra-06 avatar Oct 07 '26 18:10 Tejendra-06