quantumlib / Stim

A fast stabilizer circuit library.
Apache License 2.0
305 stars 88 forks source link

von Neumann entropy #785

Open viathor opened 3 weeks ago

viathor commented 3 weeks ago

It's fairly simple to compute von Neumann entropy of a stabilizer state given its tableau and a partitioning of the qubit register, see e.g. here.

The API might look something like

template <size_t W>
struct Tableau {
    ...
    template <class QubitIt>
    TODO entanglement_support(QubitIt first, QubitIt last);

    template <class QubitIt>
    size_t von_neumann_entropy(QubitIt first, QubitIt last);
    ...
}

where first and last are iterators to a collection of size_t specifying one of two subpartitions of the qubits indexed from zero to tableau's num_qubits minus one. The functions would throw std::out_of_range if the collection contains qubits outside the range. Return type size_t is chosen to match Tableau.num_qubits (which makes sense in light of the formula (1) in the answer linked above). Return type TODO is a representation of the subset of the given partition on which the entanglement is supported.

The new functions should be exposed via pybind.

I found a mention of this feature in this past issue.

Credit: function entanglement_support suggested by @Strilanc.

Strilanc commented 3 weeks ago

The python API is more important than the C++ API. The C++ method should probably live in src/util_top/*, along with most of the other top-level utilities not used by other utilities, to avoid explosion in compilation times by dumping everything into the class source files.