A universal scheme for robust self-testing in the prepare-and-measure scenario

We consider the problem of certification of arbitrary ensembles of pure states and projective measurements solely form the experimental statistics in the prepare-and-measure scenario assuming the upper bound on the dimension of the Hilbert space. To this aim we propose a universal and intuitive scheme based on establishing perfect correlations between target states and suitably-chosen projective measurements. The method works in all finite dimensions and allows for robust certification of the overlaps between arbitrary preparation states and between the corresponding measurement operators. Finally, we prove that for qubits our technique can be used to robustly self-test arbitrary configurations of pure quantum states and projective measurements. These results pave the way towards practical application of the prepare-and-measure paradigim to certification of quantum devices.


Introduction
Quantum devices are becoming more and more complex and the possibilities of their precise control and manipulation keep increasing. Recently reported demonstration of quantum computational advantage by Google [1] is only an intermediate milestone and quantum technologies have a potential real-life applications in fields such as quantum sensing [2], simulation of quantum systems [3], efficient computation [4] and machine learning [5,6].
With the increasing complexity of quantum systems, there is a growing need for certification and verification of their performance. This task is usually realized via the combination of quantum tomography and various benchmarking schemes (see [7] for a recent review). However, these methods, despite being powerful and universally applicable, depend on the assumptions about the inner workings of quantum systems, such as perfect measurements or uncorrelated and independent errors. In contrast to these approaches self-testing is a method which aims at proving the uniqueness of the implemented states or measurements based solely on the observed statistics and under minimal physical assumptions.
The paradigm of self-testing was first introduced in the context of quantum cryptography [8], with the aim to obtain trust in cryptographic devices (see [9] for a recent review).
Initially, it was applied to correlations observed in the Bell scenario [10] (see e.g., [8,[11][12][13]). The most know result in this area is certification of the singlet state in the case of maximal violation of the Clauser-Horne-Shimony-Holt Bell inequality [14].
With the growing number of results on self-testing, more and more attention is being drawn to prepare-and-measure scenarios, that are more experimentally appealing as compared to the one of Bell (see e.g., [15][16][17][18]). Therein, one does not need to ensure space-like separation of the measurement events by two parties; in contrast, one party, Alice, communicates some of her states to Bob, who measures them in some basis of his choice. In order to get meaningful certification results further assumptions are needed. In the most commonly studied semi-device-independent (SDI) scenario [19], one assumes that the dimension of the quantum system used for transmitting information is bounded from above. There exist, however, alternative approaches based on other constraints like minimal overlap [16], mean energy constraint [20] or entropy constraint [21].
It is important to point out that without the assumption on the dimension, or an equivalent, no certification of quantum systems is possible in the prepare-and-measure scenario. The main reason is the fact that any observed distribution resulting from quantum preparations and quantum measurements can also be obtained through classical communication if the latter is unconstrained (see, e.g., Ref. [22]). In this work, we chose the assumption of the bounded dimension as we find it physically motivated. For example, if photons' polarization is used as a carrier of quantum information, it is natural to assume this upper bound to be equal to two. By ensuring that no other degree of freedom of photons is correlated with the choice of her preparation, Alice can gain trust that no additional information can be leaked to Bob or an adversary.
Let us briefly recap on what has been done so far in the area of SDI self-testing. First, self-testing results were proven for mutually unbiased bases (MUBs) in dimension 2, for both state ensembles and measurements [23]. This was further generalised to SDI certification of mutual unbiasedness of pairs of bases in an arbitrary dimension in Ref. [24]. Methods for self-testing of extremal qubit positive operator-valued measures (POVMs) were proposed in [25,26] and further extended to symmetric-informationally complete (SIC) POVMs [27]. Importantly, all of the above results either rely on numerical approaches, for general state preparations and POVMs, or work only for special scenarios that exhibit many symmetries.
In this work we propose a simple analytical method allowing to certify overlaps between preparations of arbitrary pure states and arbitrary projective measurements in qudit systems. The scheme relies on establishing perfect correlations between preparation states and outcomes of suitably-chosen projective measurements. The method is universally applicable and robust to experimental noise. We prove that for qubits our SDI certification method can be used to obtain a robust self-testing result for arbitrary preparations of pure qubit states and corresponding projective measurements. While for higher dimensions we do not show self-testing, our scheme allows for SDI certification of numerous inherently quantum properties. The examples include, but are not limited to: arbitrary overlaps between any number of measurement bases, MUB conditions, information-completeness of measurements, and SIC relations among measurement effects.
We believe that our findings greatly extend the applicability of the paradigm of selftesting in the SDI setting. Our approach should be of interest to the researchers working on certification of near-term quantum computers [7] since our scheme can be used to characterize state-preparation and measurement errors, which is one of the major problems in the certification of quantum devices [28]. We also expect possible cryptographic applications as our setup is very similar to the one of textbook quantum key distribution schemes A B Figure 1: The idea of the certification scheme for the overlaps between states. Alice chooses her inputs a, x and Bob his input y. Alice sends states x a to Bob, who produces his outcome b. After establishing perfect correlations between preparation states and measurements for y = x, the rest of the statistics can be used to compute the overlaps between the preparation states. This can be used to directly certify presence of coherences between Alice's input states and between effects of measurements implemented by Bob. [29,30]. The perfect correlations can be utilized for generation of the secret key, while the rest can be used to estimate the security. Thus, our methods can be directly applied for certification of quantum devices implementing protocols such as BB84 [29], which is normally achieved by introducing additional preparation states or measurement bases [31].
Before we proceed, let us first fix some of the notations used in this paper. Let X be a linear operator acting on a finite-dimensional Hilbert space H. Throughout the paper we use ||X ||, ||X || F to denote operator norm and Frobenius norm of X. We will also use |n| to denote the Euclidean norm of n ∈ R 3 , and [n] to denote an n-element set {1, 2, . . . , n}.

Description of the scenario
We consider the prepare-and-measure scenario in which in each run of the experiment Alice prepares a quantum d-level system in one of the states from a finite set of preparations x a , for which we use two indexes x ∈ [n] and a ∈ [d]. The purpose of the double index will become clear later. Subsequently, Bob performs a measurement on this state with a finite choice of measurement settings y ∈ [n] having the possible outcomes b ∈ [d]. We assume that the parties do not communicate in any other way and do not have access to any entangled states or shared randomness [32]. This implies the standard i.i.d. assumption that in all the experiment runs, the same choices of preparations lead to the identical and uncorrelated quantum states prepared by Alice's device. The equivalent assumption is placed on Bob's measuring device. The role of these assumptions is discussed later in the text. This also implies that the observed statistics p(b|a, x, y) are given by the Born rule i.e., p(b|a, x, y) = tr( x a M y b ), where M y = (M y 1 , M y 2 , . . . , M y d ) is a quantum measurement (POVM) performed by Bob upon the choice of the setting y. The goal of SDI certification is then to identify the preparation states and the measurements, or their properties, based solely on the observed statistics p(b|a, x, y) assuming the upper bound on the dimension d and the validity of Born's rule. We say that certain states x a and measurements M y can be self-tested if the observed statistics specify these objects uniquely up to a unitary transformation and, perhaps, a global transposition.

Certification of overlaps
We start with a presentation of our scheme for certifying pairwise overlaps between pure qudit preparation states and between the corresponding projective measurements. By "corresponding" we mean that in our scheme we set these states and measurements to be "equal" in a sense that x a = ( x a ) 2 = M x a for all a ∈ [d] and x ∈ [n]. This is the reason why we chose to enumerate the preparation states with two indexes. The choice of d and n is arbitrary as long as d > 1 and n ≥ 1. In what follows we will refer to these objects as target pure states and target measurements respectively. Their experimental counterparts we denote as˜ x a , andM y respectively. By "experimental" we mean any states and measurements defined over a Hilbert space of dimension at most d and that reproduce the observed statistics i.e.,p(b|a, x, y) = tr(˜ x aM y b ). Clearly, we do not assume that the experimental states and measurement have to be "equal". Neither do we assume any properties of experimental states or measurements like the purity of the projective character.
The idea of our certification scheme is very intuitive, yet powerful (see Fig. 1). Assume that Alice and Bob prepared their devices in a way thatp(b|a, x, y) = 1, whenever y = x and b = a. In other words, outcomes of Bob's measurement are perfectly correlated with the preparations of Alice (whenever x = y). Since we assumed the upper bound of d on the Hilbert space's dimension in which experimental states and measurements are defined, and in this space, we have a set of d quantum states and a POVM with d effects which produce perfect correlations, we can conclude that, first, the Hilbert space's dimension must be exactly d, and second that˜ x a =M x a , for all a ∈ [d] and x ∈ [n]. Clearly, after these perfect correlations are established, the "cross-terms", can be used to compute the overlaps between the preparation states and between measurement operators:p(b|a, x, y) = tr(˜ ). Therefore, if the experimental statisticsp(b|a, x, y) match the target statistics p(b|a, x, y), we can certify that overlaps between experimental states match those of the target states. The same holds for the corresponding measurement operators.
Our method can be also applied when experimental statistics do not match exactly the target ones.
Moreover, for all x = x , a = a , y = y , and b = b , we have The parameter ε accounts for all possible experimental errors, including the finite statistics' error that can be estimated using standard tools of statistical analysis.
Proof. We start with a straightforward proof of Eq. To prove the bounds on the norms of experimental states in Eq. (1), we fix a setting x and use a decomposition:M where λ a is the largest eigenvalue ofM x a , |φ a φ a | is the corresponding eigenvector and, Rest a is a positive-semi-definite operator satisfying φ a |Rest a |φ a = 0 (to keep the derivations legible, we omit the index x). Using the fact that observed statistics are ε close to the target ones we get:  We now proceed to the proof of Eqs. (3). We start with the one for the overlaps between preparation states. The proof is given by the following sequence of inequalities which hold for every a = a , x = x : All of the above inequalities are pretty straightforward apart from tr((M x a ) 2 ) ≤ 1 + d 2 ε 2 that we prove below. For this we again use the partial spectral decomposition form Eq. (4) (without writing the superscript x as above) which implies: The proof for the overlaps of POVM effects is very similar to the one for states with the only difference being the following inequality: that is used in the second step in the proof in Eq. (7). One can easily verify the validity of this inequality by writing once more the decompositionM x a = λ a |φ a φ a | + Rest a and remembering that tr(Rest a ) ≤ dε.
The above result states that if the statistics observed in our certification scheme vary just a little bit form the target ones, the overlaps of the experimental states are also close to the overlaps between target states (and analogously for measurements). To our best knowledge analogous results have been previously known only for very special symmetric target states and measurements forming MUBs [23,24].
In Appendix B (Lemma 1) we improve the above bounds for the case of qubit systems. Moreover, in Appendix A we prove, by giving explicit examples, that the bounds in Eq. (3) are tight in the first orders in √ ε and d.

Self-testing of qubits
We now show that certification of overlaps allows to prove robust self-testing result for arbitrary pure qubit preparations and projective measurements appearing in our certification scheme.
where (·) (T ) is a potential transposition with respect to a fixed basis in C 2 that may have to be applied to all experimental states and measurements at the same time. Moreover, functions f, g : [0, ε 0 ) → R + depend solely on the target states and measurements and, for small ε, have the asymptotics f (ε) ∝ ε, g(ε) ∝ ε.
In the above we used the fidelity F ( , σ) = tr( σ) to indicate the closeness between rotated experimental states and target pure states (and analogously for measurements), following existing literature. The case ε = 0 corresponds to ideal reconstruction of target states and measurements after applying a suitable isometry. We remark that we allow only unitary operations (and possible transposition), as opposed to general channels [23,26], to be applied to the experimental states in order to approximate the target states as well as possible.
In Appendix B we give a formal version of the above result and its proof. Moreover, we present there robustness bounds expressed in terms of the trace distance and its analogue for measurements [33]. We remark that the functions f, g become unbounded once Bloch vectors of target qubit states become singular, i.e., once the target states are close to being aligned in a space of smaller dimension.
Remark. Certification of overlaps between pure states in general does not allow for their self-testing in higher-dimensional systems. This is e.g., due to the existence of unitary inequivalent sets of SIC-POVMs for d = 3 [34] and MUBs for d = 4 [35] (even if we allow for complex conjugation).
Sketch of the proof. We give a full proof for the ideal case (ε = 0) below. From Theorem 1 it follows that for all x, x , a, a we have˜ x a =M x a and tr(˜ x a˜ x a ) = tr( x a x a ). Using the Bloch representation, x a = 1 2 (1 + n x a · σ), we can conclude that alsoñ x a ·ñ x a = n x a · n x a , where n x a andñ x a are Bloch vectors of x a and˜ x a respectively. Assume now that the vectors n 1 1 , n 2 1 , n 3 1 are linear independent. Let O be the linear transformation defined by On x 1 =ñ x 1 , x = 1, 2, 3, and let L be the matrix whose rows are the vectors n  For the general case ε > 0 we consider Cholesky factorisations of Gram matrices, denoted by Γ andΓ, of Bloch vectors n 1 1 , n 2 1 , n 3 1 and their experimental counterparts respectively. Theorem 1 is then used to bound Γ −Γ F and utilize results of Ref. [38] to gauge how much the Cholesky decompositions of Γ andΓ differ in the Frobenius norm. The latter can be connected to the average fidelity between the selected target and experimental states. The robustness for the remaining states follows from the fact that they can be decomposed (as operators) using the three initially chosen target states and the identity.
If vectors from the set {n x a } span two dimensional space then the same arguments for both ε = 0 and ε > 0 can be repeated for the considered subspace. Importantly, in this case additional transposition is not necessary.

Examples
We now apply the quantitative formulation of Theorem 2 to lower-bound average fidelities for different configurations of target states as a function of the allowed error ε. In Figure 2 we present results for eigenstates of n = 2 and n = 3 Pauli matrices (i.e., states forming n = 2 and n = 3 qubit MUBs), and states belonging to two biased projective measurements satisfying tr( 1 a 2 a ) = 1+α 2 , a = 1, 2 where we take α ∈ [0, 1]. For n = 2 MUBs we compare our results with Ref. [23] that focuses on self-testing of qubit MUBs. The results of Ref. [23] give the upper bound on average fidelity equal 0.75 for the deviation of 0.1 in the figure of merit. In our scheme this happens for ε 0.033 as shown on Fig. 2. To test the versatility of our scheme, we also applied it to n = 3 MUBs, trine and tetrahedral configurations of qubit states. Quantitative results concerning these examples are listed in Table 1, while detailed derivations are given in Appendix D. For trine and tetrahedral configurations the robustness is obtained via the so-called Procrustes problem, described in Appendix C, based on Ref. [39]. For cases other than two MUBs we cannot make any comparison with the existing literature since, to our best knowledge, these case have not been studied previously.
Trine ≈ 0.058 19 3 Tetrahedron ≈ 0.037 10 Table 1: Results of quantitative variant of Theorem 2 applied to different configurations of target quantum states. The threshold ε 0 sets the maximal noise level which is tolerated by our scheme. The where 1 − f is the lower bound on the average fidelity from Eq. (9).

Shared randomness
Throughout the article we assumed that preparation and measurement devices are uncorrelated, which is often true in practice. However, one may also consider a situation in which Alice and Bob share a random variable λ, that they can use to coordinate their actions in a given round of the experiment. The most general statistics that can be generated in such a scenario can be expressed as p(b|a, Interestingly, the presence of shared randomness makes our main results, as stated by Theorems 1 and 2, inapplicable. The easiest way to see it is to consider the following simple example of n = d = 2, one bit of shared randomness λ ∈ {1, 2}, and˜ 1,2 a = |a a|, M 1,2 b = |b b|. This clearly satisfies the requirement onp(a|a, x, x) = 1. Now, Alice's and Bob's devices can decide to "flip" their preparations and measurement operators whenever x = 2, y = 2 and λ = 2 (note that λ can be distributed in an arbitrary way). This procedure does not affect the correlationsp(a|a, x, y = x), but it can be used to setp(a|a, 1, 2) to an arbitrary value.
Additionally, we believe that in the presence of shared randomness, the usual notion of self-testing in the SDI setting has to be reconsidered. Specifically, for any quantum realisation giving the statistics p(b|a, x, y) = tr( x a M y b ), one can always consider a strategy in which with probability p(λ) Alice prepares states x where U λ is some arbitrary unitary transformation depending on λ. Clearly, such strategy reproduces the original statistics, and makes it impossible to find a single unitary that connects the target and experimental states (or measurements).
A very similar argument as above can be applied to situations of non-identical preparations of states and non-identical measurements across different runs of the experiment. Indeed, the value of a given run of the experiment is accessible to both Alice and Bob and can be considered a shared random variable λ that controls both Alice's and Bob's devices. Once again, the existence of a single unitary that connects the target and experimental states can never be guaranteed.
While, we do not consider the assumption on no shared randomness strong, below we propose a modification of our SDI certification scheme that allows to certify overlaps between arbitrary pure states even in the presence of shared randomness. The idea is to introduce, for every pair of non-orthogonal states, a suitable intermediate state [40], that enforces fixed overlaps between experimental states in every round of the experiment.
Recall that in our certification scheme we consider pure target qudit states x a and Letp(b|z, y) denote the experimental statistics, corresponding to inputs z, y and outcome b. In the ideal scenario, in which experimental statistics satisfy assumptions of Theorem 1 with ε = 0, assume additionally thatp(a|z, x) +p(a |z, x ) = 1 + p(a |x, a, x ) . Below we prove that under the above assumptions for all λ we have tr(˜ x a (λ)˜ x a (λ)) = tr( x a x a ). Since in the ideal case overlaps between preparation states do not depend on λ and match the target value, our modified certification scheme works also in the presence of shared randomness. In the noisy scenario one can generally expect to be able to upper-bound the probability (over the choice of λ) of the deviations from perfect correlations between states and measurements, as a function of the error ε. We postpone the discussion of this interesting point to the future work.
Proof of soundness of certification in the presence of shared randomness. Consider a general physical realisation of experimental statisticsp(b|x, a, y),p(b|z, y) via classically correlated preparations and measurements on C d : In what follows we prove that if the above constraints are satisfied, then for all 1 : Since tr(˜ x a (λ)M x a (λ)) ≤ 1, we get that for all λ we have tr(˜ x a (λ)M x a (λ)) = 1. Since this reasoning can be repeated for all a ∈ [d] (for the fixed value of x) and since operatorsM x a form a POVM on C d , we finally get Eq. (15).
The proof of Eq. (16) is more involved and relies on both Eqs. (13) and (14). Specifically, from Eq. (13) and the already established identity˜ x a =M x a , it follows that Eq. (14) is equivalent to: where moreover: Using Bloch representation of qubit states (states˜ x a (λ),˜ x a (λ) are pure and hence span a two dimensional subspace of C d ) it is straightforward to obtain the bound: After setting g(λ) = tr(˜ x a (λ)˜ x a (λ)) and using Eq. (19) we obtain: Using Chauchy-Schwartz inequality for the left hand side of the above inequality we finally get: which is equivalent to saying that the variance of the random variable g(λ) vanishes. Therefore, g(λ) = α, where α is some numerical constant. We conclude the proof by noting that from Eq. (19) it follows that α 2 = tr( x a x a ) which implies Eq. (16).
7 Extension of the scheme to SDI characterization of rank-1 non-projective measurements In our work we focus on self-testing of arbitrary configurations of preparation states and projective measurements. In this section we discuss possible extension of our results to certification of properties of general rank-1 measurements in arbitrary dimension d. To that end, we introduce additional states coming from suitably-chosen orthonormal bases per every effect of the measurement we want to certify. With the help of these extra states (and corresponding projective measurements) we can e.g., certify the following properties of POVMs in arbitrary dimension d: . Assume now that in the idealized case we observe statistics satisfying: From the second set of conditions we conclude that { x a } a forms, as before, a basis of pure states for each x. From the first condition in Eq. (23) we get that N has to be a rank-1 POVM and, moreover, that b 1 = σ b (N b is orthogonal to all of the states except the one with a = 1). Consequently, we have tr( b . This fact together with the measured overlaps tr( b gives the information about the overlaps tr (N b N b ) between effects of the POVM N.
The knowledge of all overlaps tr (N b N b ) (including b = b) and the fact that N is a rank-1 POVM allow to certify many interesting properties of N. First, as long as m ≤ d 2 we can certify extremality of N. This follows from the fact that rank-1 POVMs are extremal if and only if their effects are linearly independent (see e.g., Ref. [41]). Linear independence can be directly inferred from the experimentally accessible moment matrix Γ b,b = tr (N b N b ). Specifically, Γ is non-singular if and only if operators {N b } b are linear independent. Now, if m = d 2 we can use the same reasoning to infer information completeness of N. Finally, from the moment matrix Γ we can directly verify the SIC property i.e., the condition

Discussion
We have presented a systematic analytical scheme for noise-resilient certification of overlaps between arbitrary configurations of pure quantum states and rank-1 projective measurements in the prepare-and-measure scenario. For qubits our scheme can be used to robustly self-test general ensembles of pure quantum sates and the corresponding projective measurements. We believe that these findings pave the way towards systematic certification of general quantum systems in the semi-device-independent paradigm. This is supported by the concrete qubit results from Table 1 and by the universality of our protocol for certifying overlaps of quantum sates in arbitrary dimension.
In our main claims, we state that the scheme can be applied to an arbitrary set of preparation states. However, the sets of states in Theorems 1 and 2 always come in a collection of bases. These two statements are not contradicting one another since any given constellation of states can always be completed to a set of bases by adding extra preparation states. In practice, one should aim at aligning each basis of preparation states and the corresponding measurement to the best degree allowed by the experimental setup.
There are many exciting research directions that stem from our work. One of them is a systematic SDI characterization of generalized measurements beyond qubits. Another research direction is the robustness analysis of our scheme in the presence of shared randomness. An important contribution to the field of self-testing would be a generalization of our self-testing results for qubit to higher-dimensional systems. Finally, it is interesting to combine our methods with recent findings relating state discrimination games and resource theories of measurements and channels [42][43][44].
We would also like to draw reader's attention to a related work [45].
Programme of the Foundation for Polish Science funded by the European Regional Development Fund. MO acknowledges the financial support by TEAM-NET project (contract no. POIR.04.04.00-00-17C1/18-00).

Appendix
In this Appendix we provide technical details that were omitted in the main text. First, in Appendix A we prove statements regarding saturation of the bounds in Theorem 1. Second, in Appendix B we formulate and prove a quantitative version of Theorem 2, which concerns robustness of our self-testing protocol expressed in terms of average fidelities. We also prove there Theorem 3 that gives analogous results expressed in terms of trace distance. In Appendix C we provide alternative robustness analysis based on orthogonal Procrustes problem. In Appendix D we provide technical details about the considered examples in Table 1. Finally, in Appendix E we give proofs of two auxiliary Lemmas needed in the proof of the technical version of Theorem 2.
A Explicit form of states and measurements saturating the bounds in Theorem 1 We start by giving an example of four states and two qubit measurements (n = 2, d = 2), for which the bound in Eq. (3) on the deviation of the overlaps scales like √ ε. Their explicit form is given below: where |+ = 1 √ 2 (|0 + |1 ), and as required by our scheme x for all x, a. Let the experimental states and measurements be the following: First, we need to show that the experimental statistics is deviated from the target one by at most ε, i.e., |tr(˜  . Finally, calculation of the overlap between the states yields: which confirms the scaling of the first order of √ ε. Now, let us show that the bounds from Eq. (3) are also tight in the first order of d. We still consider the case of n = 2, but now d is arbitrary. Let us consider the following POVM: where δ = , a = 2, 3, . . . , d, the conditions of the Theorem 1 will be satisfied and the resulting bound will be dε.

B Quantitative statement of the robust self-testing
In this part we first formulate Theorem 3 in which we present robustness of our self-testing scheme in terms of trace distance 2 for states and operator norm for measurements. Then, we give a quantitative statement of Theorem 2, that concerns robustness of our self-testing scheme in terms of average fidelities. We then proceed with proofs of both results.
In what follows we will need the following definition.
for which there exist a qubit unitary matrix U such that where (·) (T ) is the transposition (with respect a fixed basis in C 2 ) that may have to be applied to all experimental states and measurements simultaneously.
The reason for such a formulation of the theorem lays in the proof techniques that were used to derive it. Namely, we use results on the stability of the Cholesky factorization. Since the result employed by us (Ref. [38]) is valid for positive-definite matrices we cannot apply it to the Gram matrix of all of the vectors n x a due to their linear dependence. As a result, our bounds depend on the particular choice of the set S of states whose Bloch vectors are linearly independent. In what follows, without the loss of generality we take S = {1, 2} for k = 2 and S = {1, 2, 3} for k = 3 in the proof. In practice, however, one should consider all subsets S of states that give non-singular Gram matrices having in mind a specific application.
Outline of the proof.-In what follows we will consider a particular subset {n x 1 } x∈S of k linearly independent Bloch vectors. For simplify we will omit the subscript S whenever possible. The main idea of the proof is to use a Cholesky factors of k ×k the Gram matrices Γ andΓ of target ({n x 1 } x∈S ) and experimental ({ñ x 1 } x∈S ) Bloch vectors respectively. We then make use of the result of Ref. [38] on the stability of Cholesky factorization which, in simple terms, states that if Γ andΓ are close to each other, so are their Cholesky factors L andL. Specifically, this result, which we quote bellow (see Theorem [Sun 1991]), sets an upper bound on the Frobenius norm of ∆L =L − L in terms of the Frobenius norm of the perturbation ∆Γ =Γ − Γ. The Frobeniuous norm of the perturbation ∆L can be connected to the trace distance between states x 1 and the rotated states˜ x 1 in the selected subset S. On the other hand, the bound on ||∆Γ|| F can be estimated from our assumption: |p(b|a, x, y) −p(b|a, x, y)| ≤ ε. This bound follows directly from the results of Theorem 1, but here we use an improved qubit stability bounds, which are given by Lemma 1. This, in turn, leads to stronger estimates for the norms of ∆Γ in Lemma 2 bellow. Combining all these results produces bounds in Eq. (30a).
In the next part of the proof we determine the trace distance between states x 2 and˜ x 2 for x ∈ S based solely on the fact that x This gives the bounds in Eq. (30b). For states x / ∈ S we use the fact that they can be decomposed in the basis of the states in S. Since this linear decomposition can be different for target and experimental states, we use the result on stability of linear systems (see Theorem [Higham 2002], which we also quote below). The bounds for the states x / ∈ S are given by Eq. (30c). Finally, we connect the bounds for the distance between the target and experimental measurements and the distance between the corresponding states resulting in Eq. (30d) and (30e).

Theorem 2 (Quantitative formulation of robust self-testing for qubits). Consider pure target qubit preparation states
Then, there is a region of ε ∈ [0, ε 0 ) determined by for which there exist a qubit unitary matrix U such that , for x / ∈ S, a = 1, 2 , where (·) (T ) is the transposition (with respect a fixed basis in C 2 ) that may have to be applied to all experimental states and measurements simultaneously. Note that in formulas (33c) and (30e) we have used trace distance d tr (U (˜ x a ) (T ) U † , x a ) in order to simplify the resulting formulas. The bound on this quantity is given in Eq. (30c).

Remark.
Results of Theorem 2 are obtained using a similar reasoning to that given in the outline of the proof of Theorem 3. However, the proof steps are supplemented by bounds connecting fidelity to the trace distance (for states) and operator norm (for measurement operators). The proof of Theorem 2 is given at the end of this part of the Appendix.
Before we proceed we state two theorems from the literature that are needed for our proof. First, we repeat the statement of the Theorem 1.4 from Ref. [38] for real-valued matrices. Second, we state a result concerning stability of systems of linear equation, which we borrow from Ref. [46] (Theorem 7.2). We changed the notation used in these papers in accordance with our paper.
Theorem (Sun 1991 -Stability of Cholesky factorisation). Let Γ be an k × k positive definite matrix and Γ = LL T its Cholesky factorization. If ∆Γ is an k × k symmetric matrix satisfying then there is a unique Cholesky factorization and Remark. This theorem dates back to 1991, and, of course there have been attempts to improve this result. However, the recent review [47] on this topic suggests that the bound given in the Theorem above is the most appropriate in our case (Remark 3.2, Ref. [47]).

Theorem (Higham 2002 -Stability of systems of linear equations). Let c be a solution of a system of linear equations
where Proof of Theorem 3. LetΓ be the Gram matrix of Bloch vectors {ñ x 1 } x∈S of the experimental states for x ∈ S. Let us for now assume that the Cholesky factorizationΓ =LL T exists and let ∆L =L − L.
We start our first part of the proof regarding the states x ∈ S, a = 1 by connecting the square of the norm ||∆L|| F with trace distance between the states {˜ x 1 } x∈S and { x 1 } x∈S . From the sketch of the proof of Theorem 3 it follows that the Bloch vectors {n x 1 } x∈S of the target states and the vectors {l x } x∈S , transpose of which are rows of L, are connected via an orthogonal transformation, which we denote as O, i.e., l x = On x 1 , x ∈ S. Similarly, for the Bloch vectors {ñ x 1 } x∈S of the experimental states and the vectors {l x } x∈S that form L there exists an orthogonal transformationÕ, such thatl x =Õñ x 1 , x ∈ S. Let us define states τ x = 1 2 (1 + l x · σ), andτ x = 1 2 (1 +l x · σ), x ∈ S. We know that there exist unitary transformations V andṼ such that: We have the following sequence of equalities valid for x ∈ S: where we used the invariance of trace distancee under unitary evolution and transposition, and also denoted the resulting unitary V †Ṽ as U . It is clear that one transposition in the final formula in Eq. (38) is enough as the case det(Õ) = det(O) = −1 is equivalent to having det(Õ) = det(O) = 1 and changing U to U T . We need to show now that this unitary U satisfies the claim of Theorem 2 for the states x ∈ S. For qubits, trace distance can be expressed directly via Eucleedian distance between Bloch vectors: Using this fact and Eq. (38), it is straightforward to derive the following upper bound: We now use Theorem [Sun 1991] (Ref. [38]) to upper-bound ||∆L|| F . Specifically, we apply it to the Gram matrix of the Bloch vectors of states { x 1 } x∈S . We have ||L|| F = √ k, since the target states are assumed to be pure. The direct substitution of the bound in Eq. (35) into Eq. (40) gives the bound in Eq. (30a), and also the condition in Eq. (29) when the Theorem 3 (and also Theorem 2) applies.
In the beginning of the proof we assumed that the Cholesky factorizationΓ =LL T exists. The condition in Eq. (29) gives the sufficient condition for this to hold. We conclude this part of the proof by noting that a similar statement in terms of fidelity (Theorem 2, Eq. (33a)) follows from Eq. (40) by connecting fidelity to the trace distance as described in Eq. (54).
In the second part of the proof we derive upper bounds on the trace distances between the states corresponding to x ∈ S and a = 2. As we will see, those can be connected to the bounds for the states with x ∈ S and a = 1. Indeed, we can write the following for every x ∈ S: Exactly the same reasoning can be applied to upper bound the trace distance d tr (U (˜ x 2 ) T U † , x 2 ), in which case the transposition will propagate to d tr (U (˜ x 1 ) T U † , x 1 ) but would not affect the term a=1,2 ˜ x a −M x a 1 (as we can take (M x a ) T ). To finish the calculations we need to upper-bound the second summand in Eq. (41).
where the last inequality is proven in Lemma 1 (see Eq. (77)). From here, it is easy to obtain the bound in Eq. (30b). The reason why we do not simply apply the same reasoning to the states corresponding to a = 2 and x ∈ S as for the states with a = 1 is because we want the isometry U to be the same for all of the states.
In the third part of the proof we derive the bounds for the preparations states corresponding to x / ∈ S and both a = 1, 2. We start by reminding ourselves that the set of states { x 1 } x∈S is assumed to be tomographically complete. Is is equivalent to the assumption that the vectors {l x } x∈S , defined above, are linearly independent and span R 3 for k = 3, or the considered subspace for k = 2. The condition in Eq.
whenever the cardinality k of the set S is 3. For k = 2 and c,c, g,g ∈ R 2 their definition is analogous. We again omitted the subscripts a , x for the vectors g andg for simplicity. The matrices Γ andΓ are still the moment matrices for the states x ∈ S, a = 1.
In complete analogy to Eq. (39) we can write: We then can upper-bound the latter norm as follows: In the equation above we used the following relation: Also, since the norms |l x | can be upper-bounded by 1 for all x, the resulting upper bound can be simplified further to be |c | ||∆L|| F + x∈S |c x − c x |.
To estimate the deviation |c x − c x | we apply Theorem [Higham 2002] by taking ∆Γ = Γ − Γ and ∆g =g − g. The bound on the operator norm ||∆Γ|| is given by Lemma 2.
At the same time |∆g| = 2 If we take δ = 2((k − 1) √ ε + (k + 1)ε), some matrix E with ||E || = 1, vector f such that |f | = √ k k−1 , we satisfy the conditions of the Theorem [Higham 2002] and get the following bound: As the final step we need to connect the bound in Eq. (44) with the one in Eq. (46) by the relation between 1-norm and the Euclidean norm in R k , which effectively adds a factor of √ k to the bound in Eq. (46). Combining everything together we obtain the following: The above bound is given in Eq. (30c) in terms of the quantity E S,k (ε) (Eq. (28)), where we took ||∆L S || F = 2 √ kE S,k (ε) and brought back all the necessary subscripts. Again, using the relation in Eq. (55) we can derive bounds on the fidelity between the states x a and˜ x a for x / ∈ S. In the fourth, final, part of the proof we derive the bounds for the measurements. We do it by connecting the distance between the experimental measurements and the distance between the corresponding states. Indeed, we can write the following: where we used the triangle inequality and the invariance of the norm ˜ Finally, we proceed to the proof of Theorem 2, which gives a quantitative robustness analysis expressed in terms of average fidelity.
Proof of Theorem 2. Let us first state a useful identity between Frobenius distance and the fidelity, valid for an arbitrary pure states and a Hermitian operator X: We follow exactly the same steps that were given in the proof of Theorem 3. We assume that the reader is familiar with the notation introduced there. First, in order to derive the bound in Eq. (33a) we repeat the reasoning preceding Eq. (38). Analogously to the trace distance discussed there, we use the invariance of the fidelity under unitary transformations and transposition which gives us for all x ∈ S = [k]: where U = V †Ṽ . Using the above formula and standard algebra involving Pauli matrices we obtain: On the other hand, we have the following identity: where | · | is a standard Euclidean norm in R 3 . Using the identity |l x | 2 = 2tr((˜ x 1 ) 2 ) − 1 and the fact that target states are pure (which implies |l x | = 1) we obtain: Inserting the above into Eq. (51) and using the fact that tr(˜ x 1 ) 2 ≥ 1− 2ε(1−2ε) (1−ε) 2 (this follows straightforwardly from Lemma 2), we finally obtain: We complete the proof of Eq. (33a) by again employing, exactly as before, Theorem [Sun 1991] (Ref. [38]) in order to upper-bound ||∆L|| F . Now, to derive Eq. (33b), which gives the bounds for the fidelity of states for x ∈ [k] and a = 2, we can use the following inequality which can be derived from Eq. (49) and from the relation tr(˜ From Eqs. (40,41) it follows that: which gives the desired bound form Eq. (33b): The proof of the remaining bounds in Eqs. (33c,33d,33e) is straightforward and follows directly form the formula in Eq. (49). In particular, in order to prove Eq. (33c) we set X =˜ x a and = x a in Eq. (49), use the inequality tr(˜ x a ) 2 ≥ 1 − 2ε(1−2ε) (1−ε) 2 and the relation ||σ − || 2 F = 2d tr ( , σ) 2 , with latter being true for arbitrary qubits states and σ. Derivation of Eq. (33d) is completely analogous to the one of Eq. (33b). Finally, for Eq. (33e), the reasoning is again analogous to Eq. (33c), where, after setting X =M y 1 and = y 1 , it is additionally necessary to use a simple lower bound: tr((M y 1 ) 2 ) ≥ (1 − ε) 2 , which follows from the conditions of Theorem 2.

C Alternative bounds from Procrustes
and where L ‡ = (LL T ) −1 L T . There exist a unitary matrix U such that: In this section we derive alternative bounds for the fidelity between preparation states that follows from the bounds on the so-called orthogonal Procrustes problem [48]. The problem itself can be formulated as follows. Given two sets of vectors x 1 , x 2 , . . . , x m and y 1 , y 2 , . . . , y m in R d find an orthogonal transformation O ∈ O(d) in R d that minimizes m i=1 |x i − Oy i |. This problem has a clear relevance to our task. Indeed, if we take x i to be the Bloch vectors of the target qubit preparation states and y i the Bloch vectors of the experimental states, then minimization over O(3) is the same as the problem of finding a unitary transformation that connects those qubit states. In Ref. [39] the bounds on Procrustes problem were derived. We give formulation of Theorem 1 from Ref. [39] below, where we change the notation according to our problem.
In the formulation of the above theorem L ‡ stands for the Moore-Penrose inverse, which can be defined as L ‡ = (LL T ) −1 L T for tall matrices of full rank. The matrices LL T andLL T are then, of course, the full Gram matrices Γ andΓ. By "full" we mean that now we do not select a subset S of linearly independent vectors among the Bloch vectors of x a . Instead, Γ andΓ are formed by all the considered states, which can still be a subset of the 2n states (x ∈ [n], a ∈ [2]). We will be using m to denote the number of the considered states, and a simple one-indexed set { i } i to denote the states themselves. Estimating δ 2 from the formulation of the Theorem [Arias-Castro et.al. 2020] is a direct application of the bound on ||∆Γ|| F from Lemma 2, where now instead of k one should put the number m of the considered preparation states.
As for the left-hand side of Eq. (61), we can write the following: where we use the following identity: and U is the unitary transformation in SU(2) corresponding to the orthogonal transformation O of the Bloch vectors. The bound on the average fidelity between m target preparation states and the corresponding experimental states is then simply: where and

D Examples
Below we provide detailed derivations of the results presented in Table 1.
Let us now try to improve the bounds for the overlaps. In the proof of Theorem 1 (see Eq. (7)) we have already established that: Let us now refine the bound on ˜ x a −M x a . For simplicity, we present this result below for a pair of operators = (1 − η)1 + (2η − 1)|ψ ψ| and M = λ 1 1 + (λ 0 − λ 1 )|φ φ|, that satisfy the conditions tr( M ) ≥ 1 − ε, and 1 − ε ≤ λ 0 ≤ 1, 0 ≤ λ 1 ≤ ε. To compute the norm, we look for the eigenvector |ξ of the operator ( − M ), i.e., ( − M )|ξ = Λ|ξ , corresponding to the maximal eigenvalue. We have the following quadratic equation for the eigenvalue Λ: The sum of the roots of this equation is equal to 1 − λ 0 − λ 1 . Since we know that |1 − λ 0 − λ 1 | ≤ ε, then either both roots are of the same sign, in which case the largest eigenvalue could only be ε, or they are of the opposite sign. In the latter case, it is evident that the absolute values of both roots are maximal whenever the free term in Eq. (73) is minimal. We then can upper-bound the solutions to Eq. (73) by lower-bounding the free term using the condition tr( M ) ≥ 1 − ε. Indeed, from tr( M ) ≥ 1 − ε we infer immediately that: and thus we reduce Eq. (73) to: Using the same argument we can set η = 1, because η(1 − η) ≥ 0. The positive root of Eq. (75) is equal to: It is easy to check that the above expression does not have any local maxima w.r.t. λ 0 ,λ 1 on the domain 1 − ε ≤ λ 0 ≤ 1, 0 ≤ λ 1 ≤ ε, whenever ε < 1 2 , which we assume to be the case. Thus, we conclude that the maximal value of Λ corresponds to the boundary of the region of (λ 0 , λ 1 ). By considering this boundary we find that this maximal value corresponds to the case of λ 0 = 1 and λ 1 = 0 which yields Λ = √ ε. From the above argument we finally conclude that: which completes the proof for the state overlaps. From Eq. (77) and the fact that tr(M y b ) ≤ 1 + ε, it is easy to obtain the improved bound on the overlaps between measurement effect.
Proof of Lemma 2. Let us start by deriving the bound on the Frobenius norm ||∆Γ|| F : We have already established the bound on |tr( x 1 x 1 ) − tr(˜ x 1˜ x 1 )| in Lemma 1. The bound on (1 − tr(˜ x 1 ) 2 ) 2 can be obtained from the bound on the norm of each˜ x 1 . Namely, from the condition ||˜ x a || ≥ 1−2ε 1−ε we can immediately conclude that: From here, it is easy to get to the final bound on ||∆Γ|| 2 F , which reads: where we made some approximations to simplify the result. Now, let us derive the bound on ||∆Γ||. In principle, we know that ||∆Γ|| ≤ ||∆Γ|| F , but we can derive a better bound based on the fact that the diagonal entries of ∆Γ are much less than the off-diagonal entries.
First of all, due to the triangle inequality, we can write ||∆Γ|| ≤ ||diag(∆Γ)|| + ||offdiag(∆Γ)||, where we split ∆Γ on the diagonal and off-diagonal parts. The first term, ||diag(∆Γ)||, can be easily bounded as follows: As for the off-diagonal part, we give the proof for two cases k = 2 and k = 3 separately. For k = 2, ||offdiag(∆Γ)|| = 2|tr( 1 1 2 1 ) − tr(˜ 1 1˜ 2 1 )| ≤ 2 √ ε + 2ε, where we used the results of Lemma 1. As for k = 3, we will need some intermediate result, namely the following relation: where k is the size of the matrix A with tr(A) = 0. We give a proof of this below. Let us assume that {λ i } k i=1 are the eigenvalues of matrix A, hence we know that k i=1 λ i = 0. Let λ 1 be the largest eigenvalue, i.e., the operator norm of A, if λ 1 ≥ 0. If we wish to maximize the Frobenius norm of A for fixed λ 1 , the following lower-bound has to be satisfied: which proves the bound in Eq. (82). Using the above result, we obtain the following bound: which completes out proof.