1 Introduction

Quantum computing is an emerging technology exploiting quantum mechanical phenomena—namely superposition, entanglement and tunneling—in order to perform computation. Quantum computers have huge potential to transform society in a similar way that classical computers have, because they open up the possibility to tackle certain types of problems that are beyond the reach of classical computers. The first commercially available quantum computers are expected within the next five years, and it is expected that quantum computers will outperform their classical counterparts in some tasks within the same time period. In order to utilize the potential power of quantum computers, one has to formulate a given problem in a form that is suitable for a quantum computer (encoding step) and develop specialized algorithms. These type of algorithms are fundamentally different from classical algorithms. Getting accustomed to quantum algorithms has a considerable learning curve and requires a multidisciplinary approach. Typically, knowledge from physics, mathematics, computers science and a firm understanding from an application area such as quantum chemistry, optimization, or machine learning is required. In addition, it is advantageous to have knowledge of the underlying physics, particularly in the NISQ era.

The New York Times estimated in October 2018Footnote 1 that the global number of high-level researchers in quantum computing may be less than a thousand. The design of games that make use of the underlying rules of quantum computers is a way to attract more interest and ease the transition from classical algorithms to quantum algorithms for beginners. In order to play the basic version of this game, knowledge of quantum physics or advanced mathematics is not required. Just as with any other game, one has to learn a set of rules, which are described in Sect. 3. Since one of the best ways to learn is through play, this game can help to attract more people—from elementary school to post-graduate level at the university—to the field of quantum computing and we hope that the game awakens curiosity for present challenges in the field, such as the design of quantum algorithms and error mitigation schemes.

Near-term applications of early quantum devices, such as electronic structure problems and optimization, rely on accurate estimates of expectation values to become of practical relevance. However, inherent noise in quantum devices leads to wrong estimates of the expectation values of observables. Therefore, getting rid of (most of) the noise inherent in quantum computing is a critical step toward making it useful for practical applications. Quantum error correction (QEC) can only be achieved by increasing quantum resources (ancillary qubits). The first scheme was proposed by Shor [16], and many other schemes were proposed since then, e.g., the class called stabilizer codes, see Gottesman [4]. However, the number of ancillary qubits needed to achieve QEC depends intrinsically on the error rates and is out of reach for NISQ devices. Quantum error mitigation (QEM), on the other hand, can be achieved with additional classical resources only and is therefore applicable to NISQ devices.

The main contributions of this article are as follows.

  • We introduce a novel quantum game based on classic Poker. The game is useful to introduce basic quantum computing concepts to beginners.

  • We implement error mitigation schemes based on the extrapolation technique. A comparison of the results on simulators and real quantum devices is provided. We show that errors can successfully be mitigated when one is interested in expectation values of an observable.

This article is organized as follows. After describing related work in Sect. 2, we present the description of our game in Sect. 3. Using a representative circuit from an example game, we report results of ideal and noisy circuit sampling in Sect. 4. Finally, we describe methods for error mitigation in Sect. 5 before concluding in Sect. 7.

2 Related work

There exist a number of games based on quantum physics, and they can be categorized into the following two types. The first type attempts to illustrate quantum mechanical effects, and one might therefore call them quantum mechanics games. The second type illustrates quantum computing via qubits and quantum circuit building. It is the latter type of game that has been developed in connection with this paper. For a recent review of the subject of quantum games, we refer to, e.g., [7]. Existing quantum computing games include “Battleships with partial NOT gates,” solving puzzles by creating simple programs, and “quantum chess.” Some are available as Jupyter Notebooks in Qiskit’s Github repository of tutorials.Footnote 2

Mitigating the effect of noise on the execution of circuits is critical for the success of NISQ devices. The ideal action of a gate is given by a unitary operator U transforming a state \(|\phi \rangle \) into \(U|\phi \rangle \). There are two basic types of noise. Coherent noise means that a small perturbation \(\widetilde{U}\) of U is executed, where \(\widetilde{U}\) is still unitary and preserves the purity of the state \(|\phi \rangle \). An example is a slight over-rotation. Incoherent noise does not preserve the purity of the state. This type of noise comes from the (unwanted) interaction with the environment. In this case, the evolution must be described through density matrices and Kraus operators. An example of incoherent noise is amplitude damping modeling relaxation from an excited state to the ground state. For a single qubit with decay probability p, the density matrix \(\rho = |\phi \rangle \langle \phi |\) is mapped to \(K_0 \rho K_0^\dagger + K_1 \rho K_1^\dagger \) with \(K_0=\begin{pmatrix} 1 &{} 0\\ 0 &{} \sqrt{1-p} \end{pmatrix}, K_1=\begin{pmatrix} 0 &{} \sqrt{p}\\ 0 &{} 0 \end{pmatrix}\). Different types of techniques have been presented in the literature that can be used to mitigate the influence of noise on the ideal circuit. In the following, we discuss the most important ones.

Quantum subspace expansion (QSE). The main idea is to use operators from a given set (such as the set of Pauli operators) to expand about the variational solution. A generalized eigenvalue problem using linear subspaces is solved. This method leaves the circuit width (number of qubits) and depth (largest number of gates on any input–output path) unchanged. The method is introduced by Wecker et al. [19] where numerical evidence is provided. For the variational quantum eigensolver, numerical evidence for error mitigation is provided by McClean et al. [10]. An extension of the approach is given in Colless et al. [2]. The complete energy spectrum of the H2 molecule is calculated with near chemical accuracy. Premakumar and Joynt [13] generalize the concept of decoherence-free subspace (DFS) to noise with correlations in space to avoid regions where decoherence measures are high. However, as the authors point out themselves, only dephasing noise is considered and it is unlikely that the method is useful for general error models. DFSs do not exist for other types of noise, e.g., if noise flips spins.

Probabilistic error cancellation The main idea is to represent the ideal circuit as a quasi-probabilistic mixture of noisy ones. The circuit depth and width remain unchanged with this method. Temme et al. [18] present the method together with numerical evidence. Song et al. [17] demonstrate an error mitigation protocol based on gate set tomography and quasiprobability decomposition. One- and two-qubit circuits are tested on a superconducting device, and computation errors are successfully suppressed. Process tomography is not feasible for more than a few qubits since it scales exponentially with the number of qubits. In addition, process tomography is sensitive to noise in the pre- and post-rotation gates plus the measurements (SPAM errors). Gate set tomography can take these errors into account, but the scaling becomes even worse.

Extrapolation techniques The main idea is to amplify the noise deliberately in a controlled way. The information of the dependence of the expectation value on the noise level is used to extrapolate back to the zero noise level. The circuit width remains unchanged, but the circuit depth is longer (or gate times are prolonged in case of phase control). Temme et al. [18] and Li and Benjamin [9] introduced the technique and provide numerical evidence. Endo et al. [3] extend the work of [9, 18] by accounting for the inevitable imperfections in the experimentalist’s measuring the effect of errors in order to design efficient QEM circuits. Kandala et al. [6] present important considerations for hardware and algorithmic implementations of the zero-noise extrapolation technique and demonstrate tremendous improvements in the accuracy of variational eigensolvers implemented by a noisy superconducting quantum processor. Evidence on real quantum hardware is presented. In contrast to previous works, the increase in errors is not done by artificially introducing additional gates, but directly by pulse control. For IBM’s quantum computers, access at this level (pulse/machine level) is only possible for customers of, which makes this technique inaccessible to us. Otten and Gray [12] introduce a technique that can be viewed as a multidimensional extension. The approach corresponds to repeating the same quantum evolution many times with known variations on the underlying systems’ error properties. They show that the effective spontaneous emission, T1, and dephasing, T2, times can be increased using their method in both simulation and experiments on an actual quantum computer.

In this article, we present results using the extrapolation method. We conduct experiments on simulators with error models and real quantum computers.

3 Quantum Poker rules

The classical Texas hold ’em round involves five community cards on the table shared by all the players, while each player holds 2 unique cards in their own hand. The small and big blind bets are placed at the start of each round, relative to a rotating dealer position. The community cards are gradually revealed, the first three—called “the flop”—are revealed simultaneously, and the last two called “the turn” and “the river” are revealed one at a time. The players take turns betting at the start of each round. In order to stay in the game, one has to match or increase the highest bet currently in play. Otherwise, one can fold and forfeit the chance to win the pot, i.e., the sum of money that players wager during a single hand or game. After all five cards have been revealed, there is a final round of betting before the players can choose to either show their hand in the hope of winning or folding it and forfeiting the pot. The goal is to combine up to five cards from both your own hand and the table to form the best Poker hand (hands are ordered by their probability and for equal probability by the “highest” card) out of all the players. The player or players with the best hand win(s) the pot.

Fig. 1
figure 1

Example of a quantum Poker game and the basic rules needed to play. The state of the quantum register before each player places their gates is shown in the middle of (a). Max has one out of total four X, CX and ZH gates and no H gate. The underlying circuit generating the quantum register is shown in (b). Note that qubit \(q_2\) is entangled with qubits \(q_0\) and \(q_1\), but the resulting state is shown to be \(|0\rangle \) in (a), since the bit gets flipped twice. In order to win, Max needs to alter the state of the “community cards” in such a way that the states of the qubits get ”closer to \(|1\rangle \). Looking at the list of operations shown in (c), Max applies his X-gate to change the state of \(q_2\) to be \(|1\rangle \). He then applies the ZH gate to qubit \(q_3\) to obtain the state \(|0\rangle \) and flips it to \(|1\rangle \) by applying a CX with qubit \(q_2\), which is in state \(|1\rangle \)

The quantum Poker game considered here draws inspiration from Texas hold ’em Poker and shares its structure. The betting rounds in the two games are identical. Community cards are replaced with qubits, and the cards received by each player are replaced by quantum logic gates which can be applied to the qubits, i.e., community cards.

  • In quantum Poker, each player acts on a personal “copy” of the community cards, consisting of a quantum register. Hence, the only interaction between the players is through betting. An example initial state is shown in Fig. 1. The qubits can be in an any state, e.g., the ground state \(|0\rangle \), the excited state \(|1\rangle \), a state of superposition \(|\pm \rangle = \frac{1}{\sqrt{2}}(|0\rangle \pm |1\rangle )\), or in an entangled state like the Bell states \(\frac{1}{\sqrt{2}}(|00\rangle \pm |11\rangle )\).

  • The personal cards come from a set of available quantum logic gates which can be applied to the qubits. This set is known to all players, such that they can deduce the probability of another player having, e.g., a CX gate. The set of quantum logic gates consist of operations acting on one or two qubits. In our implementation, the set consists of the Hadamard gate H, the phase flip gate Z, the NOT gate X and the controlled NOT gate CX. The action of each gate applied to the \((|1\rangle ,|0\rangle )\)- and \((|+\rangle ,|-\rangle )\)-basis is shown in Fig. 1c.

  • The final score of each player is the number of qubits measured to the state \(|1\rangle \) in the computational basis at the end of the round. The winner(s) of each pot is/are the player(s) with the highest score.

The game is designed such that it can be played without knowledge of physics and advanced mathematics. The only rules to learn are given in the list shown in Fig. 1c and the following rules: The state \(|1\rangle \) has a 100% probability to “give a 1,” \(|0\rangle \) a 0% probability to “give a 1,” and the states \(|+\rangle , |-\rangle \) a 50% chance to “give a 1.” In addition, states marked as “Pair” the probabilities of the two qubits cannot be described independently. As an example, the Bell states \(\frac{1}{\sqrt{2}}(|00\rangle \pm |11\rangle )\) “give two 1s” with a probability of 50%. For the sake of correctness, the expression “give a 1/give two 1s” refers to measurement in the computational basis. The idea of the game is that players will get familiar with the rules underlying quantum computing.

In the quantum Poker game, a state

$$\begin{aligned} |\phi \rangle = VU |0\rangle ^{\otimes n} \end{aligned}$$
(1)

is created. The matrix U creates the n “community cards” and is equal for all players. The matrix V is created by the players through placing their “personal cards.” Given the state \(|\phi \rangle \) and an observable A, the expectation value of A in the state \(\phi \) is given by

$$\begin{aligned} \langle A \rangle _\phi :=\langle \phi | A |\phi \rangle = \sum _i \lambda _i \left| \langle \phi |\psi _i\rangle \right| ^2. \end{aligned}$$
(2)

Here, A is a self-adjoint operator on the Hilbert space \(\mathbb {C}^{\otimes n}\), and \(\{\lambda _i,|\psi _i\rangle \}\) is the set of eigenvalues and eigenvectors of A. To match the objective of our game, we need to define an observable A such that \(\langle A \rangle _\phi \) is equal to the expected number of ones in the computational basis. This can be done by choosing

$$\begin{aligned} A = \sum _{i=1}^{2^5} b(i) P_i, \end{aligned}$$
(3)

where b(i) is a function returning the number of ones of the binary representation of i, and \(P_i = |i\rangle \langle i|\) is the measurement operator in the computational basis. A is a diagonal matrix with eigensystem \(\{b(i),|i\rangle \}\). The matrix A can also be constructed via the number operator in the second quantization (a formalism used to describe and analyze quantum many-body systems), which is given by

$$\begin{aligned} A = \sum _i N_i, \quad \text { where } N_i = a_i^\dagger a_i. \end{aligned}$$
(4)

The creation and annihilation operators are given by

$$\begin{aligned} \begin{aligned} a_i^\dagger&= I^{\otimes n-i-1} \otimes Q^+ \otimes \sigma _z^{\otimes i}, \\ a_i&= I^{\otimes n-i-1} \otimes Q^- \otimes \sigma _z^{\otimes i}, \\ \end{aligned} \end{aligned}$$
(5)

and the raising and lowering operator is given by

$$\begin{aligned} Q^\pm = \frac{1}{2} \left( \sigma _x \mp i \sigma _y \right) , \end{aligned}$$
(6)

i.e, \(Q^+=\begin{pmatrix} 0 &{} 1\\ 0 &{} 0 \end{pmatrix}, Q^-=\begin{pmatrix} 0 &{} 0\\ 1 &{} 0 \end{pmatrix}\). As an example, for two qubits A is a diagonal matrix with entries (0, 1, 1, 2), from upper left to lower right.

Fig. 2
figure 2

Result for Max’s circuit shown in Fig. 1b using simulators and IBM’s quantum devices. In total, 1024 repetitions with 8192 shots each were used. The error models are more optimistic than the real quantum devices. Quantum noise on a real device leads to convergence of the expectation value to a much lower value than its simulated noise model, which is in turn lower than the theoretical value. A comparison of a and b shows that Pauli-twirling, see Sect. 5.1, has little to no effect on the obtained expectation value, even when noise is present. It leads, however, to an increased variance in the presence of noise

Using Equation 3, it is easy to calculate the expectation value as

$$\begin{aligned} \langle \Phi |A|\Phi \rangle = \langle \Phi | \sum _{i=1}^{2^5} b(i) P_i|\Phi \rangle = \sum _{i=1}^{2^5} b(i) \langle \Phi |P_i|\Phi \rangle = \sum _{i=1}^{2^5} b(i) \langle \Phi |P^\dagger _i P_i|\Phi \rangle = \sum _{i=1}^{2^5} b(i) p(i), \end{aligned}$$
(7)

see Postulate 3 [11, p. 84], where p(i) is the probability that result i occurs. In order to get the expectation value, we can therefore measure the states \(|\Phi \rangle \) in the computational basis and multiply the resulting bit strings with b(i).

4 Ideal and noisy quantum circuit sampling

In the following, we use Max’s circuit, shown in Fig. 1b, as an example to investigate the effects of noise in NISQ devices.

4.1 Ideal simulator

The state that Max creates is given by \(|\phi _\text {Max}\rangle = \frac{1}{\sqrt{2}}(|01101\rangle + |11111\rangle )\). Each realization of the circuit on an ideal (simulated) quantum computer results in a classical bit string \(q_{n-1} \dots q_1 q_0\) after measurement. A state \(\phi = \sum _i \alpha _i|i\rangle \) induces a probability distribution \(P_\phi (i) = |\alpha _i|^2\). For Max’s circuit, this distribution is thus given by a 50% chance of being in either state \(|01101\rangle \) and \(|11111\rangle \). The expectation value for Max’s circuit is thus \(\langle A \rangle _{|\phi _\text {Max}\rangle } = 4\). Fig. 2 shows the convergence of sequence averages on an ideal simulator with respect to the number of repetitions to the expectation value, as well as the according probability distribution of the sequence. Here, we have used Qiskit’s simulator with 1024 repetitions, each consisting of 8192 shots.

4.2 Set of universal quantum gates and circuit mappings

On a real quantum device, such as IBM’s QX architectures, only certain types of operations/gates are supported. This set contains the single qubit gates \(U_1, U_2, U_3\), and the CX gate. In order to execute a circuit, one needs to express the circuit in these basis gates. The Solovay-Kitaev theorem guarantees that this is always possible up to a given accuracy.

Fig. 3
figure 3

A comparison of the two IBM devices used shows that the qubits have better connectivity on the QX2 device (6 vs. 4 bus resonators), the average readout error is much smaller, but the CX error rate is worse, as compared to IBM’s ourense. In order to execute Max’s circuit, shown in Fig. 1b, equivalent circuits, shown in c and d. Both use the same number of CX gates, but have different depth. The variables of the \(U_2, U_3\) gates are skipped for simplicity. The average depth of the circuits can be reduced to a constant after combining neighboring single qubit gates

An additional complication comes from the fact that only a subset of qubits are physically connected. On IBM’s QX devices, CX gates can only be applied to qubits that are connected by a bus resonator. Fig. 3a, b show the connectivity graph of two of IBM’s quantum devices, where edges mark qubits that are physically connected. In order to execute a circuit with CX gates between two not connected qubits, additional gates, such as SWAP or BRIDGE gates, need be used to transform the circuit into an equivalent one that obeys the connectivity graph. Inserting one SWAP or BRIDGE gate increases the number of CX gates by three. On current NISQ devices, the noise level of two-qubit gate (CX) times and error rates are one order of magnitude higher than for single qubit gates [14], see also Fig. 3a, b. One therefore wishes to find a mapping with the lowest number of CX gates. In general, the problem of finding an optimal mapping is \(\mathcal {N}\mathcal {P}\)-complete problem [20]. For recent heuristics, we refer to [5, 20] and references therein. For Max’s circuit, it is easy to find an optimal mapping for IBM’s QX2 device manually using only one extra SWAP gate. For the IBM’s ourense device, we have used the built-in optimizer. The resulting circuits which are shown in Fig. 3c, d have the same number of CX gates. However, the circuit adapted to the ourense device has a larger depth due to lower connectivity of the qubits.

4.3 The effect of noise on quantum computation

Noise is inherent to quantum computers. Qiskit provides methods for automatic generation of approximate noise models matching a given hardware device. This enables us to simulate the effects of realistic noise on our computation before we run our circuits on a real quantum computer. Figure 2 shows the results of the Max’s circuit on different simulators and real quantum devices, using the transpiled circuits shown in Fig. 3. Due to the influence of noise, the resulting expectation values converge to a value around 3.86/3.76 for the simulated noise model and 3.70/3.52 on the IBM’s quantum computers for the QX2/ourense device. The gate noise level of IBM’s ourense device is slightly better than that of IBM’s QX2, but the average readout error and connectivity (and hence on average the depth of a circuit) is worse for the ourense device. In our case, we achieve better results with the QX2 device, since we can use a shorter depth circuit with less readout errors. Both values are far off the ideal value of 4, obtained through a noiseless simulation. In the following, we will show how to mitigate the effect of errors on expectation values in order to get a better estimate of the ideal expectation value.

5 Error mitigation

In this section, we will apply the zero-noise extrapolation method to our circuit. The basic assumption of the method is that the expectation value of an observable depends smoothly on a small noise parameter \(\lambda \ll 1\) and admits the following power series,

$$\begin{aligned} \langle A \rangle _{|\phi \rangle }(\lambda ) = \langle A \rangle _{|\phi \rangle }^* + \sum _{i=1}^n a_i \lambda ^i + \mathcal {O}(\lambda ^{i+1}), \end{aligned}$$
(8)

where \(\langle A \rangle _\phi ^*\) is the zero noise value we are trying to recover. Richardson’s deferred approach to the limit [15] can then be applied to get a better estimate of the zero noise value. The method requires to generate n estimates to the expectation value, i.e., \(\langle A \rangle _\phi (r_i\lambda )\) for \(r_1<r_2<\dots <r_n\). A better estimate of \(\langle A \rangle _\phi ^*\) is then constructed by combining these values in such a way that the lowest order terms in the power series cancel. As an example, we can get a second-order approximation of the expectation value by combining the results for \(r_1=1\) and \(r_2=2\) through

$$\begin{aligned} 2 \langle A \rangle _{|\phi \rangle }(\lambda ) - \langle A \rangle _{|\phi \rangle }(2\lambda ) = \langle A \rangle _{|\phi \rangle }^* + \mathcal {O}(\lambda ^2). \end{aligned}$$
(9)

Clearly, using \(r_1=1\) generates the expectation value with the least noise. Amplification of noise with the factors \(r_i>1\) can either be achieved directly through pulse control or through modifying the circuit by adding certain extra gates. For IBM’s QX devices, pulse control on devices with more than one qubit is only accessible for their customers, which leaves us with the second possibility.

5.1 Pauli-twirling

Before we apply the noise amplification, we convert the non-stochastic errors of CX gates into stochastic errors, see, e.g., [9, section VII] for a detailed description. One way to achieve this is to apply Pauli-twirling. Given a finite group G of quantum operations and a quantum channel \(\Lambda \), the average

$$\begin{aligned} \frac{1}{|G|} \sum _{U\in G} U^\dagger \Lambda U, \end{aligned}$$
(10)

is called a twirl of the channel \(\Lambda \). In our case, gates \(\sigma ^a, \sigma ^b, \sigma ^c, \sigma ^d\) are inserted before and after each CX gate \(\Lambda \), where \(\sigma ^i\) is chosen from the twirling set consisting of the Pauli gates \(\{ \mathbb {1}, \sigma ^x, \sigma ^y, \sigma ^z \}\). After randomly (with uniform probability) choosing \(\sigma ^a, \sigma ^b\), the gates \(\sigma ^c,\sigma ^d\) are then chosen to satisfy

$$\begin{aligned} \sigma ^c \otimes \sigma ^d = \mathrm {e}^{i \theta } \Lambda (\sigma ^a \otimes \sigma ^b) \Lambda ^\dagger . \end{aligned}$$
(11)

This ensures that the overall effect results only in a phase change, which does not change the measurement outcome. The circuit constructed with Pauli-twirling applied to all CX gates is therefore equivalent to the original circuit. Figure 4 shows a schematic depiction of Pauli-twirling as well as all valid combinations for the CX gate. In practice, this method is applicable, if the assumption holds that the qualities of single-qubit gates are an order of magnitude smaller than two-qubit gates. Twirling should then only have a negligible effect on the fidelity of the expectation value on NISQ devices. Figure 2 indicates that noise manifests itself in an increase in the variance of the distribution. There is no effect for the ideal simulator.

Fig. 4
figure 4

Pauli-twirling and noise amplification

Fig. 5
figure 5

Effect of artificially amplifying the noise on Max’s circuit. Each sample point uses \(N=1024\) randomly generated circuits with 8192 shots per circuit. The r-dependence of the simulated noise model is much smoother than that of IBM’s QX2 device. Amplifying the noise with random Pauli gates leads to a multi-peaked distribution, because the expectation value is a sum of different outcomes.

5.2 Noise amplification

In order to amplify the strength of the noise, we will apply random Pauli gates with a probability proportional to the error rate of the CX gate between a given pair of qubits. More precisely this is means applying gates \(\sigma ^e, \sigma ^f\) randomly chosen form the set of Pauli gates \(\{ \mathbb {1}, \sigma ^x, \sigma ^y, \sigma ^z \}\) after the twirled CX gates with probability \((r-1)\epsilon _{i,j}\), see a depiction in Fig. 4a. Note that there are only 15 possible choices for \(\sigma ^e \otimes \sigma ^f\), since \(\mathbb {1}\otimes \mathbb {1}\) must be excluded because it does not increase the error. Here, \(\epsilon _{i,j}\) is the two-qubit gate error rate between qubits \(q_i\) and \(q_j\). On average, this increases the error rate to the desired value \(\epsilon _\text {new} = \epsilon _{i,j} + (r-1)\epsilon _{i,j} = r\epsilon _{i,j}\).

Figure 5 shows the result for both the simulated error models and the real quantum devices. The assumption that the expectation value of an observable depends smoothly on r seems to hold for the simulator with the IBM QX2 noise model and the IBM QX2 device, but less so for the IBM ourense device, see Fig. 5d. This is likely because some of the underlying assumptions of the method are violated for the ourense device, e.g., the existence of non-Markovian noise, spatially or temporally correlated noise, etc. The result shown in Fig. 5d seems to justify the assumption of the exponential variant of the extrapolation method presented in [3].

Additional insight is provided by looking at the distribution for \(r\in \{1,4,32\}\). Since we increase the noise of CX gates artificially by adding Pauli gates, this means that other outcome strings are becoming more likely. Figure 5a-c shows that expectation values of 1, 2, 3 become increasingly likely. The result is a multi-peaked distribution. The noisy results show the same basic behavior as the ideal circuit. In general, the noise models seem to lead to better estimates of the expectation values than the real quantum devices, limiting their usefulness somewhat.

5.3 Error mitigation of measurement noise

Measurement noise is another major source of error. Here, we use the model that assumes spatially uncorrelated errors of a bit flip. We compute the probability that the state \(|i\rangle \) is observed if the state \(|j\rangle \) is prepared, i.e., the conditional probability \(P_{i,j}:=P(|i\rangle ||j\rangle )\). The matrix

$$\begin{aligned} P=\left[ \begin{matrix} P_{1,1}&{}\dots &{}P_{1,2^n}\\ \vdots &{}\ddots &{}\vdots \\ P_{2^n,1}&{}\dots &{}P_{2^n,2^n}\\ \end{matrix}\right] , \end{aligned}$$
(12)

is a (right) stochastic matrix, as \(\sum _j P_{i,j} = 1\). In the absence of noise \(P_{i,j}=\delta _{i,j}\), but measurement (and other) noise leads to nonzero off-diagonal entries. The resulting probabilities for IBM’s QX2 are shown in Fig. 6a.

Let us assume that, for a quantum computer, we are given P and a probability distribution \(D_\text {noisy}\) induced by measurement of a quantum state \(|\Psi \rangle \). Using the equation

$$\begin{aligned} D_\text {noisy} = P D_\text {ideal}, \end{aligned}$$
(13)

we can retrieve the ideal distribution \(D_\text {ideal}\) of \(|\Psi \rangle \). As an example, we are preparing the Bell state \(|\Psi \rangle =1/\sqrt{2}(|00\rangle +|11\rangle )\), but the resulting distribution is \(D_\text {noisy}=(13,2,2,13)/30\). In addition, we have that \(P_{i,j}\) is 0.8 if \(i=j\) and 0.2/3 otherwise. By solving (13), we can then retrieve the noiseless distribution \(D_\text {ideal}=(1/2,0,0,1/2)\).

Fig. 6
figure 6

The results from the prepared vs measured state can be used to construct a filter to mitigate measurement errors. The filter applied to Max’s circuit improves the probabilities

In order for the method to work, measurement errors must be at least one order of magnitude larger than state preparation and the execution of the X gate. This condition is satisfied for IBM’s QX2 and ourense device, compare Fig. 3. In addition, it must be mentioned that this requires an exponential amount (in the number of qubits) of states to be prepared and measured to build the matrix P. In this work, we use the implementation provided by Qiskit [1]. Fig. 6b and the column for \(E_1\) in Fig. 6c show a clear improvement by applying the measurement filter for Max’s circuit.

5.4 Overall results

In all of our experiments, we generate N circuits randomly with Pauli-twirling and a noise amplification factor r. Each of these circuits is called a “repetition” and uses 8192 shots. The number of this random circuits (repetitions) has to be large enough to cover the whole sample space. Max’s circuits have 9 CX operations, which is why we used \(N=1024\) repetitions. We can see in Fig. 7a, b that this number is sufficient for convergence. The results for other circuits are similar.

Figure 7 shows the convergence of the circuits and the effect of error mitigation techniques on the expectation value. With \(E_r=E(r)\), we denote the expectation value achieved with amplification factor r, and by R(.) the Richardson extrapolation. Without error mitigation, the expectation value for the X2 device is closer to the theoretical value than the ourense device. The execution on real devices leads to a worse result as the simulators. Compare also Fig. 2b

Applying Richardson, extrapolation clearly improves the resulting expectation value in all cases. With increasing number of terms, the achieved estimate of the expectation value seems to converge. For the X2 device, already 2–3 terms are sufficient to achieve a very good approximation. For the ourense device, the results are not as good. This is most likely due to longer circuit depth and higher measurement errors.

Applying the measurement error filter alone helps to improve the expectation value as well, particularly when using a quantum simulator. However, on the real devices, the results are not as good as for the Richardson extrapolation. Combining Richardson extrapolation and measurement error filter seems to only work for the ourense model and device.

Fig. 7
figure 7

Results achieved using the simulator and IBM’s quantum devices. The symbols \(E_1, E_2, \ldots E_{32}\) denote the expectation value for the noise amplification factor r equal to \(1, 2, \ldots , 32\), respectively. R(.) denotes the Richardson extrapolation. All results were obtained by using 1024 repetitions with 8192 shots each

6 Relationship to benchmarking

We would like to remark that circuits from the proposed game could be used to benchmark quantum devices. In randomized benchmarking, see, e.g., [8], random sequences are generated from the Clifford group, including a computed reversal element such that the overall unitary is the identity up to a global phase factor. Quantum Poker has a random part, the “community cards,” and a part that depends on the strategy of the individual player, see Equation (1). In order to use quantum poker in this setting, one would need to make the following changes:

  • Negate the original definition of winning to be maximizing the number of 0’s that are measured.

  • Provide a player with enough cards, such that the overall unitary of an identity modulo global phase can be created, i.e., such that \(U=e^{i\theta }V^{-1}\).

With this changes, the game can be used to benchmark subspaces of 5 qubits. A generalization to n qubits is also straight forward.

7 Conclusion

We have presented a game intended to serve as a pedagogical tool for learning the basic rules of quantum computers. The aim was to make it a fun experience in order to get more people acquainted with the rules of quantum computing and raise interest in algorithms and error mitigation. It could therefore help to avoid a shortage in experts when quantum computers become commercialized. To make the threshold for acquiring the game lower, it could be made available on smartphones as well. In order to make the game more difficult, one could generate a completely random initial state. The quantum Poker game can be easily simulated on classical computers because it requires only 5 qubits. However, on contemporary quantum computers the use of multiple error-prone CX gates and measurement operations, gives a large error in the output state of the circuits. We have presented and discussed several error mitigation techniques that produce better estimates of expectation values. The overall results rely on Pauli-twirling to convert non-stochastic errors of CX gates into stochastic errors.