Self-testing two-qubit maximally entangled states from generalized CHSH tests

Device-independent certification, also known as self-testing, aims at guaranteeing the proper functioning of untrusted and uncharacterized devices. For example, the quality of an unknown source expected to produce two-qubit maximally entangled states can be evaluated in a bi-partite scenario, each party using two binary measurements. The most robust approach consists in deducing the fidelity of produced states with respect to a two-qubit maximally entangled state from the violation of the CHSH inequality. In this paper, we show how the self-testing of two-qubit maximally entangled states is improved by a refined analysis of measurement statistics. The use of suitably chosen Bell tests, depending on the observed correlations, allows one to conclude higher fidelities than ones previously known. In particular, nontrivial self-testing statements can be obtained from correlations that cannot be exploited by a CHSH-based self-testing strategy. Our results not only provide novel insight into the set of quantum correlations suited for self-testing, but also facilitate the experimental implementations of device-independent certifications.

Device-independent certification, also known as self-testing, aims at guaranteeing the proper functioning of untrusted and uncharacterized devices. For example, the quality of an unknown source expected to produce two-qubit maximally entangled states can be evaluated in a bi-partite scenario, each party using two binary measurements. The most robust approach consists in deducing the fidelity of produced states with respect to a two-qubit maximally entangled state from the violation of the CHSH inequality. In this paper, we show how the self-testing of two-qubit maximally entangled states is improved by a refined analysis of measurement statistics. The use of suitably chosen Bell tests, depending on the observed correlations, allows one to conclude higher fidelities than ones previously known. In particular, nontrivial self-testing statements can be obtained from correlations that cannot be exploited by a CHSH-based self-testing strategy. Our results not only provide novel insight into the set of quantum correlations suited for self-testing, but also facilitate the experimental implementations of device-independent certifications.

I. INTRODUCTION
Bell inequalities were proposed to show that the results of local incompatible measurements on subsystems prepared in a global quantum state can have stronger-thanclassical correlations, so-called non-local correlations [1]. Self-testing aims to reconstruct the global state and the local measurements generating these non-local correlations (up to local isometries) in a device-independent way, i.e. without assumption on the functioning of devices used in the Bell test [2,3].
A self-test of a two-qubit maximally entangled state φ + AB for example can be obtained from the simplest Bell inequality -the Clauser-Horne-Shimony-Holt (CHSH) inequality [4]. The latter is tested in a bi-partite scenario in which Alice and Bob share a state ρ AB ∈ H A ⊗ H B and perform one out of two binary measurements each. The measurement choice is labelled A x , B y where x, y = 0, 1 for Alice and Bob, respectively, with the results for each measurement choice ±1. By repeating the experiment many times, the CHSH score is computed from where A x B y is the expectation values of results for the measurement choice A x and B y (the probability that the results are the same minus the probability that they are different). The CHSH inequality is obtained by noting that, for any locally causal theory, β is upper bounded by 2 -the local bound [5]. Hence, the observation of any score β > 2 rules out the possibility to model the experiment in the framework of such theories. Furthermore, the sole knowledge of the CHSH score can be used to certify that the shared state ρ AB resembles φ + AB [6][7][8]. More precisely, when β is sufficiently close to 2 √ 2, there exist local maps Λ A and Λ B that can be applied to ρ AB to extract a two-qubit state Λ A ⊗ Λ B [ρ AB ] having a fidelity with respect to φ + AB which exceeds 1/2 [9][10][11][12].
Self-testing by the CHSH score is not only an elegant characterisation of bipartite sources, but has been shown * both authors contribute equally to this work.
to be a key ingredient for the device-independent certification of other quantum instruments, including quantum processing units [13,14] and generalised measurements [15]. Its implementation is however not easy. Selftesting is simply not possible for CHSH scores smaller than β ≈ 2.05 [16] and a non-trivial fidelity with respect to two-qubit maximally entangled states can only be extracted for a CHSH score exceeding β 2.11 [12]. This explains why first experimental realisations [17][18][19] were not device-independent [20] and only one self-testing realisation [21] has so far been reported. In order to popularize self-testing, it is natural to ask if the noise tolerance for the self-testing of φ + AB can be improved.
To achieve this goal, an approach consists in deriving self-tests from a more refined analysis of measurement statistics. Indeed, in order to evaluate the CHSH score experimentally, all four expectation values A x B y have to be collected. These values give more information than just the CHSH score, and can be used to generate all the self-testings of the singlet [22]. Note that first attempts for robust self-testing were based on the knowledge of these individual expectation values but none of them succeeded to provide non-trivial state fidelities with respect to two-qubit maximally entangled states if the CHSH score β < 2.37 [23].
Here we focus on a family of Bell tests with a generalized CHSH score given by for some θ ∈ [0, π 2 ]. The local bound is given by β L θ = 2 √ 2 max(cos θ, sin θ) [24][25][26] and the Bell inequalities β θ < β L θ can be tested in a CHSH scenario, where two parties dispose of two binary measurements each. Note that the case θ = π/4 reduces to the CHSH case. We show that this family of generalized CHSH tests can be used to self-test two-qubit maximally entangled states with a fidelity higher than with the CHSH score whenever X = Y. In some cases, a non-trivial fidelity with respect to the two-qubit maximally entangled state can be extracted from a suitably chosen generalized CHSH test, even when the CHSH score β is larger than, but arbitrarily close to, 2. We conclude with an explicit recipe to choose the test giving the highest fidelity in any experiments where the values of correlators X and Y are measured.

II. PRELIMINARIES ON SELF-TESTING
We stay with the scenario described in the introduction. Two protagonists, Alice and Bob, share an unknown state ρ AB ∈ H A ⊗ H B with unknown local Hilbert space dimensions and perform one out of two binary measurements each, A x and B y with x, y = 0, 1 denoting the respective measurements of Alice and Bob. By repeating the experiment many times, Alice and Bob obtain the individual expectation values X and Y defined in Eq. (2). From these expectation values, they want to show that the state ρ AB resembles a maximally-entangled two-qubit state φ + AB . In the framework of self-testing, we express this resemblance by a notion of extractability or singlet fraction, defined by The former function captures the maximal fidelity with the target state φ + AB for a given state ρ AB over all local completely positive trace preserving (CPTP) maps Λ A ⊗ Λ B [9]. The local maps Λ A/B : L(H A/B ) → L(C 2 ) should be thought of as necessary operations to identify a degree of freedom of the whole system ρ AB that can be described by a two-qubit state. The fidelity is the square of the Uhlmann fidelity F (ρ 0 , ρ 1 ) = tr ρ 1/2 0 ρ 1 ρ 1/2 0 2 which reduces to the overlap F (ρ 0 , ρ 1 ) = tr [ρ 0 ρ 1 ] whenever one of the two states ρ 0/1 is pure. We will simply denote the extractability of ρ AB by Ξ[ρ AB ] in the rest of the manuscript as there will be no ambiguity to the reference state.
We are interested in bounding the extractability Ξ[ρ AB ] as a function of observed quantities X and Y. Formally, this is accomplished by considering all possible quantum models (ρ AB , A x , B y ) satisfying tr (ρ AB (A 0 (B 0 + B 1 ))) ≥ X and tr (ρ AB (A 0 (B 0 − B 1 ))) ≥ Y. However, the set of correlator-pairs (X, Y ), for which the extractability is lower-bounded by a constant, is convex: two quantum models can be joined into a new model on which the extractability is bounded by the weighted sum of extractabilities associated to the individual models. It is thus equivalent to bound the extractability from linear constraints of X and Y , i.e. from the Bell score β θ . Our aim is thus to solve the following optimization is a Bell operator identified as the generalized CHSH operator. This is a hard optimization problem given that the dimensions of the Hilbert spaces supporting the initial states are unknown and that the set of product maps is non-convex. Before approaching the problem (4), we note that there exists a trivial strategy to achieve Ξ[ρ AB ] = 1 2 for all state ρ AB . Indeed, it is always possible for Alice and Bob to choose CPTP maps destroying the shared state and replacing it by a fixed state of their choice, resulting in a product state ρ AB = ρ A ⊗ ρ B . Alice and Bob can always chose a product state with a fidelity of 1 2 with respect to a two-qubit maximally entangled state. We thus call this fidelity the trivial fidelity.

III. SELF-TESTING WITH TWO BINARY MEASUREMENTS
For the particular case of interest where two dichotomic measurements are used by each party, we can choose a basis according to Jordan's lemma so that the local observables A x and B y are block diagonal with blocks of size 2 × 2 represented by Pauli measurements where σ x and σ z are the Pauli operators and a i , b j ∈ [0, π 2 ] are the angles between the local measurements in the blocks defined by the indexes i and j. Trivially, our family of Bell operators inherits the same block structure A priori, the state ρ AB does not have the same diagonal structure. However, Alice and Bob can locally perform a projection into their orthogonal blocks before choosing the extraction map. Let us call p ij the probability to get a successful projection into the blocks i for Alice and j for Bob, and ρ ij AB the resulting state. At first sight, the extractability of ρ AB is larger than ij p ij ρ ij AB , but because of the block diagonal structure of the measurements, the two states lead to the same score β θ and hence have the same extractability. Without loss of generality, we can thus consider that ρ AB is of the form This means that the extraction maps can be constructed independently for each block and that the extractability (3) reduces to a maximization over qubit maps If we fix the dependence of the extraction maps on the angles a i and b j and consider the case where they do not depend on the state, we can lower bound the extractability F given in Eq. (4) by first solving the following optimization for all physical two-qubit states ρ qubit AB and then taking the convex roof of O min (β θ ). The optimization over states for fixed measurement angles is a minimization of a linear objective function over a spectrahedron. Such problems can be efficiently solved using semi-definite programming. The minimization over angles between measurements can be done using a non-linear optimisation algorithm. The details for these optimisations are detailed in the Appendix. When considering self-testing from the CHSH operator B θ= π 4 , the result of this two-fold optimisation followed by a convex roof shows that a non-trivial fidelity can be obtained as long as β 2.11. This takes a clever choice of local maps that we present in the following section.

IV. CHOICE OF MAPS FOR SELF-TESTING FROM THE CHSH OPERATOR
As stated in the previous section, local maps need to be fixed to bound the self-testing fidelity from the numerical optimization given in Eq. (11). A particularly relevant choice has been reported by Kaniewski in Ref. [27] for self-testing a maximally entangled two-qubit state from the CHSH operator. We quickly present the basic ideas leading to this choice of maps and, in the next section, show how to use the same line of thought to construct maps relevant for self-testing a maximally entangled twoqubit state from the generalized CHSH operator B θ .
Consider the CHSH operator appearing in the constraint of Eq. (11) for the block characterized by the index i and j for Alice and Bob, respectively. If we forget these indices, the CHSH operator takes the following form of this single-block CHSH operator can be written in the decreasing order as For fixed measurement angles, the Bell score β π 4 of any two-qubit state ρ qubit AB is therefore given by On one hand, the maximal eigenvalue satisfies On the other hand, the two lowest eigenvalues λ 3 and λ 4 are negative, and the states with support on |ψ 3 (a, b) and |ψ 4 (a, b) thus lead to a relatively low CHSH score. We observed numerically that an appropriate design of local maps can be obtained by considering states supported on the two-dimensional subspace H π/4 (a, b) spanned by the first two eigenstates. These maps are obtained by considering various values of parameters a and b.
Let us now consider the values a, b ∈ {0, π 4 , π 2 }, where the Bell operator takes the form , the CHSH operator takes the form B π/4 = 2 σ n ⊗ σ n with the Bloch vector n in the X-Z plane. Consequently, the two maximal eigenvalues are degenerate, λ 1 = λ 2 = 2, and the corresponding subspace is spanned by the states where n ⊥ is the Bloch vector orthogonal to n in the Z-X plane. Hence, in order to attain a non-zero extraction fidelity at β π 4 = 2, the maps have to deform the Bloch sphere associated to the two dimensional space. Let us keep in mind that for the angle a = π 4 , the extraction map is given by the identity (and similarly for b = π 4 ). The other party thus has to select a map that increases the overlap between the state φ ⊥ AB and the target state φ + AB (they are manifestly orthogonal to start with). This can be done by choosing a dephasing map in the direction σ n , that is, for angles 0 and π 2 , the map changes ρ into 1 2 (ρ + σ n ρ σ n ) . Since any state in the subspace spanned by φ + AB and φ ⊥ AB can be expressed as with a unit vectors r, and the operators the map changing ρ into 1 2 (ρ + σ n ρ σ n ) sends any state in the subspace of interest onto with |x| ≤ 1. Such a state has a fidelity with the target state φ + AB equal to 1/2.
It is interesting to consider what these maps do for the remaining points in the table above. It turns out that the situation is similar for all the remaining combinations of angles and can be illustrated by considering the example (a, b) = (0, 0) only. In this case, the maps on both Alice's and Bob's side are dephasing maps in the directions σ h and σ z respectively. Any state attaining β = 2 is sent by these maps to states of the form given by Eq. (16), where σ n is replaced by σ h for Alice and σ z for Bob. It is easy to see that the fidelity of such states with the target state is given by Remarkably, if we connect the points (2, F L ) and (2 √ 2, 1) in the (β, F ) plane, we see that it intersects the trivial fidelity line F = 1/2 at precisely β t 2) 17 ≈ 2.11. We thus succeeded to identify the angles and states that tightly constrain the final extractability bound.
Finally, to get the extraction maps for all angles a, b ∈ [0, π 2 ], one simply does an analytical continuation between Λ A (0) ←→ Λ A ( π 4 ) ←→ Λ A ( π 2 ) and similarly for Λ B . In particular, we take the one proposed by Kaniewski [28] Λ A (a) = 1 + g(a) 2 1ρ1 with the strength and the dephasing direction Bob's map is similar to the one of Alice, but with a dephasing in the direction Interestingly, numerical results suggest that the exact form of the function g on intermediate angles is not important for the final bound found in Ref. [28].

V. EXTRACTION MAPS FOR SELF-TESTING FROM GENERALIZED CHSH OPERATORS
We now consider the eigenvalues of generalized Bell operators λ (θ) (a, b) = Eig ↓ (B θ (a, b)).
The last two eigenvalues λ are still negative, and as before, they are not considered in the construction of relevant maps. Hence, we can start by constructing extraction maps using reasoning analogous to the one presented in the previous section.
Since the maximal quantum value λ operator B θ (a, b) is attained for the setting choice (a, b) = ( π 4 , θ), we choose maps satisfying Λ A ( π 4 ) = Λ B (θ) = 1, so that the target state is extracted when the Bell score is maximal.

We now consider the value of Bell operators
). It is still given by products of Paulis, with the important difference that the prefactors now depend on the angle b as shown in the following table Here, f (b) = 1 + cos(2b) cos(2θ) is a monotonic function ranging from f (0) = √ 2 cos(θ) to f ( π 2 ) = √ 2 sin(θ) and As the Bell operator B θ (a, b) takes the same value as the CHSH operator B π 4 (a, b) for the extreme angles a, b = 0, π 2 , it is still relevant to align the dephasing direction of maps with the direction of the corresponding Pauli operators σ h , σ m , σ z or σ x . We thus temporarily fix Λ A(B) to be of the same form as in Eq. (18). To fix the strength of the dephasing for intermediate angles, we again resort to an analytic continuation. For Alice, we pick the strength as in Eq. (19). For Bob, the situation is different as the continuation has to be done between the angles 0 ←→ θ ←→ π 2 where the maps are fixed. Inspired by Ref. [15], we define a new functioñ where The functiong θ (b), i.e. the variation of the strength of dephasing, is plotted in Fig. 1 as a function of the angle b for different choice of Bell operators (θ).
On the frame, i.e. (a, b) ∈ ∂([0, π 2 ] × [0, π 2 ]), the maps we just defined transform the states associated to positive eigenvalues of the Bell operators in states of the form given in Eq. (16) with two different indexes for Alice and Bob. Specifically, σ n → σ A (a) for Alice and σ n → σ B (b) for Bob with The fidelity of these states with respect to the φ + AB is given by We now aim at finding a better map than the one temporarily fixed for Alice. So far, we used a straightforward translation from the CHSH case. However, we can design a better extraction map for Alice, exploiting the asymmetry of generalized CHSH tests.
In order to do so, we focus on the upper and lower lines of the frame corresponding to Bob settings b = 0 and b = π/2. We label F ↑ (a) the fidelity corresponding to the upper line of the frame and F ↓ (a) the one of the lower line. Using Eq. (28) to express these fidelities, we find that F ↑ (a) = F ↓ (a) for all Alice's measurement setting a. However, the generalized CHSH score of the state associated to positive eigenvalues of generalized Bell operators on the upper frame differs from such a score on the lower frame, as follows from the form of the function f (b) in Tab. I. Indeed, these scores reads noting s ↑ ≥ s ↓ for all a, and for θ ∈ [0, π/4].
Since we are interested in the convex roof as a function of the generalized CHSH score (see Eq. (11)), an extraction map that yields the same fidelity for different Bell scores seems sub-optimal. Since the lower part of the frame results in a lower score, it is only the upper part which limits F. In particular, a map on Alice's side raising F ↑ (a) could lead to a higher extractability. Since F ↑ can be increased if σ A (a) gets closer to σ B (0) = σ z , we append a rotation by an angle ω around σ y to Alice's extraction map. This will ultimately increase F ↑ (a) at the price of lowering the fidelity F ↓ (a), sending σ A (a) further away from σ B ( π 2 ) = σ x .
For some generalized CHSH tests with the parameter θ slightly lower that π 4 , s ↓ is small and plays essentially no role in limiting the final extractability. In that case, it is natural for Alice to try to increase F ↑ (a) as much as possible, ideally up to 1 2 . However, for some settings a, it appears that F ↑ (a) can not reach 1 2 , even when optimising the angle ω of the rotation. To overcome this limitation, we also tweak the direction of the dephasing associated to the map Λ A . Concretely we introduce a parametric dephasing direction Γ(d) = cos(d)σ h − sin(d)σ m allowing F ↑ (a) to take the value 1 2 for any setting a. For simplicity, the strength of the dephasing is kept the same as before.
Lastly, we optimise the convex roof over the two parameters ω, d, for a given setting a and a given operator B θ , that is, we choose ω, d such that Finally, Alice's map with the rotation around σ y and new dephasing direction Γ(d) reads

VI. ROBUSTNESS OF SELF-TESTING FROM GENERALIZED CHSH SCORES
We first solve the two-qubit optimisation given in Eq. Eq. (11) using the extraction maps proposed in the previous section and then deduce a lower bound F on the extractability by taking the convex roof, as is detailed in the Appendix. The generalized CHSH score for which this lower bound reaches F = 1/2 is referred to as the trivial score, denoted β t θ , that is, the trivial fidelity F = 1/2 is obtained for any violation satisfying β θ ≤ β t θ . For higher generalized CHSH scores, the bound increases linearly from (F, β θ ) = (1/2, β t θ ) to (F, β θ ) = (1, 2 The values of the minimum generalized CHSH scores β t θ needed to get a non trivial self-testing bound are shown in Fig. 2  FIG. 2. Minimum value β t θ of the expectation value of the generalized CHSH operators B θ leading to a non-trivial selftesting bound (F ≥ 1/2) as a function of the parameter θ. For θ = π/4, B π 4 corresponds to the CHSH operator and the trivial self-testing bound is β t π 4 ≈ 2.11 in agreement to the results of Refs. [12,14].
The previous formula can be used to self-test a source expected to produce two-qubit maximally entangled states from generalized CHSH scores. This naturally rises the question of how to choose the generalized CHSH operator leading to the highest self-testing bound given an experiment in which values of X and Y are observed.

VII. CHOOSING THE GENERALIZED CHSH TEST
We consider the case where X and Y are given and clarify on the choice of the operator B θ leading to the highest self-testing fidelity.
Let us begin by discussing values of the pair (X, Y ) that are relevant for self-testing. First, we can assume X, Y ≥ 0 without loss of generality since X, Y ≥ 0 can always be obtained by relabelling the measurement outcomes of A 1 , B 0 and B 1 . We can also assume that X − Y ≥ 0 without loss of generality because in case X − Y < 0, we can relabel the inputs to switch X and Y . The local bound of the CHSH operator X +Y = 2 invites us to look at the region above the line connecting the deterministic local strategies (X, Y ) = (2, 0) and (X, Y ) = (0, 2), that is the region for which X + Y ≥ 2. Finally, the region achieved by quantum states and quantum measurements is bounded by X 2 + Y 2 ≤ 4, as shown in Ref. [24,26]. Hence, the values of the pair (X, Y ) that are relevant for self-testing can be reported in the positive quadrant with X − Y ≥ 0, X + Y ≥ 2, and X 2 + Y 2 ≤ 4.
We discretize this relevant region by meshing it with squares of side δ, i.e.
Given a pair (X, Y ) on the mesh, we compute the values of generalized CHSH scores β θ for 500 values of θ from Eq. (2). Note that it is sufficient to consider values of θ ∈ [0, π/4], since we can recover all cases θ ∈ [π/4, π/2] by permuting X and Y . For every value of θ, we compute the lower bound on F using the optimization procedure described above. The maximum values of these bounds over θ is represented in Fig. 3 while the value of θ leading to the corresponding maximum is shown in Fig. 4. This gives a recipe for self-testing maximally entangled twoqubit states from generalized CHSH scores: from a pair (X, Y ), first deduce the most advantageous generalized CHSH operator from Fig. 4. Then run the optimization described before to conclude on the self-testing bound, whose value is given in Fig. 3. Self-testing of a maximally entangled two-qubit state from the CHSH score only depends on the value of X +Y. Known bounds on F are reported as horizontal dashed lines in Fig. 3. We see from the figure self-testing based on the generalized CHSH scores outperforms CHSH for all pairs of values (X, Y ) where X = Y . In particular, selftesting based on generalized CHSH tests is possible even for CHSH scores below ≈ 2.05 where no self-testing statement can be obtained from the CHSH score alone [16]. Note that, in extreme cases where X << Y , self-testing is possible even for CHSH scores arbitrary close to (but strictly larger than) the local bound.

VIII. CONCLUSION
The most robust self-test of two-qubit maximally entangled states was obtained so far from the CHSH score . Despite several previous attempts, it was not clear how the knowledge of individual values A x B y can be used to improve the robustness of such a self-test. Here, we derive a self-testing strategy based on the knowledge of the two individual terms X = A 0 (B 0 + B 1 ) and Y = A 1 (B 0 − B 1 ) appearing in the CHSH score. We show in particular that such a strategy is equivalent to considering a family of generalized CHSH operators, and go on to present an explicit recipe for choosing the appropriate operator given observed values for the pair (X, Y ). We prove that using the available information of X and Y improves the bound on the fidelity with respect to CHSH for all pairs (X, Y ), except the one where X = Y . Furthermore, selftesting statements can be obtained for some pair (X, Y ) where the strategy based on the CHSH test fails. Our results facilitate the experimental implementation of any device-independent certification based on the self-test of maximally entangled two-qubit states.
A lower bound on the extractability F can be obtained as the convex roof of the two-qubit optimisation O(β θ ) defined in Eq. (11), over all generalized CHSH score β θ . In this appendix, we give more details on how the optimization is performed.
For a given score β θ , we minimize the fidelity with respect to φ + AB over all two-qubit states and over all angles of measurement achieving a violation of at least β θ . Such an optimisation is formally expressed as with ρ qubit AB ∈ C 2 ⊗ C 2 and (a, b) ∈ 0, π 2 .
As a reminder, for a given operator B θ , Alice's map Λ A (a) also includes an inner optimisation (see Eq. (30)) over two scalars ω and d. However, in our case this optimization is independent of the minimization above, and is executed beforehand, fixing the maps Λ A (a) in Eq. (35).
In this Appendix, we will explore each optimization step independently. We start by focusing on the parametrisation of Alice's map. Then, we detail the semidefinite programming optimisation over two-qubit states. We further discuss the optimisation of Alice and Bob settings. Finally, we show how the convex roof is obtained to get the final lower bound on F.

Inner optimization of Alice's map parameters
For a generalized CHSH operator B θ and Alice's measurement setting a, we need to find a good choice of Alice's map parameters. However, the best choice of parameters is not required since sub-optimal maps only result in underestimating the self-testing capabilities of generalized CHSH self-test. As explained in the main text, Alice's map is parametrized from the result of the following optimization ΛA(a; θ) = Ua(ω) 1 + g(a) 2 1ρ1 The quantities F ↑ , F ↓ are defined using Eq. (28) and read σ A (a, ω, d) results from the action of Alice's map on the states associated to the positive eigenvalues of the Bell operator B θ (a, b). Formally cos(a)σ h sin(a)σm .
where R(·) is a SO(2) rotation. With the above expression, fidelities on the frame simplifies to F ↑ (a, ω, d) = 1 4 1 + For a given Bell operator B θ , we have to run the optimisation given in Eq. (36) for each value of a. Since we have to optimize over Alice's measurement setting to get F, running the this optimisation can be resource-heavy. To shorten each of these optimisations, we start by creating a discrete set of Alice measurement setting a. We choose a set of 100 settings = {a n } 100 n=1 with a step δ = π/4 100 so that a n = a n−1 + δ. Then, for each element of the set, a i , we run the optimisation given in Eq. (36) to obtain the parameters ω i and d i . In practice, this optimisation is run multiple times, with different starting points at each run. This will increase our confidence in the result. The set of results obtained this way, is used as a starting point for the optimization of values of a that do not belong to the grid. This is, for a / ∈ we run an optimisation, e.g. using a Limited-memory BFGS method, with initial guess ω i , d i , the parameters obtained for a i ≈ a, where a i ∈ .

Semidefinite programming for optimising over two-qubit states
Finding the worst-case fidelity over all two-qubit states is an optimization over Hermitian matrices ρ qubit AB that are valid density matrices, i.e positive semi-definite with unit trace. Furthermore, the objective function depends linearly on ρ qubit AB , and the constraints are affine expressions of this variable. Such a problem can be solved with semidefinite programming (SDP). Interestingly, SDP is a certifiable method of optimisation. This is, either the optimisation is infeasible or the optimisation results is tight -up to the numerical tolerance, in a case of weak duality.

Minimization over the angles and confidence
Minimizing over the choices of measurement, a, b, is a non-convex optimization over two scalars in a closed domain (a, b) ∈ ([0, π 2 ] × [0, π 2 ]). In practice, this optimisation is performed using the Scipy implementation of the L-BFGS algorithm.
a. Infeasible SDP -Some measurement choices result in an infeasible SDP, since for some measurement angles a, b, there exist no state ρ qubit AB satisfying the generalized CHSH score constraint tr(B θ (a, b)ρ qubit AB ) = β θ .
When this happens, in order to help the optimisation converge to a feasible solution, we guide the angles (a, b) towards the optimal measurement setting for which we know any Bell score β θ ≤ 2 √ 2 can be attained and, thus, the SDP is feasible. To do so we introduce the function It takes the minimum value 1 for (a, b) = ( π 4 , θ) and increases with the distance to the optimal choice of measurement. At each iterative step of the (a, b) minimization, if the SDP is found infeasible, the objective function of the optimisation is replaced by V for this step, i.e.
Therefore, at a given optimization iteration if the SDP is infeasible the minimisation over a, b will follow the gradient V , exploring parameters toward the optimal choice of measurement angles.
b. Entrusted results of minimisation -From the fact that the minimization comes with no certificate, it is possible that we do not find the angles (a, b) attaining the minimal fidelity. For a given generalized CHSH score, this could result in a higher singlet fidelity and, thus, an overestimation of F. To build trust in the numeric results we implement several routines.
A first routine is made to improve the confidence in the minimisation outcome. This is, the minimisation over the choices of measurement is run a fixed number of time n for a given violation.
Then, for a given generalized CHSH score, we make sure that the minimum fidelity found is lower than the one obtained for an higher score. A pseudo-code of these routines can be found in Alg. 1.