{'fraction_non_alphanumeric': 0.028333333333333332, 'fraction_numerical': 0.010588235294117647, 'mean_word_length': 4.762994350282486, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Experimental hybrid quantum-classical reinforcement learning by boson sampling: how to train a quantum cloner

We report on experimental implementation of a machine-learned quantum gate driven by a classical control. The gate learns optimal phase-covariant cloning in a reinforcement learning scenario having fidelity of the clones as reward. In our experiment, the gate learns to achieve nearly optimal cloning fidelity allowed for this particular class of states. This makes it a proof of present-day feasibility and practical applicability of the hybrid machine learning approach combining quantum information processing with classical control. Moreover, our experiment can be directly generalized to larger interferometers where the computational cost of classical computer is much lower than the cost of boson sampling.


INTRODUCTION
Machine learning methods are extensively used in an increasing number of fields, e.g., automotive industry, medical science, internet security, air-traffic control etc. This field conveys many algorithms and structures ranging from simple linear regression to almost arbitrarily complex (limited by computational resources and amount of training data) neural networks which are able to find solutions to highly nonlinear/complex problems. Recently, a considerable attention was drawn to the overlap between quantum physics and machine learning [1]. Depending on the type of input data and data processing algorithms, we can distinguish four types of so called quantum machine learning (QML), i.e., CC (classical data and classical data processing -classical limit of quantum machine learning), QC (quantum data and classical data processing), CQ (classical data and quantum data processing), and QQ (quantum data and quantum data processing).
In addition to its fundamentally interesting aspects, QML can offer reduced computational complexity with respect to its classical counterpart in solving some classes of problems [1]. Depending on the problem at hand the speedup can be associated with various features of quantum physics. A number of proposals and experiments focused on QML have been reported, such works include for instance quantum support vector machines [2], Boltz- mann machines [3], quantum autoencoders [4], kernel methods [5], and quantum reinforcement learning [6,7]. In reinforcement learning a learning agent receives feedback in order to learn an optimal strategy for handling a nontrivial task. Next, the performance of the agent is tested on cases that were not included in the training. If the agent performs well in these cases the validation is completed.
In this paper, we demonstrate experimentally that reinforcement learning can be used to train an optical quantum gate (see conceptual scheme in Fig. 1). This problem is related to the boson sampling problem [8][9][10][11][12] where one knows the form of the scattering matrix of a system and learns its permanent. However, here we optimize the probabilities of obtaining certain outputs of arXiv:1906.05540v1 [quant-ph] 13 Jun 2019 the gate by finding the optimal parameters of the scattering matrix. Calculating the probabilities (permameters of scattering matrix) is in general a computationally hard task while measuring them is much faster. This feature of quantum optics allows us to expect that complex integrated interferometers could be applied as specialpurpose quantum computers (for a 16 photon quantum interferometer see [13]). This sets our problem in the class of CQ quantum machine learning tasks. There are other QML approaches that could be used to optimize a quantum circuit. One approach uses classical machine learning to optimize the design of a quantum experiment in order to produce certain defined states [14]. Another QML approach consists of optimizing quantum circuits to improve the solution to some problems solved on a quantum computer [15]. The latter method is motivated by recent developments in quantum computing which suggest that using a quantum computer even to minor tasks within an experiment can save computational resources [16,17].
We applied online reinforcement learning methods to train an optimal quantum cloner. Quantum cloning is essential both for certain experimental tasks and for fundamental quantum physics. It is indispensable for safety tests of quantum cryptography systems or of other quantum communications protocols. Perfect quantum cloning of an unknown state is prohibited by the no-cloning theorem [18]. However, it is possible to prepare imperfect clones that resemble the original state to a certain degree. Usually, the approach towards quantum cloning involves explicit optimization of the interaction between the system in the cloned state and another systems to maximize the fidelity of the output clones. Then, one uses such results explicitly to set the parameters of the experimental setup. In contrast to that, we present a quantum gate (learning agent) that is capable to self-learn such interaction (policy) based on provided feedback (implicit setting of the parameters). For the purposes of this proof-ofprinciple experiment, we limit ourselves to qubits in the form of where |0 and |1 denote logical qubit states. These qubits can be found on the equator of the Bloch sphere, hence, we call them equatorial qubits. Cloning of these states is known to be the optimal means of attack on individual qubits of the famous quantum cryptography protocols BB84 [19] and RO4 [20,21] or quantum money protocol [22] (see also Refs. [23,24] for experimental implementation).

RESULTS
We demonstrate reinforcement-learned quantum cloner for a class of phase-covariant quantum states. For the training procedure, the figure of merit is the individual fidelity of the output copies. The fidelity of the j-th clone is defined as overlap between the state of the input qubit |ψ in and the state of the cloneˆ j : In case of the state in Eq. (1), the maximum achievable fidelity of symmetrical 1 → 2 cloning accounts for F 1 = F 2 = 1 2 1 + 1 √ 2 ≈ 0.8535 [25,26]. We have constructed a two qubit gate on the platform of linear optics. Qubits were encoded into polarization states of the individual photons (|0 ⇔ |H and |1 ⇔ |V ). The gate operates formally as a polarization dependent beam splitter with tunable splitting ratios for horizontal (H) and vertical (V ) polarization. This tunability provides two parameters for self-learning labeled φ and θ throughout the text. The third learnable parameter ω is embedded in the state of the ancillary photon |ψ a = cos 2ω |H + sin 2ω |V . ( We have experimentally implemented two machine learning models using two and three parameters, respectively. In the first model, we fixed the ancilla state to its theoretically known optimum |ψ a = |H . The remaining two parameters of the gate φ and θ were machine learned. To minimize the cost function (i.e. optimize the performance of the cloner) we applied Nelder-Mead simplex algorithm which iteratively searches for a minimum of a cost function. We chose the cost function to be in the form of where F 1 and F 2 stand for the fidelity of the first and second clone, respectively. This choice reflects the natural requirements to obtain maximum fidelities of both the clones as well as to force the cloner into a symmetrical cloning regime. Training of the gate consists of providing it with training instances of equatorial qubit states (randomly generated in each cost function evaluation, i. e. an online machine learning scenario) and with the respective fidelity of the clones. In each training run, the underlying Nelder-Mead algorithm sets the gate parameters to vertices of simplexes in the parameter space and then decides on a future action. In the case of a twoparameter optimization, these simplexes correspond to triangles as depicted in Figure 2. In this Figure, we plot the exact path taken by the Nelder-Mead simplex algorithm to minimize the cost function C for the case of a real experiment and its simulation. The selected initial simplex was intentionally chosen well away from the optimal position -its first vertex resembles the trivial cloning strategy [24,28]. In Figure 3a, we illustrate the evolution of both the fidelities F 1 and F 2 during the training. After 40 runs (i.e. 40 instances from the training set), this model was deemed trained because the size of simplexes dropped to the experimental uncertainty level (i.e. ∼ 0, 1 • on rotation angles of wave plates). However, in general, setting the simplex to converge within a given precision is a nontrivial problem [29]. In the second model, we let the gate learn the optimal setting of the ancilla ω along with the gate parameters φ and θ. The training procedure ran similarly to the first model. The initial value of the ω parameter was set naively to ω = π 8 so it lied on the equator of the Poincaré-Bloch sphere. We present evolution of the intermediate fidelities of this three-parameter model in Figure 3b. Using a similar stopping criterion as in the first model, the training of the second model was terminated after 60 runs.
We have tested the performance of both our models on independent random test sets each populated by 40 instances of equatorial states. We summarize the results of the two models in Table I, where we provide the final learned parameters together with the mean values of the fidelities on the test sets F 1 and F 2 . The observed fidelities on test sets are bordering on the theoretical limit (at most 0.013 below it) which renders our gate highly precise in context of previously implemented cloners [25,[30][31][32][33][34].

EXPERIMENTAL REALIZATION
We constructed a device composed of a linear optical quantum gate and a computer performing classical information processing. While the gate itself is capa- ble of a broad range of two qubit transformations, this paper focuses on its ability to act as a phase-covariant quantum cloner. The experimental setup is depicted in Fig. 4. Pairs of photons are generated in Type I spontaneous parametric down-conversion occurring in a nonlinear BBO crystal. This crystal is pumped by Coherent Paladin Nd-YAG laser with integrated third harmonic generation of wavelength at λ = 355 nm. The generated pairs of photons are both horizontally polarized and highly correlated in time. These photons are then spectrally filtered by 10 nm wide interference filters and spatially filtered by two single mode optical fibers each guiding one photon from the pair. In our experimental setup, qubits are encoded into polarization states of the individual photons. The pho-  ton in the upper path (spatial mode 2) represents the signal qubit, quantum state of which we want to clone, and the photon in the lower path (spatial mode 1) serves as the ancilla.
Using polarization controllers (PC) we can ensure that both photons are horizontally polarized at the output of the fibers. From now on, polarization states of the photons are set using a combination of half-wave plates (HWPs) and quarter-wave plates (QWPs). There are eight wave plates in total, two stationary QWPs fixed at angle 45 • and six motorized HWPs which make it possible to control the whole quantum gate using a computer. The first two half-wave plates HWP 1 and HWP 2 are used to set input polarisation states of the photons. The core part of the presented quantum gate is a Mach-Zehnder-type interferometer which consists of two polarizing beam splitters (PBS) and two reflective pentaprisms, one of which is attached to the piezoelectric stage (PS). With the addition of two HWPs (HWP 3 and HWP 4 ) placed in its arms, this whole interferometer implements a polarization dependent beam splitter with variable splitting ratio. Mathematically, the scattering matrix of the gate reads  (5) is formally equivalent to the transformation by a polarization dependent beam splitter, the intensity splitting ratios of which for horizontal and vertical polarizations are cot 2 2φ and cot 2 2θ, respectively. The two spatial modes at the output of the interferometer are subjected to polarization projection (QWP 5 , QWP 6 and HWP 7 , HWP 8 ) and then led via singlemode optical fibers to a pair of avalanche photodiodes by Perkin-Elmer running in Geiger mode. We use detection electronics to register both single photons at each of the detectors and coincident detections as successful operation of the gate is indicated by the presence of single photon in each output of the interferometer. The electronic signal is then sent to a classical computer.
For specific parameters of the presented linear-optical elements, this quantum gate functions as a 1 → 2 symmetric phase-covariant cloner, optimal analytical cloning transformation of which is well known [25]. On a linearoptical platform, this optimal cloning transformation can be achieved by a polarization dependent beam splitter with intensity transmitivities for horizontal and vertical polarization at t H ≈ 0.19 and t V ≈ 0.81, while setting the ancilla to be horizontally polarized. Note that our quantum gate is capable of implementing this transformation when set approximately to φ = 31.3, θ = 13.7 and the maximum theoretical fidelities of the clones are To showcase the capability of our gate to learn to clone phase-covariant states optimally, we deliberately ignore this analytical solution and employ self-optimization procedure seeking to maximize the cloning fidelities. The optimization process consists of a number of measurements (runs), each performed for a set of variable optimization parameters φ, θ, ω. That is, variable splitting ratio for horizontal (φ) and vertical (θ) polarization as well as the state of the ancilla (ω) (Eq. 3) controlled by the rotation of HWP 1 . In each run, output clones fidelities are evaluated and supplied to the classical Nelder-Mead algorithm for a decision about the parameters of the future runs.
In between any two runs, the setup is stabilized. We first minimize temporal delay between the two individual photons. In this case, all HWPs are set to 0 • with the exception of HWP 4 being at 22.5 • . In this regime, we minimize the number of two-photon coincident detections (Hong-Ou-Mandel dip) by changing the temporal delay between the photons using a motorized translation stage MT. In the next step, the phase is stabilized in the interferometer. Moreover, we make use of the fact that the phase shift in the interferometer additively contributes to the phase η of the signal state (Eq. 1). This allows us to use interferometer phase stabilization for setting of any signal state of the equatorial class. We achieve this task by setting HWP 2 to 22.5 • and HWP 8 to the value corresponding to orthogonal state with respect to the required input signal state. All other HWPs are set to 0 • and a minimum in single-photon detections on Det 2 is found by tuning the voltage applied to PS. Note that the entire stabilization procedure is completely independent of the learning process itself.
While all six of the HWPs are controlled by a PC, only three (HWP 1 , HWP 3 and HWP 4 ) are specifically controlled by the optimization algorithm. In contrast to that, HWP 2 is used to set the quantum state of the cloned qubit and HWP 7 and HWP 8 are used to choose polarization projections, therefore their configuration shall not be accessible to the optimization algorithm.
In this reinforced-learning scenario, the cloner is trained on a sequence of random equatorial signal states (Eq. 1) different for each run. The phase η is randomly picked from interval (0; 2π). The optimization algorithm then rotates HWP 1 , HWP 3 and HWP 4 to chosen angles φ, θ, ω. Finally, the cloner is fed back the measured fidelities F 1 , F 2 of the clones.
The fidelities are obtained by measuring coincidence detections in four different projection settings that correspond to the angles set on HWP 7 and HWP 8 . We label these coincident detections cc ij , where i, j ∈ { ; ⊥}. The and the ⊥ sign denote projection on the signal state |ψ s and its orthogonal counterpart ψ ⊥ s . We calculate the fidelities as where Σ denotes cc + cc ⊥ + cc ⊥ + cc ⊥⊥ . The core part of the optimization process is the Nelder-Mead simplex algorithm which minimizes a chosen cost function C in a multidimensional space corresponding to the number of the function parameters N [27]. The algorithm takes (N + 1) points in the parameter space to create a (N + 1) dimensional initial simplex (each point corresponds to one of the simplex vertices). For example, with 2 parameters being optimized, the algorithm creates a triangle, for 3 parameters it creates a tetrahedron and so on. The value of the cost function at each point of the simplex is then evaluated and the algorithm transforms the simplex in such way to find a point of local minimum. In our case, we define the cost function C so that the first two elements maximize the obtained fidelities, while the last element achieves symmetry of the cloning.

CONCLUSIONS
In our proof of principle experiment, we implemented a CQ reinforcement quantum machine learning algorithm driven by a hybrid of classical Nelder-Mead method and quantum computing based permanent measurement. This approach was used to train a practical quantum gate (i.e., a quantum cloner). The task of the training was to optimize parameters of the gate (interferometer) φ, θ and ω (setting of the ancilla in the second experiment) to perform phase-covariant cloning. The quality of both the clones measured by their fidelities F 1 and F 2 which were evaluated within both experiments (Figure 3) successfully reached the theoretical limit for phasecovariant cloning 0.854. Remarkably, the cloner managed to achieve almost optimal cloning by learning setup parameters, slightly different from analytical values, that counter all experimental imperfections including imperferctions in the cloner itself and in the input state preparation.
To see the connection between boson sampling and our results, let us focus on computing the permanent Perm of scattering matrix describing the gate operation. The unitary scattering matrix U performs linear transformation on the annihilation operators a i of the input modes (i can be an index labeling both the polarization and the spatial degrees of freedom). Then the input-output relation of an quantum-optical interferometer is given as If all the input modes of an interferometer are injected with single photons and single photons are detected at specific outputs (no bunching) the probability of obtaining the desired detection coincidence is p = |PermU | 2 . However, this expression becomes more complex if some modes are occupied by more than one photon. Then factorials of mode-specific photon numbers appear as denominator and the respective rows/columns of U must be repeated a corresponding number of times [8]. If some output modes are not to be populated, the respective row of U matrix is deleted. Calculating the permanents of the scattering matrix associated with our cloner by hand is already challenging (we have polarization and spatial degrees of freedom for two photons) and in general it falls into the #P -hard complexity class. Our experiment can be directly generalized to larger interferometers, where the computational cost of classical computer is much lower than the cost of boson sampling. This makes our research a relevant application of so-called quantum circuit learning described in Ref. [35].
Our results also opens possibilities of further research or applications in the field of quantum key distribution. Suppose a typical attack on the key distribution scheme: Bob and Alice share quantum states and the attacker Eve is eavesdropping on them. Bob and Alice exchange quantum states and, via a classical line, they can decide to stop exchanging qubits (because of noise). Let us assume that Eve is eavesdropping on both quantum and classical communication. Eve can in principle use reinforced-learning to train a cloner to perform the attack by feeding it with information on the behavior of Bob and Alice, e.g., their decision on continuing or aborting the exchange of a quantum key and/or their decision on parameters of privacy amplification. For such application the proposed gate would have to be modified since Eve does not know the specific class of states used by Bob and Alice, but that is out of the scope of this paper.