# How it works#

## Motivation#

Suppose we have access to a device performing one of the predefined von Neumann measurements[1], \(\PP\) or \(\QQ\). While the \(\PP\) and \(\QQ\) are known, it is not known which of them is performed when the device executes. Based on the measurement outcome, you have to guess which measurement was performed (but you can perform arbitrary unitary operations before and after the measurement). What is the highest probability of making a correct guess? And what do you have to do to achieve it? And, most importantly, why would we want to do this?

Suppose that you know a strategy that, for an ideal device, would yield a probability \(p_{\text{succ}}\) of successfully discriminating between two measurements. Will the probability be the same on an actual physical device? For current, Noisy Intermediate Scale Quantum devices (NISQs), the answer is: certainly not. However, the error rate that you make when guessing can be used as a benchmarking metric. PyQBench helps you in organizing such discrimination experiments for a single qubit system[2], executing them on real hardware or simulators, and computing discrimination probabilities based on the measured bitstrings.

## Notation and some preliminaries#

Recall that a general quantum
measurement, that is a positive operator valued measure (POVM) \(\PP\) is a
collection of positive semidefinite operators \(\{E_1, \ldots, E_m \}\) called
*effects*, which sum up to identity, i.e. \( \, \, \sum_{i=1}^m E_i = \Id\).
In PyQBench, we are interested only in von Neumann measurements, i.e. measurements
for which all the effects are rank-one projectors. Every such measurement can be
parameterized by a unitary matrix \(U\) which the effects \(\{\proj{u_0}, \ldots, \proj{u_{d-1}}\}\),
are created by taking \(\ket{u_i}\) as \(i+1\)-th column of the unitary matrix \(U\).
We will denote von Neumann measurements described by the matrix \(U\) by \(\PP_{U}\).

Typically, NISQ devices can only perform measurements in computational \(Z\)-basis. To perform an arbitrary von Neumann measurement \(\PP_{U}\), one has to first apply \(U^\dagger\) to the measured system and then follow with \(Z\)-basis measurement. Hence, the following two circuits are equivalent.

Note that the decomposition above is basically a change of basis in which the measurement is performed.

## Discrimination scheme#

Without loss of generality, we consider discrimination between a measurement in the computational Z-basis (\(\PP_\Id\)), and an alternative measurement performed in the basis \(U\) (\(\PP_U\))[3]. In PyQBench, we operate only on two-level systems, but the discrimination scheme, described in detail in [1], makes no assumptions about the dimensionality.

In general, the discrimination scheme, presented in Fig. 2, requires a second system of the same dimensionality as the measured one. First, the joint system is prepared in some state \(\ket{\psi_0}\). Then, the unknown measurement is performed on the first part of the system. Based on its outcome \(i\), another measurement \(\mathcal{P}_{V_i}\) is performed to obtain an outcome \(j\). Finally, if \(j=0\) we guess that the performed measurement is \(\mathcal{P}_U\), otherwise we guess that it was \(\mathcal{P}_\Id\).

## Limitations of NISQ devices and practical considerations#

Current NISQ devices are unable to perform conditional measurements, which is the biggest obstacle to implementing our scheme on real hardware. Luckily, we can overcome it by cleverly adjusting our scheme so that it only uses components available on current devices. We have two possible choices here: using a postselection or a direct sum \(V_0^\dagger\oplus V_1^\dagger\).

### Scheme 1: using postselection#

The first idea is very simple. Instead of performing a conditional measurement, for each measurement \(\PP_U, \PP_\Id\) to be discriminated and each choice of \(k \in \{0, 1\}\) we run circuit presented in Fig. 3.

But now our experiment does not match the previously described scheme, right? Yes, unless we discard all the outcomes for which \(i\ne k\) (hence the name \emph{postselection}, we are selecting valid outcomes after the experiment is performed).

More precisely, our experiments can be grouped into classes identified by tuples of the form \((\mathcal{Q}, k, i, j)\), where \(\mathcal{Q} \in \{\PP_U, \PP_\Id\}\) denotes the chosen measurement. We discard all the experiments for which \(k \ne i\). Hence, the total number of valid experiments is

We now need to count the experiments (among the valid ones) resulting in successful discrimination. If we have chosen \(\PP_U\), then we guess correctly iff \(j=0\). Similarly, for \(P_\Id\), we guess correctly iff \(j=1\). If we define

then the empirical success probability can be computed as

### Scheme 2: By using direct sum of \(V_0^\dagger \oplus V_1^\dagger\)#

We prepare the discriminator \(\ket{\psi_{0}}\) on bipartite system.

We apply one of unitary, either \(U^\dagger\) or \(\Id\), on the first system.

We apply direct sum \(V_0^\dagger \oplus V_1^\dagger\) on the whole systems.

We measure both systems in computational basis \(\Delta\).

We make a decision based on the received label \(j\) on the second system. If \(j=0\), then we decide that \(\PP_U\) occurs. Otherwise, we decide that \(\PP_{\Id}\) occurs.

The schematic representation of this setup is depicted in Fig. 4.

In this scheme, the experiment can be characterized by a pair \((\mathcal{Q}, i,j)\), where \(\mathcal{Q} = \{ \PP_{U}, \PP_{\Id} \}\). The number of successful trials for \(U\) and \(\Id\), respectively, can be written as

Then, the probability of correct discrimination between \(\PP_{U} \) and \(\PP_\Id\) is given by

where \(N_{\text{total}}\) is the number of trials.