# Efficient experimental estimation of fidelity of linear optical quantum Toffoli gate

###### Abstract

We propose an efficiently measurable lower bound on quantum process fidelity of -qubit controlled-Z gates. This bound is determined by average output state fidelities for partially conjugate product bases. A distinct advantage of our approach is that only fidelities with product states need to be measured while keeping the total number of measurements much smaller than what is necessary for full quantum process tomography. As an application, we use this method to experimentally estimate quantum process fidelity of a three-qubit linear optical quantum Toffoli gate and we find that . We also demonstrate the entangling capability of the gate by preparing GHZ-type three-qubit entangled states from input product states.

###### pacs:

03.65.Wj, 42.50.Ex, 03.67.-aAs the complexity of quantum information processing devices increases, there is a growing demand for reliable and efficient methods of their characterization. Traditionally, the experimentally implemented quantum operations are being characterized by quantum process tomography which provides their full description Nielsen00 (); Paris04 (). However, a complete quantum tomography requires resources which grow exponentially with the number of qubits. In recent years, increasing attention has been therefore paid to methods such as compressed sensing Gross10 (); Shabani11 () or Monte Carlo sampling Flammia11 (); Silva11 (); Steffen12 (), that allow to reduce the overhead of quantum process characterization. This is possible if we make some a-priori assumption about the structure of the reconstructed quantum object or if we do not seek a complete tomographic description and we are satisfied instead with determination of a particular parameter such as fidelity Emerson07 (); Bendersky08 (); Koch13 ().

In 2005, it was shown by Hofmann that the quantum process fidelity can be estimated by measuring the average quantum state fidelities and for only two conjugate bases Hofmann05 (). The quantum process fidelity is then lower bounded according to

(1) |

This procedure has received a considerable attention and it was utilized in several experiments to estimate the fidelity of a quantum CNOT gate Okamoto05 (); Bao07 (); Clark09 (); Gao10 (); Gao10b (); Zhou11 (). In this case, it is sufficient to measure the CNOT truth table in the computational basis and in the dual basis obtained from the computational basis by single-qubit Hadamard transformations. In this dual basis, the gate also acts as a CNOT but the roles of control and target qubits are reversed. The great practical advantage of this characterization of a CNOT gate is that all the required input probe states as well as all the corresponding output states whose fidelity should be measured are product states. Therefore, the fidelities can be directly determined by single-qubit measurements. The fidelity bound (1) is applicable to arbitrary multiqubit quantum gates. However, going beyond the two-qubit CNOT gate, it would typically require measurements of fidelities of output states that are entangled Lanyon11 ().

In this paper, we propose a generalization of the Hofmann fidelity bound to multiqubit controlled-Z gates which preserves all the experimentally desired features present for the two-qubit CNOT gate. In particular, product multiqubit probe states are considered and only fidelities of product states have to be measured. Furthermore, the total required number of measurement settings is only , while at least measurement settings are necessary for a full quantum process tomography of an -qubit gate specified by parameters for deterministic gates or parameters for probabilistic gates. Here a measurement setting represents a specific combination of input state preparation and an output measurement. As an application, we employ this method to experimentally estimate quantum process fidelity of a three-qubit linear optical controlled-Z gate (CCZ gate) that is equivalent to the Toffoli gate up to single-qubit Hadamard transform on a target qubit. The Toffoli gate is a crucial part of many quantum information processing schemes Nielsen00 () and it represents one of the most complex quantum circuits experimentally implemented to date Lanyon09 (); Monz09 (). A peculiar feature of linear optical quantum gates is that they are probabilistic Kok07 (). In practice, it may happen due to various imperfections that the success probability of the gate depends on the input state and is not a constant. We shall show that the fidelity bounds hold even in such case but the average state fidelities must be calculated as weighted averages, with the weights given by relative probabilities of success.

Let and denote the computational basis states of a qubit. The CCZ gate flips the sign if and only if all three qubits are in state ,

(2) |

where denotes the identity operator. In the computational basis, we explicitly have . A Hadamard transform on a target qubit converts the sign flip of CCZ gate into the bit flip of Toffoli gate. Recall that and , where .

According to the Choi-Jamiolkowski isomorphism Jamiolkowski72 (); Choi75 (), any quantum operation can be represented by a positive semidefinite operator on a tensor product of input and output Hilbert spaces. Let denote a maximally entangled state on two copies of a three-qubit Hilbert space. The Choi matrix of operation can be determined by applying this operation to one part of the maximally entangled state, , where is a short-hand notation for a density matrix of a pure state. For any input density matrix , the corresponding output density matrix can be calculated as , where denotes partial trace and stands for transposition. We shall consider general probabilistic operations and then represents the success probability for the input . In particular, the Choi matrix of a unitary CCZ gate reads

(3) |

The process fidelity of a quantum gate with respect to the ideal CCZ gate can be defined as a normalized overlap of the Choi matrices, , where the factor accounts for the normalization of .

1 | ||||
---|---|---|---|---|

2 | ||||

3 | ||||

4 | ||||

5 | ||||

6 | ||||

7 | ||||

8 |

Our goal is to lower bound the gate fidelity by suitably chosen average state fidelities. Motivated by the symmetry of the CCZ gate which is invariant with respect to the permutation of the qubits, we propose to characterize the CCZ gate by measuring the average output state fidelities for three complementary product bases where two of the qubits are prepared in the computational basis states while the third qubit is prepared in the Hadamard basis states . The probe product states are specified in Table I for all three bases . It can be easily checked that all the corresponding output states are also product states and the two bases and coincide. Let denote the (unnormalized) output state for the input . The fidelity of this output state with the ideal output can be expressed as

(4) |

Here denotes the probability of success of the gate for input and denotes a density matrix of a pure state . We define the average state fidelity for th basis as a weighted mean of with weights equal to the success probabilities Bell12 (),

(5) |

Since for all , it holds that and we can express the mean fidelities in a compact matrix form , where

(6) |

The gate fidelity can be lower bounded by the three above defined average state fidelities as follows,

(7) |

which generalizes the Hofmann bound (1) and is valid for both deterministic and probabilistic quantum operations. In order to prove this bound, we rewrite it as

(8) |

where It can be shown by explicit calculation that the matrix is positive semidefinite, which immediately implies the inequality (8). Note that holds irrespective of the actual form of the unitary . Thus the fidelity bound (7) is actually completely general and it holds for all three-qubit unitary operations. The output states will be product states for all unitaries that are diagonal in the computational basis SI (). However, for other gates the output states may be entangled. We stress that it is important to calculate as wieghted means (5) because if would be calculated as ordinary means, /8, then the bounds (1) and (7) could actually overestimate the gate fidelity for certain trace-decreasing operations. The fidelity bound (7) can be generalized to -qubit gates and it can be shown that

(9) |

where is the average fidelity for input product basis states where all qubits are prepared in the computational basis states except for the th qubit which is prepared in the Hadamard basis states. A detailed analytical proof of the bound (9) can be found in the Appendix SI (). The bound will be tight and equality will hold in Eq. (9) if is either the desired unitary , the unitary preceded by a phase flip on a single qubit, or any mixture or coherent superposition of these unitary operations SI ().

The experimental setup is shown in Fig. 1. Orthogonally polarized time-correlated photon pairs with central wavelength of nm are generated in the process of spontaneous parametric downconversion in a mm thick BBO crystal pumped by a CW laser diode with mW pump power Jezek11 (). The first qubit is encoded into spatial degree of freedom of the signal photon while the second and third qubits are encoded into polarization of the signal and idler photons, respectively. The polarization states are prepared and analyzed using half- and quarter-waveplates and polarizing beam splitters. The calcite beam displacer BD1 transforms the input polarization state of the signal photon into state of spatial qubit and the beam displacer BD2 maps the spatial qubit back onto polarization. The pair of beam displacers forms an inherently stable Mach-Zehnder interferometer. The HWPs which address only one path in the interferometer disentangle input polarization and spatial qubits of the signal photon and ensure correct signal collection by BD2.

The CCZ gate is implemented by two-photon interference on a partially polarizing beam splitter PPBS with intensity transmittances and for horizontally and vertically polarized photons, respectively Ralph02 (); Hofmann02 (); Okamoto05 (); Langford05 (); Kiesel05 (). The scheme also requires two additional PPBSs for balancing the amplitudes. The phase shift due to two-photon interference on the central PPBS occurs only if the signal photon travels through the lower interferometer arm and both photons are vertically polarized (logical qubit states ). This probabilistic CCZ gate operates in the coincidence basis Kok07 () and its successful operation is indicated by detection of two-photon coincidences D1&D3, D1&D4, D2&D3, or D2&D4 at the output. Other detection events correspond to gate failure and are rejected and not used in subsequent analysis. Ideal success probability of the CCZ gate is which is the maximum value achievable without the use of ancilla photons Lemr11 ().

We have prepared the input states , , as listed in Table I and for each input we have performed projective measurement on the output in the product basis . The results are shown in Fig. 2 and they can be also interpreted as the computational basis truth tables of the Toffoli gates where the target qubit is the first, the second, and the third qubit, respectively. The parameters and necessary for evaluation of the average state fidelities were determined as follows. Let denote the number of detected coincidences corresponding to projection onto for input . Then , where is the total number of coincidences for a given input. In our measurement, on average. Since all were measured for the same time interval of s, the relative success probabilities can be determined as normalized total number of coincidences, where . The estimated lie in the interval . On inserting the expressions for and into Eq. (5) we get , which yields

(10) |

The statistical errors represent standard deviations , which were determined assuming Poissonian statistics of the measured coincidences, . If we plug the fidelities (10) into formula (7) we obtain a lower bound on the fidelity of the implemented linear optical CCZ gate,

(11) |

For comparison, we have also experimentally determined the original Hofmann bound on the process fidelity (1). For this purpose we consider two bases labeled and connected by Hadamard transforms of all three qubits, . The input states are explicitly listed in the last column of Table I. It holds that , where both fidelities are given by Eq. (5). This inequality can be equivalently expressed as , where . Similarly as before, one can explicitly show that , which proves the above inequalities. The determination of requires measurement of fidelities of entangled output states, since for instance . Fortunately, in our setup the projection onto the maximally entangled states of qubits 1 and 2 can be accomplished deterministically because both these qubits are carried by a single photon. We only have to rotate the HWP2 by which acts as a CNOT gate between the polarization and spatial qubits carried by a single photon and transforms the maximally entangled states onto product states. From the measurements we have determined which together with as given in Eq. (10) yields . We can see that at the cost of measuring fidelities of entangled states we obtain a slightly higher fidelity bound. This is universally valid because . Since for all , the average state fidelities also provide an upper bound on the gate fidelity Hofmann05 (), . Specifically, we get .

Finally, we explicitly demonstrate the capability of the three-qubit CCZ gate to generate entanglement from input separable states , where (partially entangled inputs are considered in the Appendix. The corresponding output state reads hence the gate generates GHZ-type three-qubit entangled states GHZ89 (); Dur00 (). As an example, in Fig. 3 we plot the reconstructed output state corresponding to the input product state . The fidelity of the reconstructed state with the ideal state is and its purity reads .

In summary, we have proposed a lower bound on the quantum process fidelity of multiqubit quantum gates which generalizes the original Hofmann bound and we used it to experimentally characterize linear optical quantum CCZ gate. The advantage of our generalized fidelity bound is that only fidelities of product multiqubit quantum states need to be measured and the required number of measurement settings is much smaller than what is needed for full quantum process tomography or gate fidelity estimation by Monte Carlo sampling SI (). We hope that our work will represent a useful addition to the toolbox of methods for efficient and experimentally feasible characterization of quantum devices.

###### Acknowledgements.

This work was supported by the Czech Science Foundation (13-20319S). M.S. acknowledges support by the Operational Program Education for Competitiveness - European Social Fund (project No. CZ.1.07/2.3.00/30.0004) of the Ministry of Education, Youth and Sports of the Czech Republic.## References

- (1) M. A. Nielsen and I. L. Chuang, Quantum Computation and Quantum Information (Cambridge University Press, Cambridge, UK, 2000).
- (2) Quantum state estimation, No. 649 in Lect. Notes Phys., M. Paris and J. Řeháček, eds., (Springer, Heidelberg, 2004).
- (3) D. Gross, Y.-K. Liu, S. T. Flammia, S. Becker, and J. Eisert, Phys. Rev. Lett. 105, 150401 (2010).
- (4) A. Shabani, R.L. Kosut, M. Mohseni, H. Rabitz, M.A. Broome, M.P. Almeida, A. Fedrizzi, and A.G. White, Phys. Rev. Lett. 106, 100401 (2011).
- (5) S. T. Flammia and Y.-K. Liu, Phys. Rev. Lett. 106, 230501 (2011).
- (6) M. P. da Silva, O. Landon-Cardinal, and D. Poulin, Phys. Rev. Lett. 107, 210404 (2011).
- (7) L. Steffen, M. P. da Silva, A. Fedorov, M. Baur, and A. Wallraff, Phys. Rev. Lett. 108, 260506 (2012).
- (8) A. Bendersky, F. Pastawski, and J.P. Paz, Phys. Rev. Lett. 100, 190403 (2008).
- (9) J. Emerson, M. Silva, O. Moussa, C. Ryan, M. Laforest, J. Baugh, D.G. Cory, R. Laflamme, Science 317, 1893 (2007).
- (10) D.M. Reich, G. Gualdi, and C.P. Koch, Phys. Rev. A 88, 042309 (2013); arXiv:1305.5649 (2013).
- (11) H.F. Hofmann, Phys. Rev. Lett. 94, 160504 (2005).
- (12) R. Okamoto, H.F. Hofmann, S. Takeuchi, and K. Sasaki, Phys. Rev. Lett. 95, 210506 (2005).
- (13) X.H. Bao, T.Y. Chen, Q. Zhang, J. Yang, H. Zhang, T. Yang, and J.W. Pan, Phys. Rev. Lett. 98, 170502 (2007).
- (14) A.S. Clark, J. Fulconis, J.G. Rarity, W.J. Wadsworth, and J.L. OBrien, Phys. Rev. A 79, 030303(R) (2009).
- (15) W.B. Gao, P. Xu, X.-C. Yao, O. Gühne, A. Cabello, C.-Y. Lu, C.-Z. Peng, Z.B. Chen, and J.W. Pan, Phys. Rev. Lett. 104, 020501 (2010).
- (16) W.B. Gao, A.M. Goebel, C.Y. Lu, H.N. Dai, C. Wagenknecht, Q.A. Zhang, B. Zhao, C.Z. Peng, Z.B. Chen, Y.A. Chen, and J.W. Pan, PNAS 107, 20869 (2010).
- (17) X.Q. Zhou, T.C. Ralph, P. Kalasuwan, M. Zhang, A. Peruzzo, B.P. Lanyon, and J.L. O’Brien, Nature Commun. 2, 413 (2011).
- (18) B.P. Lanyon, C. Hempel, D. Nigg, M. Müller, R. Gerritsma, F. Zähringer, P. Schindler, J.T. Barreiro, M. Rambach, G. Kirchmair, M. Hennrich, P. Zoller, R. Blatt, and C.F. Roos, Science 334, 57 (2011).
- (19) B.P. Lanyon, M. Barbieri, M.P. Almeida, T. Jennewein, T.C. Ralph, K.J. Resch, G.J. Pryde, J.L. O’Brien, A. Gilchrist, and A.G. White, Nature Phys. 5, 134 (2009).
- (20) T. Monz, K. Kim, W. Hänsel, M. Riebe, A.S. Villar, P. Schindler, M. Chwalla, M. Hennrich, and R. Blatt, Phys. Rev. Lett. 102, 040501 (2009).
- (21) Pieter Kok, W. J. Munro, Kae Nemoto, T. C. Ralph, Jonathan P. Dowling, and G. J. Milburn, Rev. Mod. Phys. 79, 135 (2007).
- (22) A. Jamiolkowski, Rep. Math. Phys. 3, 275 (1972).
- (23) M.-D. Choi, Linear Algebra Appl. 10, 285 (1975).
- (24) B. Bell, A.S. Clark, M.S. Tame, M. Halder, J. Fulconis, W.J. Wadsworth, and J.G. Rarity, New J. Phys. 14, 023021 (2012).
- (25) See Appendix for detailed proof of the bound (9), comparison of our technique with Monte Carlo sampling, and discussion of generation of a maximally entangled three-qubit GHZ state.
- (26) M. Ježek, I. Straka, M. Mičuda, M. Dušek, J. Fiurášek, and R. Filip, Phys. Rev. Lett. 107, 213602 (2011).
- (27) N. K. Langford, T.J. Weinhold, R. Prevedel, K. J. Resch, A. Gilchrist, J. L. OBrien, G. J. Pryde, and A. G. White, Phys. Rev. Lett. 95, 210504 (2005).
- (28) N. Kiesel, C. Schmid, U. Weber, R. Ursin, and H. Weinfurter, Phys. Rev. Lett. 95, 210505 (2005).
- (29) T. C. Ralph, N. K. Langford, T. B. Bell, and A. G. White, Phys. Rev. A 65, 062324 (2002).
- (30) H.F. Hofmann and S. Takeuchi, Phys. Rev. A 66, 024308 (2002).
- (31) K. Lemr, A. Černoch, J. Soubusta, K. Kieling, J. Eisert, and M. Dušek, Phys. Rev. Lett. 106, 013602 (2011).
- (32) D. M. Greenberger, M. Horne, A. Zeilinger, Bells theorem, Quantum Theory, and Conceptions of the Universe, ed. M. Kafatos, Kluwer, Dordrecht 69 (1989).
- (33) W. Dür, G. Vidal, and J.I. Cirac, Phys. Rev. A 62, 062314 (2000).

*

## Appendix A

### a.1 Proof of the fidelity bound for -qubit gates

Our aim is to prove a bound on quantum process fidelity between the actually implemented quantum operation and an ideal target unitary gate ,

(12) |

for arbitrary -qubit unitary gate . Here denote average output state fidelities for different input product bases. Analogously to the case of three qubit CCZ gate we define

(13) |

a maximally entangled state on two copies of an -qubit input Hilbert space. The Choi matrix of an -qubit unitary gate reads

(14) |

We define the process fidelity of a quantum gate with respect to the -qubit unitary gate as a normalized overlap of the Choi matrices, , where the term appears due to the normalization of .

The probe product states are straightforward generalization of the states specified in Table I of the main paper. In this case index specifies an element of an -qubit orthonormal product basis formed from basis vectors on each qubit except for -th qubit, where basis is used. Explicitly, we can write

(15) |

where is a computational basis state with forming a binary representation of integer , and denotes the single-qubit Hadamard gate. Note that an -qubit controlled-Z gate transforms the input product states onto product states at the output and the preparation basis and the measurement basis coincide. The gate is diagonal in computational basis and it introduces a phase shift if and only if all qubits are in state ,

(16) |

Similarly to the three-qubit case, the average output state fidelity is defined as

(17) |

where

(18) |

and

(19) |

denote the success probability and output fidelity for input state , and . We can express in a matrix form , where

(20) |

We can now rewrite the inequality (12) as:

(21) |

where

(22) |

Since the trace of a product of two positive semidefinite operators is non-negative, we would prove our claim by showing . In order to show this we define an operator with the same eigenvalues and express it using the definition of :

(23) |

It is useful to divide the qubit Hilbert space on which operator acts into two-qubit subsystems formed by the -th qubit of the input and the -th qubit of the output. We introduce a unitary operator which groups together the -th input and output qubits,

(24) |

In this way the maximally entangled state can be seen as , where are the Bell states and the subscripts indicate the two-qubit subsystems. Let us now analyze terms of the type . For any they are factorized with respect to a subsystem of the -th input and output qubit, because the state is completely factorized. In any such subsystem we can find only one of four states . Let us note that

(25) |

where are the other two Bell states. The identities (25) allow us to rewrite the sums of projectors as

Using the four Bell states we can express the identity on the two qubit Hilbert space as . This enables us to rewrite Eq. (23) using Eq. (A.1) in the following form

(27) |

where . Since is unitary, operator has the same eigenvalues as . Moreover, is diagonal in the basis formed by tensor products of Bell states, hence the eigenvalues can be directly determined from the expression (27). One eigenstate is given by tensor product of copies of and its eigenvalue reads . eigenstates are formed by tensor products of a single copy of and copies of or and they all correspond to eigenvalue . For we have eigenvalues formed by tensor products of copies of and copies of whose eigenvalue is equal to . All the remaining eigenstates correspond to the eigenvalue . We can see that all the eigenvalues of are nonnegative for which proves that is a positive semidefinite operator and as a consequence the same holds for operator . This proves the fidelity bound (12).

In a similar fashion we can prove an upper bound on quantum gate fidelity,

(28) |

Taking into account Eq. (A.1) and the definition of , we find after some algebra that the inequality (28) is equivalent to the condition

(29) |

This latter inequality is obviously satisfied which proves (28).

The bound (12) will be tight for any whose support lies in the subspace spanned by the eigenstates of with eigenvalue . The multiplicity of the eigenvalue and the structure of the corresponding eigenstates follows from the above analysis of eigenstates and eigenvalues of operator . In particular, for this dimensional subspace is spanned by the mutually orthogonal basis states generated by unitary operations , where , and , . Here is a unitary operation that applies phase shift to th qubit,

(30) |

and . It is easy to check that if the actually implemented operation is then equality holds in Eq. (12) and the lower bound is thus equal to the true gate fidelity . For we obviously have as well as . On the other hand, if then and , hence . Note that in this case because the phase flip maps the input states of th qubit onto orthogonal states. In contrast, all probe states belonging to other bases are unchanged by . The fidelity bound (12) is thus tight if the actually implemented operation is either the desired unitary or a unitary preceded by a phase flip on a single qubit. The bound will be tight also for any mixture or coherent superposition of these operations. The case is special because we have additional eigenstates with eigenvalue . These eigenstates correspond to two-qubit unitary operations , , , and , where .

Since each average state fidelity is larger or equal to the gate fidelity , the difference between the true fidelity and the lower bound (12) will increase at most linearly with the number of qubits N,

(31) |

For large number of qubits and high level of noise it may happen that the bound (12) will be too small to be of any use. However, with increasing the -qubit controlled Z gate becomes very similar to the identity operation as wittnessed by their fidelity

(32) |

On inserting the explicit expressions (13) and (16) for and into Eq. (32), we obtain

(33) |

In any experiment attempting to certify the quality of -qubit controlled Z gate by fidelity measurement, fidelity achievable by simply doing nothing has to be exceeded. This requires an exponentially small gate infidelity, . It is instructive to rewrite the fidelity bound (12) as a bound on the gate infidelity ,

(34) |

Since , the bound (12) will certainly exceed provided that the true gate infidelity will satisfy , which represents only a small extra overhead in gate quality compared to the dominant exponential factor .

Our construction of the set of input states was tailored for the multiqubit controlled Z gates, but it is actually well suited for a much wider class of all unitary operations that are diagonal in the computational basis,

(35) |

where denotes an input-state dependent phase shift. For all unitary operations (35) it holds that the output states are product states of single-qubit states. Therefore, the output-state fidelities can be directly determined by single-qubit measurements similarly to the case of the controlled-Z gate.

However, for other -qubit gates than (35) the output states may be entangled. In such case direct determination of output state fidelity would require measurement in basis of entangled states, which may be difficult or even impossible for certain experimental implementations. In that case one would have to estimate the fidelity of output entangled states from measurements in various product bases, e.g. by the Monte Carlo sampling Flammia11 (); Silva11 (). This would inevitably increase the required number of measurement settings. Consequently, other approaches such as Monte Carlo sampling of the gate fidelity or measurement of the original Hofmann bound Hofmann05 () may become preferable for such gates.

### a.2 Comparison with Monte Carlo sampling

Our method of characterization of the -qubit controlled-Z gates as well as the Monte Carlo sampling technique proposed in Refs. Flammia11 (); Silva11 () are designed such that it suffices to prepare product -qubit input states and perform single-qubit measurements on the output. This is important, because in many experiments it may be difficult or impossible to prepare entangled input states or to perform measurements in entangled basis. The main advantage of our procedure is that it requires much smaller number of different measurement settings than Monte Carlo sampling. A single measurement setting represents a specific combination of input state and output measurement. In our experiment, both input states and measurement bases are set by waveplate rotations and each change of measurement setting requires about seconds mainly due to a limited speed of motorized rotation stages. By contrast, the data acquisition for a fixed setting is fast, because the average observed two-photon coincidence rates are of the order of per second for each pair of detectors.

Experimental Monte Carlo estimation of fidelity of a three-qubit quantum Toffoli gate was experimentally demonstrated by Steffen et al. Steffen12 (). As shown in Ref. Steffen12 (), fidelity of -qubit Toffoli gate can be expressed as a linear combination of average values of tensor products of single-qubit Pauli operators , , , and . Each tensor product includes six Pauli operators: for the input qubits and for the output qubits. Experimental determination of a single average value requires sequential preparation of product input states that are the eigenstates of the first Pauli operators and the output qubits are measured in a product basis of eigenstates of the last Pauli operators. A careful analysis reveals that all average values of tensor products including can be determined from measurements of other average values where a different Pauli operator replaces . Even after this reduction we are left with average values that need to be determined. This method thus requires different measurement settings, which is times higher than the measurement settings required by our protocol.

In our experiment we have access to only out of the possible measurement outcomes, because part of the signal is deflected by the second calcite beam displacer and not detected. Moreover, in order to avoid the need to calibrate the detector efficiencies, we have utilized only a single coincidence signal D2D3. For each measurement setting we used different waveplate settings such that the coincidence detection of photons by detectors D2 and D3 corresponded to the projection onto different eigenstates of the -qubit measurement basis. Estimation of fidelity using the procedure of Refs. Flammia11 (); Silva11 (); Steffen12 () would thus in our case require different settings. Just preparing all these settings would take about hours which exceeds the stability time of the Mach Zehnder interferometer formed by the calcite beam displacers and of the Hong-Ou-Mandel dip on the central partially polarizing beam splitter. By contrast, our fidelity estimation procedure requires only different settings even if we use only a single coincidence signal D2D3. For each waveplate setting we measured the number of coincidences in and for each input state we detected about coincidences in total. The whole measurement lasted about hours and most of this time was used for data acquisition.

At a cost of larger number of required measurement settings, Monte Carlo sampling allows to obtain an estimate of the true gate fidelity while our approach yields only a lower and upper bound on the gate fidelity. One may conjecture that with increasing number of qubits the Monte Carlo sampling will eventually become more efficient even in terms of the number of experimental settings, because the number of required distinct settings depends only on the desired accuracy of the Monte Carlo estimate and not on the system size Flammia11 (); Silva11 (). Let us therefore discuss this issue in more detail. If one wants to obtain a Monte Carlo fidelity estimate that with probability will be -close to the true fidelity , , then the number of required experimental settings reads

(36) |

These settings need to be randomly chosen from all the relevant settings according to a specific relevance distribution Flammia11 (); Silva11 (). According to formula (36), achieving a precision () with probability () would require about settings. For a three-qubit CCZ gate this largely exceeds the total number of relevant settings. In such case one can directly perform measurements for all the relevant settings Steffen12 (), which eliminates the error of fidelity estimate due to Monte Carlo sampling. As shown in the previous section, the -qubit controlled-Z gate becomes exponentially close to the identity operation with the increasing number of qubits, c.f. Eq. (33). In order to reliably certify that the gate fidelity exceeds , the error has to be of the order of for large . For this specific task we thus obtain asymptotic scaling . In contrast, our method requires only distinct measurement settings.

We can conclude that the gate fidelity estimation based on the lower bound (12) is suitable for systems where a change of measurement setting requires significant effort. On the other hand, Monte Carlo sampling is particularly well suited for platforms where changes of measurement settings are fast and easy to implement. Both techniques could also be combined. For instance, our method can be used for a quick assessment of the gate performance during its construction and fine-tuning, followed by a more precise but also more time-consuming characterization of the resulting gate by Monte Carlo sampling.

### a.3 Generation of three-qubit GHZ state

In our experiment, entanglement between spatial and polarization qubits of the signal photon can be deterministically generated and controlled by a suitable rotation of the HWP1 that addresses only the lower path in the interferometer formed by the two beam displacers. This allows us to investigate the action of the three-qubit CCZ gate on partially entangled input states. In particular, we have tested the fusion of a two-qubit maximally entangled Bell state

(37) |

with a third qubit prepared in state into a three-qubit maximally entangled GHZ state,

(38) |

The output state was reconstructed with the Maximum Likelihood method and it is shown in Fig. S.1. Note that a Hadamard basis is used for the third qubit in this figure. The generated state is very close to the ideal GHZ state (38) as witnessed by a high state fidelity and purity . Note the nonzero imaginary parts of the off-diagonal density matrix elements which can be attributed to the uncompensated residual phase shift in the interferometer, . If we compensate for this phase shift on the experimental data, the fidelity increases to .