quantumlib / Cirq

A Python framework for creating, editing, and invoking Noisy Intermediate Scale Quantum (NISQ) circuits.
Apache License 2.0
4.28k stars 1.02k forks source link

Channel testing utilities #4579

Open viathor opened 3 years ago

viathor commented 3 years ago

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:

[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 commented 2 years ago

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