Introduction

Trapped ions are one of the most promising candidates for implementing scalable quantum information processing1,2,3,4. Traditionally macroscopic rod traps were used for electrically trapping laser cooled ions. These Paul traps have a deep potential well that enables the trapping of multiple ions in a chain, but their distant electrodes lack the fine spatial control of electric fields necessary to efficiently split and combine small ion crystals5. One of the proposed architectures for scaling up the number of trapped ions in a quantum processor is the use of microfabricated surface chip traps with multiple DC electrodes that are able to manipulate multiple ions individually6,7,8,9,10.

In these chip traps the ions are confined to a potential formed by the node of an oscillating RF electric field in two dimensions while a DC field generated from multiple electrodes provides a finely spatially adjustable potential in the third dimension. It is well-known in Paul trapping that stray DC electric fields push the ion off the RF node and induce micromotion that degrades or outright prevents effective confinement and laser-cooling11. The solution to this problem is to use the DC electrodes to generate an opposite DC electric field that compensates for these stray fields9.

Micromotion amplitude can be measured and dealt with in multiple ways9,12,13,14,15. Most of the conventional methods are time consuming and can only be done manually. A simple and quick proxy, that is only applicable to small amounts of micromotion, is to measure the ion’s fluorescence under laser cooling near the Doppler limit. In fact for low magnitudes of micromotion, if a laser is red-detuned near the natural linewidth of the atom, the ion fluorescence rate increases as the micromotion amplitude decreases (see “Experimental setup” section and Fig. 2a). While stray electric fields can be readily compensated in simple fixed trap geometries16, this task becomes more challenging for multi-electrode designs17 and in proximity of surfaces which are vulnerable to laser induced charging18.

Automation, optimization, and machine learning have been used to improve different manual tasks in atom and ion traps19,20,21 and they are also useful tools for optimizing the individual electrode voltages which generate the trapping electric field. In this work we show how the voltages of an array of electrodes in a surface chip trap can be optimized using a fully automated, machine learning driven process to minimize micromotion and maximize florescence. The chip trap in our experiment has 44 segmented DC electrodes and 2 RF rails, as shown in Fig. 1. The trap incorporates nearly aberration free diffractive mirrors directly fabricated onto the central ground electrode for efficient fluorescence collection from the ion22. A Gradient descent (ADAM23) and a machine learning algorithm (MLOOP20) were compared on the basis of the versatility and time taken to find the optimal compensation and highest fluorescence rate of the ion. These methods were applied to a trapped \(^{171}\)Yb\(^+\) ion and compared to a manual optimization performed by an experienced operator.

With ADAM we were able to improve the fluorescence by 78% starting from voltages already optimized by manual adjustment, while MLOOP achieved a 96% improvement. Subsequently we tested the versatility and adaption of this procedure by deliberately charging the trap with UV light to drop the fluorescence rate by around 35% and compensating back to the optimal with ADAM. This was not tested on MLOOP as it was observed to be quite sensitive to the noise in the fluorescence signal and did not make a solid candidate for final optimization of the artificially charged trap.

Experimental setup

Figure 1
figure 1

(a) Transitions for laser cooling \(^{171}\)Yb\(^+\). The ion is laser cooled on the nearly closed 369.5 nm \(^2\)S\(_{1/2}\), F = 1 to \(^2\)P\(_{1/2}\), F = 0 transition. The small amount of off-resonant scattering into the \(^2\)S\(_{1/2}\) F = 0 state is repumped with a 14.7 GHz sideband on the primary cooling laser. Decays from \(^2\)P\(_{1/2}\) can also populate the \(^2\)D\(_{3/2}\) level, which are repumped using a 935 nm laser. (b) Schematics of the ion trap chip and the optimization devices. RF and DC electrodes are used to trap the ion and shuttle it above the diffracting mirror that collects photons from the ion and sends it to photo multiplayer tube (PMT). The PMT counts are processed by the optimiser and DC electrode voltages and cooling laser position are updated using a digital to analogue converter (DAC).

The ion trap used in these experiments and described in22,24, consists of a planar rectangular chip of 1400 \(\mu \)m length and 800 \(\mu \)m width. It has a set of aluminum electrodes patterned on top and is schematically shown in Fig. 1. The ion is trapped 60 \(\mu \)m above the surface, between the two RF electrode rails that extend for the full length of chip, and 44 DC electrodes on the sides. The DC electrodes are used for creating a reconfigurable trapping potential along the length of the trap, compensating stray electric fields, and enabling ion crystals merging, separation, and shuttling.

An atomic oven underneath one end of the trap generates a beam of neutral Yb atoms which passes through a slit in the chip. The \(^{171}\)Yb is first excited by an isotopically selective 399 nm laser25, and subsequently non-resonantly ionized by a 369.5 nm laser. The ion is then Doppler cooled using the same 369.5 nm laser tuned nearly resonant with \(^2\)S\(_{1/2}\) F = 1\(\leftrightarrow ^2\)P\(_{1/2}\) F = 0 transition. To efficiently cool the ion in both x and y directions, the RF axis of the trap is slightly tilted and therefore the horizontal cooling laser has a component along both nearly horizontal x-axis and nearly vertical y-axis. Occasionally off-resonant scattering from the \(^2\)P\(_{1/2}\) F = 1 state will populate the dark \(^2\)S\(_{1/2}\) F = 0 ground state, which is repumped by a small amount of light from a 14.7 GHz sideband added to the primary 369.5 nm cooling laser. There is also a probability of 0.5% for the atom to decay from the \(^2\)P\(_{1/2}\) into the meta-stable \(^2\)D\(_{3/2}\) state. In this case a 935 nm laser repumps the ions back into the cooling cycle. Figure 1a depicts the cooling and repumping transitions.

After initial trapping near the oven slit region, the ion is shuttled along the length of the trap by properly controlling the voltages of the array of DC electrodes with a 12-bit National Instruments PXI-6713 DAQ (output doubled to +/\(-20\)V with 10 mV resolution). For our experiments, the ion was shuttled above the surface of an integrated diffracting micro-mirror patterned on the ground electrode with a focal length of 60 \(\mu \) m, equal to the height of the ion above the trap, to improve florescence collection and coupling into a single mode fiber22.

For efficient Doppler cooling and subsequent quantum information processing experiments, it is important to minimize any micromotion induced by stray electric fields. This is done by tuning the voltages of the DC electrodes so that they generate an opposing electric field that compensates for the stray fields. To manually compensate stray electric fields in the RF confinement plane xy (see Fig. 1), it is not practical to individually tune all the 44 DC electrodes. We instead use two voltage sets (array of DC voltages for individual electrodes) which were calculated for generating an electric field of 100 V/m in the x (horizontal) and y (vertical) directions. Electrode voltages of \(-1\) to \(+1\) V for the x direction and \(-2\) to \(+2\) V for the y direction are needed to create electric field of 100 V/m at the location of the ion. These sets of voltages are multiplied by arbitrary weights \(w_x\) and \(w_y\) to compensate arbitrary fields in the RF trapping plane. In practice this process has imperfections and cannot fully compensate for the stray electric fields17. Instead, individual electrodes need to be tuned independently for optimal compensation. This optimum compensation is position dependent and there might be multiple solutions for a multi-electrode trap.

Figure 2
figure 2

(a) Ideal micromotion broadening of the transition fluorescence in a two-level system as a function of the micromotion amplitude [\(\beta \)] and laser detuning (\(\delta \)) in the low intensity limit (Eq. 1). For our 370 nm transition the fluorescence rate is proportional to the \(^2\)P\(_{1/2}\) excited state population. The laser frequency detuning \(\delta =-7.8\) MHz, the natural linewidth \(\gamma = 20\) MHz and the RF trap drive frequency \(\Omega =25.5\) MHz. Heating/cooling dynamics are neglected. Our optimizations occur in the low beta (\(<1\)) limit. (b) The photon count improvement using ADAM starting from manually optimized voltage set weights. This graph demonstrates a \(78\pm 1\%\) improvement in ion fluorescence. The error bars are a combination of the readout error of the PMT and peak to peak variations in the photon count whilst not optimizing. The background photon count here is 1184 ± 34 counts/s.

Two other DC voltage sets are used and their relative weights tuned: a harmonic voltage set, and RF plane trap axis rotation voltage set. The former creates a harmonic potential to trap the ion in different locations along the chip length, while the latter rotates the trap’s secular confinement axes to lift the degeneracy and improve cooling26.

We infer the magnitude of the stray electric field from the fluorescence rate of the ion when the cooling laser is red-detuned near half its natural linewidth for optimal cooling. When driving an ideal cold two-level atom with this laser, the fluorescence is proportional to the population of excited state, \(P_e\), that can be calculated from the optical Bloch equation27. The relationship between \(P_e\) and the strength of the stray electric field is given by15:

$$\begin{aligned} P_e(\beta ) = C \sum _{m=-\infty }^{\infty }{\frac{J_m^2(\beta )}{ \left( \frac{\delta _L}{\gamma }+m\frac{\Omega }{\gamma }\right) ^2 + \frac{1}{4} }} \end{aligned}$$
(1)

where \(J_m\) is the mth order Bessel function of the first kind, \(\delta _L=\omega _{atom}-\omega _{laser}\) is the laser frequency detuning, \(\gamma \) is the natural linewidth and \(\Omega \) is the RF trap frequency. The amount of micromotion is embedded in the dimensionless parameter \(\beta \) which accounts for the dimensionless measure of the ion’s coherently driven motion from the stray electric fields and RF phase imbalances (AC micromotion)15. C depends on the strength of the coupling between the levels that is a constant here since we keep laser intensity and direction fixed. Figure 2a shows a graph of \(P_e(\beta )/P_e(0)\) as a function of \(\beta \). The graph shows that at our detuning (\(-7.8\) MHz) the population decreases monotonically as \(\beta \) increases if \(\beta \) is less than 2.5. For larger \(\beta \) micromotion induced local maxima arise that prevent inferring the magnitude of micromotion from fluorescence rate. Since our operating regime is below this threshold, we can use the change in fluorescence rate to detect the change in magnitude of the stray electric field.

Results

A gradient descent algorithm (ADAM) and a deep learning network (MLOOP) were tested for compensating stray fields in different working regimes. The source code used for the experiments is available in28. The software controlled the voltages using the PXI-6713 DAQ and read the fluorescence counts from a photo-mutliplier-tube (PMT) through a time tagging counter (IDQ id800). All software was written in python and interfaced with the DAQ hardware using the library NI-DAQmx Python. A total of 44 DC electrodes and the horizontal position of the cooling laser were tuned by the program, resulting in a total of 45 input parameters.

Figure 3
figure 3

Voltage deviation from the original starting point during optimization with ADAM. (a) uncharged trap (“Gradient descent optimizer” section). (b) During UV charging (“Testing under poor trap conditions”). Top graphs show odd electrode numbers corresponding to top DC electrodes in Fig. 1b and the bottom graphs show the even electrode numbers. The values were determined by subtracting the voltage at each iteration by the starting voltage \(\Delta V = V_n - V_0\). Changes can be seen in almost all the electrodes of the trap.

Figure 4
figure 4

(a) MLOOP deep learning network. Differential Evolution explores the input space (blue points) and the neural network creates a model of the data and predicts an optimum (red points). Maximum photon count of the neural network points is 96 ± 1% higher than manual optimization. Differential Evolution continues to explore the input space and has varied photon counts. The beginning point for the process (found by manually adjusting the 4 voltage set weights) was at 33700 counts/s and the highest photon count found by the neural network was at 66200 counts/s. (b) and (c) Fluorescence versus laser frequency detuning from the resonance for inital setting and after different optimizations. It can be seen from that the experimental values are very close to the theoretical Lorentzian fit29,30,31. This shows the heating is low before and after optimization and therefore the change in fluorescence can be used to infer the change in heating. Deviation from the theory near the resonance shown in (b) is a sign of small heating instability.

Gradient descent optimizer

The first compensation test was performed by ADAM gradient descent algorithm. This is a first order optimizer that uses the biased first and second order moments of the gradient to update the inputs of an objective function, and was chosen for its fast convergence, versatility in multiple dimensions and tolerance to noise23. Our goal was to maximize the fluorescence of the ion which was described by a function \(f(\vec {\alpha }{\,})\), where \(\vec {\alpha }{\,} =(\alpha _1, \alpha _2, \alpha _3, \ldots \alpha _{45})\) represents the array of parameters to be optimized. To find the optimal \(\vec {\alpha }{\,}\), the algorithm needs to know the values of the partial derivatives for all input parameters. Because we do not have an analytic expression for \(f(\vec {\alpha }{\,})\), the values of its derivatives were estimated from experimental measurements by sequentially changing each input \(\alpha _{i}\), and reading the associated change in fluorescence f. This data were used as inputs to ADAM for finding the optimal \(\vec {\alpha }{\,}\) which maximized f.

Before running the automated compensation, we manually adjusted the 4 weights of the voltage sets used for compensation described in the previous section. We also tried to run ADAM to optimize these 4 parameters but the increase in fluorescence was limited to 6%. After manual compensation, we ran ADAM on all 45 inputs with the algorithm parameters given in the source code28. Each iteration took 12 s, where 9.8 s were the photon readout (0.1 s\(\times \)2 readouts per parameter plus 2\(\times \)0.1 s readouts at the beginning and end of the iteration), and the rest of the time was the gradient computation. If the photon count reduced by more than 40% of its initial value, the algorithm terminated and applied the previously found optimum. This acted as the safety net for the program, ensuring the ion was not lost while optimizing the 45 inputs. We need this safety net because if the ion is heated past the capture range for the used cooling detuning, it will be ejected from the trap. In our implementation of the algorithm we removed the reduction in the step size of the optimization algorithm as iterations progressed. This step reduction, which is present in the standard version of ADAM, is not ideal when stray fields change with time since the optimal values of the voltages also drift in time. The removal caused some fluctuations in the photon readout near the optimal settings. Adding to these fluctuations, other sources of noise, such as wavemeter laser locking32, and mechanical drift in the trap environment, resulted in daily photon count variations of around 5%. Fluctuation in laser power was not a concern here since the power of the cooling laser was stabilized. Despite these fluctuations, and the fact that stray fields change every day, the algorithm demonstrated an increase in fluorescence collection up to 78 ± 1% (Fig. 2b) when starting from a manually optimized configuration in less than 10 iterations, or 120 s.

The ADAM algorithm was fast and reliable (the ion was never lost during optimization), even in extremely volatile conditions like having time-dependent charging and stray electric field buildup. Figure 3a shows a colourmap of the voltages and laser position adjustments, where most of the improvement came from adding the same voltage to all DC electrodes indicating that the ion was not at optimal height. The volatility of the ion-trap environment causes the fluorescence rate to oscillate around the optimal point. To get the best value, instead of using the values of the final iteration, the software saved all voltage combinations and applied the setting with the highest photon count after all iterations were finished. Despite picking the best value it can be seen in Fig. 2b that the fluorescence for some iterations during the optimization are higher than the final point selected by the software. This is because when the settings are changed, the ion fluorescence rate may transiently increase and subsequently stabilize to a slightly lower value for the same voltage settings.

Deep learning network for the ion trap

The second algorithm tested was a deep learning network using the python based optimization and experimental control package MLOOP20. MLOOP uses Differential Evolution33 for exploring and sampling data. The blue points in Fig. 4a corresponds to these samples and it can be seen that even at the end of optimization, they can have non-optimum fluorescence rates. MLOOP also trains a neural network using the data collected by Differential Evolution and creates an approximate model of the experimental system. It then uses this model to predict an optimum point. The red points in Fig. 4a shows the optimum points predicted by the neural network model. It can be seen that this section starts later than Differential Evolution, as it requires some data for initial neural network training, and gradually finds the optimum and stays near it. For training of the neural network, the inbuilt ADAM optimizer is used to minimize the cost function. The sampling in MLOOP does not require a gradient calculation which greatly improves the sampling time. Even though the sampling is fast, training the network to find an optimal point requires a minimum of 100 samples and that makes MLOOP slower than ADAM. With our settings for MLOOP, each iteration took 0.7 s on average and therefore 700 s was needed to take 1000 samples shown in Fig. 4a.

In our test the neural network in MLOOP had 5 layers with 45 nodes each, all with Gaussian error correction. The neural network structure (number of layers and cells) was manually optimized and tested on a 45-dimensional positive definite quadratic function before being used for the experiment. Once the ion was trapped, positioned above the integrated mirror22, and photon counts were read, the program started sampling 100 different voltage combinations around its initial point. Then, the network started training on the initial data and making predictions for the voltages that maximise fluorescence. Since the ion trap setup is very sensitive to changes in the electric field, the voltages were set to move a maximum of 1% of their previous value in each iteration to reduce the chance of losing the ion. As a step size value could not be explicitly defined, this percentage was chosen to make the changes similar to the step size used for ADAM.

A small percentage of our initial trials with the maximum change of a few percent (instead of 1%) led to an unstable ion during the parameter search sequence. This is because MLOOP is a global optimizer and can set the voltages to values far from the stable starting point. Since the ion trap is a complicated system that can only be modelled for a specific range of configurations, moving away from these settings can lead to unpredictable and usually unstable behavior. MLOOP also has an in-built mechanism that handles function noise using a predefined expected uncertainty. We set this uncertainty to the peak-to-peak noise of the photon readout when no optimization was running.

Since MLOOP is a global optimizer it was able to find optimum points different from the points found by ADAM. For trials where low numbers of initial training data points were used, these configurations proved to be unstable and in most cases resulted in the loss of the ion. Unstable states were also observed occasionally if the optimizer was run for too long. With moderate-size training sets, MLOOP was able to find voltage settings with fluorescence rates similar or higher than optimum points found by ADAM as shown in Fig. 4a. Considering the long duration of the MLOOP iteration sequence and the possibility of finding unstable settings in volatile conditions, the test of optimization with induced changing stray fields (“Testing under poor trap conditions”) was only performed with the ADAM optimizer as the gradient based search method proved to be more robust against fluctuations in the ion environment.

Table 1 Saturation power (\(P_{sat}\)), detection efficiency (\(\eta \)) and average background count rate (Bkg) before and after optimization with different methods.

To test the effectiveness of the protocols, the saturation power, \(P_{sat}\), was measured before and after the optimization process. The \(P_{sat}\) is the laser power at which the fluorescence rate of a two-level system is half the fluorescence at infinite laser power. We also measured the overall detection efficiency \(\eta \), the fraction of emitted photons which resulted in detection events. Table 1 shows \(P_{sat}\) decreased (ion photon absorption was improved) using both ADAM and MLOOP. The detection efficiency was approximately the same for all runs as expected.

Another test was done by measuring fluorescence versus laser detuning before and after optimization. Figure 4b shows that the measured values follows the expected Lorentzian profile29,30,31 and associated linewidth before and after optimization. This indicates that the initial micromotion magnitude \(\beta \) was sufficiently small for fluorescence to be a good optimization proxy. Clear increase in florescence can be seen after optimizing 44 electrodes individually both with ADAM and MLOOP. The fit residual curve (difference between the experimental values and the theoretical fit) shows that optimizing individual electrodes, resulted in slight increase in heating instability near the resonance.

Testing under poor trap conditions

To test the live performance of the optimization protocol in a non-ideal situation, we deliberately charged the trap by shining 369.5 nm UV laser light onto the chip for 70 min. The power of the laser was \(200\pm 15\mu W\) and the Gaussian diameter of the focus was \(120\pm 10\mu m\). This process ejects electrons due to the photo-electric effect34 and produces irregular and potentially unpredictable slow time varying electric fields within the trap. The process charged the trap significantly and made a noticeable reduction to the photon count. The ADAM algorithm was then tested both during charging and after charging was stopped. In both cases an improvement of fluorescence rate was observed.

The first experiment was performed to test the optimizing process after charging. In this test, starting with the optimal manual setting, ADAM individual electrode optimizer was able to obtain 27% improvement in the fluorescence rate (blue points on the left side of Fig. 5a). Then charging was induced onto the trap for 70 min and a clear decrease in photon count was seen that went even lower than the initial value (red points in Fig. 5a). At this point charging was stopped and ADAM was run again and fluorescence rate returned back to the previous optimum, within the error, in approximately 12 min. During the second optimization, the fluorescence goes higher than the stable final value for some iterations before the final. This is because of the same effect explained in “Gradient descent optimizer” section that the fluorescence might spike right after a change but go down slightly after stabilizing. Looking at the changes of individual electrodes, shown in Fig. 3b, we see that the main electrodes adjusted were those around the ion and some throughout the trap. The change in the laser horizontal position was negligible.

Another experiment was done by running ADAM during continuous charging for real-time compensation. Since we induce charging via laser scattering from the trap, the collected photons are both from the ion and the scattered laser and fluctuations in the intensity of scattered light confuses the optimizer. Despite that the optimizer did not lose the ion nor needed to abort the process. Figure 5b shows that the fluorescence rate, even after a 70-min charging session, remained near the optimum value. After stopping the charging, the ion remained trapped for more than 8 h and was intentionally removed from the trap after this time.

Figure 5
figure 5

(a) Real time compensation with ADAM of laser charging induced stray electric field. The ion was optimized using ADAM (left blue points) then the photon count was noted whilst charging for 70 min (red points) then re-optimized (right blue points). Initial improvement from manually optimized settings was 27%. The second optimization improved the fluorescence by 58% from the charged conditions and returned it back to the optimum value of the first optimization within the error. (b) The trap was charged by hitting a UV laser to destabilize the ion and individual electrodes optimized using ADAM simultaneously for 70 min. The photon count fluctuates as a result of combination of fluctuations of power of the cooling laser power, algorithm search and charging irregularities. The optimizer keeps the fluorescence at the photon count similar to the case of optimizing after the charging is stopped (third section of (a)).

Conclusion

Comparing the results of the gradient descent method and MLOOP shows that ADAM, the local optimizer, was a better performer in volatile conditions. This is because unlike MLOOP, ADAM does not need any training and can react faster to changes. MLOOP as a global optimizer was able to find settings with higher fluorescence but occasionally optimums were unstable if the defined parameter search range for the settings were large or if the machine learner ran for too long. The main drawback of MLOOP was that it was much slower than ADAM. In both cases photon collection times were the limiting factor.

Optimizing the individual electrodes improved the fluorescence by 78% for ADAM and 96% for MLOOP. ADAM showed its reliability in the charging test, returning the ion to the optimal fluorescence in 12 min after 70 min of purposely charging the trap with a UV laser. Improvement amounts depended greatly on the overall stability of the cooling laser and efficiency of the photon counting system.

To improve the speed of the gradient based optimizer, shorter readout times can be used although this increases variability in the value of the photon count. It is also possible to try local optimizers like SPSA35 that approximate the gradient using only 2 readouts instead of 90. This improves the time needed for each iteration but because using this approximate gradient reduces the improvement in each iteration, the overall speed comparison to reach the same optimum can only be made when both are tried in practice. One possible problem with SPSA is that it cannot handle noise like ADAM and multiple readouts and averaging are needed in noisy conditions. If high amount of averaging is required, the algorithm may become very slow.