A neural network oracle for quantum nonlocality problems in networks

Characterizing quantum nonlocality in networks is a challenging, but important problem. Using quantum sources one can achieve distributions which are unattainable classically. A key point in investigations is to decide whether an observed probability distribution can be reproduced using only classical resources. This causal inference task is challenging even for simple networks, both analytically and using standard numerical techniques. We propose to use neural networks as numerical tools to overcome these challenges, by learning the classical strategies required to reproduce a distribution. As such, a neural network acts as an oracle for an observed behavior, demonstrating that it is classical if it can be learned. We apply our method to several examples in the triangle configuration. After demonstrating that the method is consistent with previously known results, we give solid evidence that a quantum distribution recently proposed by Gisin is indeed nonlocal as conjectured. Finally we examine the genuinely nonlocal distribution recently presented by Renou et al., and, guided by the findings of the neural network, conjecture nonlocality in a new range of parameters in these distributions. The method allows us to get an estimate on the noise robustness of all examined distributions.


I. INTRODUCTION
The possibility of creating stronger than classical correlations between distant parties has deep implications for both the foundations and applications of quantum theory.These ideas have been initiated by Bell [1], with subsequesnt research leading to the theory of Bell nonlocality [2].In the Bell scenario multiple parties jointly share a single classical or quantum source, often referred to as local and nonlocal sources, respectively.Recently, interest in more elaborate causal structures, in which several independent sources are shared among the parties over a network, has been on the rise [3][4][5].Contrary to the Bell scenario, in even slightly more complex networks the boundary between local and nonlocal correlations becomes nonlinear and the local set non-convex, greatly perplexing rigorous analysis.Though some progress has been made [6][7][8][9][10][11][12][13][14][15][16][17][18][19][20], we still lack a robust set of tools to investigate generic networks from an analytic and numerical perspective.
Here we explore the use of machine learning in these problems.In particular we tackle the membership problem for causal structures, i.e. given a network and a distribution over the observed outputs, we must decide whether it could have been produced by using exclusively local resources.We encode the causal structure into a neural network and ask the network to reproduce the target distribution.By doing so, we approximate the question "does a local causal model exist?" with "is a local causal model learnable?".Neural networks have proven to be useful ansätze for generic nonlinear functions in terms of expressivity, ease of learning and robustness, both in-and outside the domain of physical sciences [21][22][23][24][25].They have also been used in the study of nonlocality, however, we note that our method is significantly different from previous ones [26,27], in particular because it allows us to obtain explicit local models.
In our approach we exploit that both causal structures and feedforward neural networks have their information flow determined by a directed acyclic graph.For any given distribution over observed variables and an ansatz causal structure, we train a neural network which respects that causal structure to reproduce the target distribution.This is equivalent to having a neural network learn the local responses of the parties to their inputs.If the target distribution is inside the local set, then a sufficiently expressive neural network should be able to learn the appropriate response functions and reproduce it.For distributions outside the local set, we should see that the machine can not approximate the given target.This gives us a criterion for deciding whether a target distribution is inside the local set or not.In particular, if a given distribution is truly outside the local set, then by adding noise in a physically relevant way we should see a clear transition in the machine's behavior when entering the set of local correlations.
We explore the strength of this method by examining a notorious causal structure, the so-called 'triangle' net-arXiv:1907.10552v1[quant-ph] 24 Jul 2019 work, depicted in Fig. 1.The triangle configuration is among the simplest tripartite networks, yet it poses immense challenges theoretically and numerically.We use the triangle with quaternary outcomes as a test-bed for our neural network oracle.Apart from checking for the consistency of our method with known results, we examine the distribution proposed in [28], which we refer to as the Elegant distribution from here on.Our method gives solid evidence that the Elegant distribution is outside the local set, as originally conjectured.We also use our method to get an estimate of the noise robustness of this nonlocal distribution.

II. ENCODING CAUSAL STRUCTURES INTO NEURAL NETWORKS
The methods developed in this work are in principle applicable to any causal structure.For the sake of simplicity we will demonstrate how to encode a network nonlocality configuration into a neural network on the simple, yet non-trivial example of the triangle network with quaternary outputs and no inputs.In this scenario three sources, α, β, γ, send information through either a classical or a quantum channel to three parties, Alice, Bob and Charlie.Flow of information is constrained such that the sources are independent from each other, and each one only sends information to two parties of the three, as depicted in Fig. 1.Alice, Bob and Charlie process their inputs with arbitrary local response functions, and they each output a number a, b, c ∈ {0, 1, 2, 3}, respectively.Under the assumption that each source is independent and identically distributed from round to round, and that the local response functions are fixed, such a scenario is well characterized by the probability distribution p(abc) over the random variables of the outputs.
If quantum channels are permitted from the sources to the parties then the set of distributions is larger than that achievable classically.Due to the nonlocal nature of quantum mechanics, these correlations are often referred to as nonlocal ones, as opposed to local behaviors arising from only using classical channels.In the classical case, the scenario is equivalent to a causal structure, otherwise known as a Bayesian network [29,30].
For the classical setup we can assume without loss of generality that the sources each send a random variable drawn from a uniform distribution on the continuous interval between 0 and 1.If we also incorporate the network constraint then the probability distribution over the parties' outputs can be written as We now construct a neural network which is able to approximate a distribution of the form (1). We use a feedforward neural network, since it is described by a directed acyclic graph, similarly to a causal structure [29][30][31].This allows for a seamless transfer from the causal structure to the neural network model.We simply take the hidden variables to be inputs and the conditional probabilities p(a|βγ), p(b|γα) and p(c|αβ) to be the outputs, for each possible value of a, b, c.So as to respect the communication constraints of the triangle, the neural network is not fully connected, as shown in Fig. 1.We evaluate the neural network for N values of α, β, γ in order to approximate the joint probability distribution (1) with a Monte Carlo approximation, ( The cost function can be any measure of discrepancy between the target distribution p t and the neural network's output p M , such as the Kullback-Leibler divergence of one relative to the other, namely abc p t (abc) log pt(abc) p M (abc) .In order to train the neural network we synthetically generate uniform random numbers for the hidden variables, the inputs.We then adjust the weights of the network after evaluating a minibatch of size N with conventional neural network optimization methods [31].The minibatch size is chosen arbitrarily and can be increased in order to increase the neural network's precision.
By encoding the causal structure in a neural network like this, we can train the neural network to try to reproduce a given target distribution.The procedure generalizes in a straight-forward manner to any causal structure, and is thus in principle applicable to any quantum nonlocality network problem.

III. RESULTS
Given a target distribution p t , the neural network provides an explicit model for a distribution p M , which is, according to the machine, the closest local distribution to p t .The distribution p M is guaranteed to be from the local set by construction.The neural network will almost never exactly reproduce the target distribution since p M is evaluated by sampling the neural network a finite number of times.As such, to use the neural network as an oracle we could define some confidence level for the similarity between p M and p t .It is however, more generic and perhaps more informative if instead, we search for transitions in the machine's behavior when giving it different target distributions from both outside the local set and inside it.We will typically define a family of target distributions p t (v) by taking a distribution which is believed to be nonlocal and adding some noise controlled by the parameter v, with p t (v = 0) being the completely noisy distribution and p t (v = 1) being the noiseless, "most nonlocal" one.By adding noise in a physically meaningful way we guarantee that at some parameter value, v * , we will enter the local set and stay in it for v < v * .For each noisy target distribution we retrain the neural network and obtain a family of learned distributions p M (v).Observing a qualitative change in the machine's performance at some point is an indication of traversing the local set's boundary.In this work we extract information from the learned model through • the distance between the target and the learned distribution, • the learned distributions p M (v), in particular by examining the local response functions of Alice, Bob and Charlie.
Observing a clear liftoff of the distance d M (v) := d(p t (v), p M (v)) at some point is a signal that we are leaving the local set.Somewhat surprisingly, we can deduce even more from the distance d M (v).Though the shape of the local set and the threshold value v * are unknown, in some cases, under mild assumptions, we can estimate not only v * , but also the angle at which the curve p t (v) exits the local set, and in addition gain some insight into the shape of the local set near p t (v * ).To do this, let us first assume that the local set is flat near p t (v * ) and that p t (v) is a straight curve.Then the true distance from the local set is where θ is the angle between the curve p t (v) and the local set's hyperplane (see Fig. 2 for an illustration).In the more general setting Eq. ( 3) is still approximately correct even for v > v * , if p t (v) is almost straight and the local set is almost flat near v * .We denote our approximation of the true distance form the local set as d(v).We use Eq. ( 3) to calculate it but keep in mind that it is only an approximation.Given an estimate for the two parameters v * and θ this function can be compared to what the machine perceives as a distance, d M (v).Finding a match between the two distance functions gives us strong evidence that indeed the curve p t (v) exits the local set at v * at an angle θ, where the hat is used to signify the obtained estimates.We also get information out of the learned model by looking at the local responses of Alice, Bob and Charlie.
Recall that the shared random variables, the sources, are uniformly distributed, hence the response functions encode the whole problem.These are already interesting in themselves and can guide us towards analytic guesses of the ideal response functions.However, they can also be used to verify our results in some special cases.For example, if θ = 90 • and the local set is sufficiently flat, then the response functions should be the same for all v ≥ v * .On the other hand if θ < 90 • then we are in a scenario similar to that of the left panel in Fig. 2 and the response functions should differ for different values of v.

A. Fritz distribution
First let us consider the quantum distribution proposed by Fritz [5], which can be viewed as the CHSH Bell scenario wrapped into the triangle topology.Alice and Bob share a singlet, i.e. |ψ AB = |ψ − = 1 √ 2 |01 − |10 , while Bob and Charlie share either a maximally entangled or a classically correlated state with Charlie, such as ρ BC = 1 2 (|00 00| + |11 11|) and similarly for ρ AC .Alice measures the shared state with Charlie and, depending on this random bit, she measures either the Pauli X or Z observable.Bob does the same with his shared state with Charlie and measures either X+Z √ 2 or X−Z √ 2 .They then both output the measurement result and the bit which they used to decide the measurement.Charlie measures both sources in the computational basis and announces the two bits.We now introduce a finite visibility for the singlet shared by Alice and Bob, thus examining a Werner state, where I/4 denotes the maximally mixed state of two qubits.For such a state we expect to find a local model below the threshold of v * = 1 √ 2 .In Fig. 3 we plot the distances discussed previously for θ = 90 • and v * = 1 √ 2 .The coincidence of the two curves is already good evidence that the machine finds the closest local distributions to the target distributions.Upon examining the response functions of Alice, Bob and Charlie, also in Fig. 3, we see that they do not change above v * , which means that the machine finds the same distributions for target distributions outside the local set.This is in line with our expectations.Due to the connection with the CHSH Bell scenario, we believe the curve p t (v) exits the local set perpendicularly and that the local set is a polytope, as depicted on the right panel in Fig. 2.These results reaffirm that our algorithm functions well.

B. Elegant distribution
Next we turn our attention to a distribution which is more native to the triangle structure, as it combines entangled states and entangled measurements.We examine the Elegant distribution, which is conjectured in [28] to be outside the local set.The three parties share singlets and each perform a measurement on their two qubits, the eigenstates of which are where the |m j are the pure qubit states with unit length Bloch vectors pointing at the four vertices of the tetrahedron for j = 1, 2, 3, 4, and | − m j are the same for the inverted tetrahedron.We examine two noise models -one at the sources and one at the detectors.First we introduce a visibility to the singlets such that all three shared quantum states have the form (4). Second, we examine detector noise, in which each detector defaults independently with probability 1 − v and gives a random output as a result.This is equivalent to adding white noise to the quantum measurements performed by the parties, i.e. the positive operator-valued measure elements are For both noise models we see a transition in the distance d M , depicted in Fig. 4, giving us strong evidence that the conjectured distribution is indeed nonlocal.Through this examination we gain insight into the noise robustness of the Elegant distribution as well.It seems that for visibilities above v * ≈ 0.80, or for detector noise above v * ≈ 0.86, the distribution is still nonlocal.The curves exit the local set at approximately θ ≈ 50 • and θ ≈ 60 • , respectively.Note that for both distribution families, by looking at the unit tangent vector, one can analytically verify that the curves are almost straight for values of v above the observed threshold.This gives us even more confidence that it is legitimate to use the approximate distance d(v) as a reference.In Fig. 4 we illustrate how the response function of Charlie changes when adding detector noise.It is peculiar how the machine often prefers horizontal and vertical separations of the latent variable space, with very clean, deterministic responses, similarly to how we would do it intuitively, especially for noiseless target distributions.

IV. DISCUSSION
The standard method for tackling the membership problem in network nonlocality is numerical optimization.For a fixed number of possible outputs per party, o, without loss of generality one can take the hidden variables to be discrete with a finite alphabet size, and the response functions to be deterministic.In fact the cardinality of the hidden variables can be upper bounded as a function of o [12].Specifically for the triangle this upper bound is o 3 − o.This results in a straightforward optimization over the probabilities of each hidden variable symbol and the deterministic responses of the observers, giving 3(o 3 − o − 1) continuous and 3(o 3 − o) 2 discrete optimization parameters.For binary outputs, i.e. o = 2, this means only 15 continuous and 72 discrete variables and is feasible.However, already for the case of quaternary outputs, o = 4, this optimization is a computational nightmare on standard CPUs with a looming 177 continuous and 10800 discrete optimization parameters.Even when constraining the response functions to be the same for the three parties, p A = p B = p C , and the latent variables to have the same distributions, p α = p β = p γ , the problem becomes intractable around a hidden variable cardinality of 8, which is still much lower than the current upper bound of 60 that needs to be examined.Standard numerical optimization tools quickly become infeasible even for the triangle configuration -not to mention larger networks!
The causal modeling and Bayesian network communities examine scenarios similar to those relevant for quantum information [29,30].The core of both lines of research are directed acyclic graphs and probability distributions generated by them.In these communities there exist methods for this so-called 'structure recovery' or 'structure learning' task.However, these methods are either not applicable to our particular scenarios or are also approximate learning methods which make many assumptions on the hidden variables, including that the hidden variables are discrete.Hence, even if these learning methods are quicker than standard optimization for current scenarios of interest, they will run into the scaling problem of the latent variable cardinality.
The method demonstrated in this paper attacks the problem from a different angle.It relaxes both the discrete hidden variable and deterministic response function assumptions which are made by the methods previously mentioned.The complexity of the problem now boils down to the response function of the observers -each of which is represented by a feedforward neural network.Though our method is an approximate one, one can increase its precision by increasing the size of the neural network, the number of samples we sum over (N ) and the amount of time provided for learning.Due to universal approximation theorems we are guaranteed to be able to represent essentially any function with arbitrary precision [32][33][34].For the distributions examined here we find that there is no significant change in the learned distributions after increasing the neural network's width and depth above some moderate level, we have reached a plateau.For the Elegant distribution, for example, for each party we used depth 5 and width 30.We note, however, that we did not do a rigorous examination of how much this can be reduced while still detecting the same thresholds.Also, for larger network sizes the machine could in principle learn more complex functions.However studying this thoroughly can be tedious since the amount of time that the machine needs to learn typically increases with network size.We were satisfied with the current complexity, since getting a local model for a single target distribution takes a few minutes on a standard computer, using a mini-batch size of N = 8192.The question of what the minimal required complexity of the response functions is, is interesting enough for a separate study.
We have demonstrated how, by adding noise to a dis-tribution and examining a family of distributions with the neural network, we can deduce information about the membership problem.For a single target distribution the machine finds only an upper bound to the distance from the local set.By examining families of target distributions, however, we get a robust signature of nonlocality due to the clear transitions in the distance function, which match very well with the approximately expected distances.

V. CONCLUSION
In conclusion, we provide a method for testing whether a distribution is classically reproducible over a directed acyclic graph, relying on a fundamental connection to neural networks.The simple, yet effective method can be used for arbitrary causal structures, even in cases where current analytic tools are unavailable and numerical methods are futile, allowing quantum information scientist to test their conjectured quantum, or postquantum, distributions to see whether they are locally reproducible or not, hopefully paving the way to a deeper understanding of quantum nonlocality in networks.
To illustrate the relevance of the method, we have applied it to an open problem, giving firm numerical evidence that the Elegant distribution is nonlocal on the triangle network, and getting estimates for its noise robustness under two physically relevant noise models.
The obtained results on nonlocality are convincing, but are still just numerical evidence.Examining whether a certificate of nonlocality can be obtained from machine learning techniques would be an interesting further research direction.In particular, it would be fascinating if a machine could derive, or at least give a good guess for a Bell-type inequality which is violated by the Elegant distribution.In general, seeing what insight can be gained about the boundary of the local set from machine learning would be interesting.Perhaps a step in this direction would be to understand better what the machine learned, for example by somehow extracting an interpretable model from the neural network analytically, instead of by sampling from it.A different direction would be to apply similar ideas to networks with quantum sources, allowing a machine to learn quantum strategies for some target distributions.

FIG. 2 :
FIG. 2: Visualization of target distributions pt(v) leaving the local set at an angle θ for a generic noisy distribution (left) and for the specific case of the Fritz distribution with a 2-qubit Werner state shared between Alice and Bob (right).The grey dots depict the target distributions, while the red dots depict the distributions which the neural network finds.

FIG. 4 :
FIG. 4: Elegant distribution results.(Left) Comparison of the distance perceived by the machine, dM (v) and the approximation of the distance d(v).Both visibility and detector noise model results are shown.(Right) Responses of Charlie illustrated as a function of β, γ, similarly to Fig. 3. Detector noise values (top left to bottom right): 0.5, 0.72, 0.76, 1.