quantumlib / Cirq

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

Distance measures for quantum states #2763

Open mpharrigan opened 4 years ago

mpharrigan commented 4 years ago
viathor commented 4 years ago

Well, trace distance, of course.

Regarding other distance measures to consider, it is surprisingly easy for them to proliferate. Given a distance measure on quantum states you can define a distance measure on quantum operations by:

  1. Applying the former to the (trace-normalized) process matrices.
  2. Computing the average over input states.
  3. Computing the maximum over input states.

The latter has some cool properties, but is not invariant under tensoring with the identity. The problem can be remedied by a small tweak to the definition (first tensor with the identity on a sufficiently large Hilbert space, then compute maximum).

Now, the diamond norm is the distance measure for quantum processes obtained by applying maximization over input states (with the above tweak) to the trace distance. You can apply the same procedure to other distance measures. At least one of them is actually interesting and that is when you apply minimization over input states (again, with the above tweak) to the fidelity. I don't think this has an established name. I certainly haven't seen anyone refer to this as "diamond fidelity". I have seen it called "stabilized fidelity" or "S fidelity".

Also, since you've included purity, which is not a distance measure, we may consider normalized linear entropy, tangle, Schmidt rank, von Neumann entropy and maybe other measures of entanglement.

So, there is potentially a lot of stuff to do here. However, there are reasons for parsimony. If anything the field suffers from too many rather than too few distance measures and people came up with well-justified recommendations to settle on. We should probably endorse one (or few) of those and stick to them. Moreover, some of distance measures one can find in the literature (e.g. the Bures metric) are simple functions of the fidelity anyway so users who really need them can very easily compute them from the fidelity (trace distance is an exception).

Also, regarding distance measures for operations, not every combination of procedures 1-3 above and a distance measure for quantum states yields a reasonable distance measure for quantum operations. Process fidelity and diamond norm SGTM. Process trace distance and the S fidelity may be reasonable additions. And we should probably stop there.

Regarding measures of entanglement, many of them are NP-hard to compute.

viathor commented 4 years ago

There is another, related concern that came up in a discussion I had with @maffoo. We probably want to avoid developing and maintaining a full quantum information package inside cirq. Many such packages already exist, e.g. qiskit and qutip and have a lot more functionality than we are unlikely to build. Rather than writing our own, we may want to consider partnering with an existing project and ensuring easy interoperability.

@dabacon @Strilanc

mpharrigan commented 4 years ago

Love the idea of interop. qiskit and qutip are good, but would each be a very heavy dependency. If we can figure out a way to highlight the quantum information parts, that would be very cool

viathor commented 4 years ago

I have quickly skimmed the two packages. They both provide a ton of cool functionality. Here are two short snippets showing the computation of fidelity of two pure states:

qutip:

import qutip

q_0 = qutip.basis(2, 0)
q_1 = qutip.basis(2, 1)
q_plus = (q_0 + q_1).unit()

f = qutip.metrics.fidelity(q_1, q_plus)
print(f)

output: 0.7071067811865475

qiskit:

import numpy as np
import qiskit.quantum_info as qi

q_0 = np.array([1, 0])
q_1 = np.array([0, 1])
q_plus = np.array([1, 1]) / np.sqrt(2)

f = qi.state_fidelity(q_0, q_plus)
print(f)

output: 0.4999999999999999

Two notable differences:


[1]: Assuming one state is pure. [2]: See paragraph beginning with "Nevertheless..." on p.4 in https://arxiv.org/pdf/quant-ph/0408063.pdf for one recommendation against Mike&Ike's convention.

kevinsung commented 4 years ago

See https://github.com/quantumlib/Cirq/pull/2797#issuecomment-593767332 for an example of how Qiskit's implementation of fidelity is much slower than an alternative. If we implement a few core functions ourselves, we can be sure that they are as efficient as possible. Just a few core functions would not take much work to maintain, either.

vtomole commented 4 years ago

Rolling our own ~10 procedures from https://qiskit.org/documentation/apidoc/quantum_info.html shouldn't be a huge burden when it comes to maintenance. I vote for wheel re-inventing in this case.

tonybruguier-google commented 4 years ago

Hello, Is more work needed for this issue? Is this a good reference for the diamond norm? https://arxiv.org/pdf/1004.4110.pdf

@mpharrigan Is this easy enough given my limited experience?

mpharrigan commented 4 years ago

I'm not an expert on distance measures or the current state of cirq.qis, so someone else could probably speak more to the current state of things.

But after a quick check, it looks like we still only have (state) fidelity. We should definitely support process fidelity and purity (see @vtomole 's linked qiskit page for more details). This depends on having a representation for processes (like the superoperator representation)

You're certainly welcome to try. I've found a lot of the most insightful reference material is buried in people's theses like https://uwspace.uwaterloo.ca/handle/10012/9557 which probably contains parts of https://arxiv.org/abs/1111.6950

tonybruguier-google commented 4 years ago

Sent https://github.com/quantumlib/Cirq/pull/3198 for process fidelity. Happy to withdraw if this is misguided.

tonybruguier commented 3 years ago

@balopat balopat You can assign this issue to me, if you want.

balopat commented 3 years ago

@tonybruguier assigned! Please outline a design (here should be sufficient) instead of directly opening the PRs directly. I think there are a couple of design questions that are open.

tonybruguier commented 3 years ago

Thanks,

There is some discussion going on about how to handle noisy channels and which representation to choose. I plan to wait until there is resolution (I don't think I'm competent to chime in) and then once that decision is made, I will implement some of the functions as per the papers: https://arxiv.org/pdf/quant-ph/0205035.pdf https://arxiv.org/pdf/1102.0948.pdf

I already have PR #3226 out for review, but I think it's better for me to wait for now.

viathor commented 2 years ago

Related: #2183

95-martin-orion commented 2 years ago

Closed as part of #3641. Please open a new issue if you have a specific measure you're interested in.

mpharrigan commented 2 years ago

I'm really confused. You closed this referencing another issue which I'm very unsure why it was closed

95-martin-orion commented 2 years ago

This was discussed in the Cirq sync (and I'm only now seeing the comment on the other issue about transcribing discussions...sorry about that!) but I think the intent was not to mark this as complete, but to remove it from the open items leading into 1.0. Now that we have the time/after-1.0 tag, we can annotate with that and keep this open.

95-martin-orion commented 2 years ago

Note that time/after-1.0 was added with the understanding that the general task (adding all distance measures) is not prioritized prior to the 1.0 release, but individual distance measures can still be prioritized by opening focused issues with the time/before-1.0 tag.

mpharrigan commented 2 years ago

got it, thanks!