Learning an unknown transformation via a genetic approach

Recent developments in integrated photonics technology are opening the way to the fabrication of complex linear optical interferometers. The application of this platform is ubiquitous in quantum information science, from quantum simulation to quantum metrology, including the quest for quantum supremacy via the boson sampling problem. Within these contexts, the capability to learn efficiently the unitary operation of the implemented interferometers becomes a crucial requirement. In this letter we develop a reconstruction algorithm based on a genetic approach, which can be adopted as a tool to characterize an unknown linear optical network. We report an experimental test of the described method by performing the reconstruction of a 7-mode interferometer implemented via the femtosecond laser writing technique. Further applications of genetic approaches can be found in other contexts, such as quantum metrology or learning unknown general Hamiltonian evolutions.

The genetic algorithm, which aims at learning the unitary transformation U r starting from the collected data set, is structured as follows.
1. A distribution of N DNA sequences, representing N different m × m unitary matrices, is generated. The parameters {t l k , α l k .β l k } are drawn from appropriate distributions, so that the generated unitaries are distributed according to the Haar measure [S1]. An approximate form of these distributions have been evaluated numerically by sampling unitary matrices from the Haar measure. More specifically, the phase differences α l k − β l k are drawn from the uniform distribution, while the transmittivities t l k are drawn from a triangular one u(t i ) = 2t i . The exact form of these distribution can be evaluated as shown in [S2]. The obtained set of N DNAs constitutes the populationΦ 0 = {Ẽ 1 , ...,Ẽ N }.
1 . The analytic method proposed in Ref. [S3] is applied to the experimental data. A set of m 2 independent estimates of the unitary [S4] is obtained, starting from this approach, by selecting appropriate subsets of the data and by performing permutations of the mode indexes. DNA sequences for the N 1 = 20 unitaries presenting higher fitnesses are then evaluted. Finally, N 1 elements of the populationΦ 0 obtained at step 1 are replaced by the N 1 candidates determined from the analytic method. The new set of N DNAs constitutes the initial population Φ 0 = {E 1 , ..., E N }.
2. The population is sorted by decreasing fitness values, evaluated between the experimental data (P i,j ,Ṽ ij,pq ) and the predictions (P E l i,j , V E l ij,pq ) obtained from the matrices of the population, with l = 1, . . . , N . The new ordered population set is Φ 1 = {E 1 , ..., E N }.
3. The single-photon probabilities P E 1 and the two-photon visibilities V E 1 are calculated from the element E 1 . If f (E 1 ) ≥ δ the algorithm halts and returns the solution matrix U E 1 . More specifically, the unitary matrix U E 1 is obtained from the conversion function T (E 1 ) which relates the genetic code to the corresponding unitary transformation [S5].
4. The second half of the population, consisting of the individuals with lowest fitness values, is removed. The resized population Φ 2 is the set Φ 2 = {E 1 , ..., E N/2 }.
5. Crossover is applied between two randomly chosen individuals. The corresponding generated offspring is added to the population set Φ 2 . This operation is iterated with other couples of individuals until the number of elements of Φ 2 is N . The result of this mechanism is a new population where the elementsĒ l are the newly-generated individuals.
6. During the evolution of the system, several individuals with the identical DNA (clones) corresponding to the element with highest fitness may spread in the population. This effect causes a steady depletion of the gene pool, which in turn leads to an early convergence of the algorithm to a local maximum of f (E). To avoid this effect two countermeasures have been adopted: (i) Random Offspring Generation [S6], which imposes that crossover betweeen two clones generates a child with random DNA, and (ii) Packing, which consists in identifying clusters of clones in the population every q iteration. For each of these clusters, all the elements except one are removed and the population is filled by randomly generated new individuals.
7. For each element l = 2, ..., N , mutation is applied with probability γ. The index l starts from the value 2 to avoid a mutation on the individual with highest fitness in the population. This constraint is commonly refereed to as Elitism. A new population Φ 4 = {E 1 , ..., E N } is obtained.
8. Steps 2-7 are iterated starting from the new population Φ 4 until the halting condition is reached at step 3.

SUPPLEMENTARY NOTE 2: ALGORITHM CONVERGENCE
To characterize the performance of the developed genetic algorithm, we have performed numerical simulations for different circuit size with simulated data. More specifically, for each tested size we generated N unit = 50 different Haar-random unitary matrices. For each matrix, the complete set of single-photon probabilities and two-photon visibilities is calculated. To include the effect of statistical errors corresponding to a finite size experimental data sample for each quantity, noisy data are simulated by generating random numbers following a Gaussian distribution with µ equal to the exact value, and σ equal to the simulated noise. We employed a value of the (relative) noise equal to 3% for single-photon probabilities, and 5% for the two-photon visibilities.
The simulated noisy data are fed into the genetic algorithm to learn the unitary transformation. The obtained results for m = 4, m = 5 and m = 6 interferometers are shown in Supplementary Fig. 1 and compared to what is obtained with the analytic approach (which is employed as seed for the genetic approach) and with a numerical derivative-based minimization routine (adopting the solution of the analytic method as a starting point). More specifically, we report the histograms of the reduced χ 2 ν (that is, the χ 2 divided by the number of degrees of freedom ν). We observe that the conventional numerical routine and the genetic approach provide comparable performances in terms of achieved χ 2 ν , with value close to 1. On the other side, the analytic approach in general fails to capture the optimal solution in the presence of statistical noise.
Note that the same set of parameters (mutation rate, population size, ...) is employed for all unitary matrices at a given size m. Furthermore, in these simulations a single set of parameters is shown to be effective for all investigated m. However, it is likely that by further increasing the interferometer dimension m, the set of hyperparameters has to be tuned to optimize and guarantee convergence of the algorithm.

SUPPLEMENTARY NOTE 3: EXPECTED AND RECONSTRUCTED UNITARY MATRICES
Here we report the unitary matrix corresponding to the interferometer design U and the one obtained from the reconstruction with the genetic approach U (g) r , shown in Fig. 4 of the main text. The expected unitary matrix is calculated by exploiting from the actual internal structure of device, shown in Fig. 1 d, which is composed by a network of symmetric 50/50 beam-splitters interspersed by static relative phases between the modes. The fabrication phases for each layer are reported in Supplementary  Table 1 The expected unitary U has real part: and imaginary part: The reconstructed unitary matrix U (g) r with the genetic approach has real part: