## Abstract

Ultrafast electron diffraction using MeV energy beams(MeV-UED) has enabled unprecedented scientific opportunities in the study of ultrafast structural dynamics in a variety of gas, liquid and solid state systems. Broad scientific applications usually pose different requirements for electron probe properties. Due to the complex, nonlinear and correlated nature of accelerator systems, electron beam property optimization is a time-taking process and often relies on extensive hand-tuning by experienced human operators. Algorithm based efficient online tuning strategies are highly desired. Here, we demonstrate multi-objective Bayesian active learning for speeding up online beam tuning at the SLAC MeV-UED facility. The multi-objective Bayesian optimization algorithm was used for efficiently searching the parameter space and mapping out the Pareto Fronts which give the trade-offs between key beam properties. Such scheme enables an unprecedented overview of the global behavior of the experimental system and takes a significantly smaller number of measurements compared with traditional methods such as a grid scan. This methodology can be applied in other experimental scenarios that require simultaneously optimizing multiple objectives by explorations in high dimensional, nonlinear and correlated systems.

### Similar content being viewed by others

## Introduction

Ultrafast electron diffraction using MeV energy beams (MeV-UED) has led to a new paradigm in ultrafast electron scattering^{1,2}. MeV electron probes lead to atomic spatial resolution together with sub-picosecond temporal resolution^{3}. Furthermore, MeV electrons can provide pure kinetic scattering signals for samples with a given thickness, which makes it possible to achieve quantitatively understood observables to validate physical modeling. Recently, MeV-UED techniques have reached a high level of maturity with several beamlines operating as user facilities. Rapid advancements in MeV fs electron probes, sample delivery and manipulation techniques, high efficiency electron detection and novel data analysis techniques^{3,4,5,6,7} have enabled unprecedented scientific opportunities in ultrafast structural dynamics, including observations of bond dissociation, coherent ground state wavepacket motion after electrocyclic ring-opening^{8}, simultaneous observation of electronic and nuclear structure changes in a molecule undergoing non-adiabatic dynamics^{9}, hydrogen bond strengthening in liquid water^{10}, and phase switches of materials with exotic functional properties^{11,12}.

Broad scientific applications usually pose different requirements for electron beam properties, such as temporal length, spot size and transverse momentum resolution in reciprocal space (q-resolution). Measuring these beam properties as a function of the input parameters using limited and time-consuming diagnostics becomes a necessary part of planning and optimization of experiments. Due to the complex, nonlinear and correlated nature of accelerator systems, electron beam property optimization often relies on extensive and time-taking hand-tuning by experienced human operators. This comes at the cost of reducing the beam time available for scientific experiments. Uniformly spaced grid-like parameter scans are routinely conducted in one or two dimensions for sampling the parameter space and obtaining an overview of the beam property behaviors. However, grid scans suffer from poor scaling as the number of sampling points increases exponentially with input parameter dimensions which may be impractical during a limited beam time. Algorithm based efficient online tuning strategies are highly desired as they hold the potential to reducing the setup time, allowing human experts to focus on more challenging high-level scientific problems.

Recently, Artificial intelligence and Machine learning (AI/ML) have reached sufficient maturity for applications in real-world tasks such as autonomous driving, natural language processing^{13}, protein folding prediction^{14} and fusion reactor control^{15}. Speeding up and aiding online optimizations of complex particle accelerators is one of the key areas where AI/ML can make substantial contributions^{16,17,18,19,20,21,22,23}. Bayesian Optimization (BO) with Gaussian processes(GPs)^{24,25}, often referred to as Bayesian active learning^{22,26,27}, represents a class of ML alogrithms in which a probabilistic model and its uncertainty at each measurement step are used to select the optimal next observation point. Recently, BO based optimization methods have been successfully applied for online tuning at large-scale accelerator systems such as LCLS^{19}, with a lower number of observations needed than Gradient-based or Nelder-Mead simplex algorithms. These algorithms are designed to optimize a single beam property (an “Objective"). In practice, beam tuning often seeks to simultaneously optimize multiple Objectives. This pose a significant challenge as individual beam properties may not be independent optimizables due to complex inter-correlations between them. For example, in UED it is difficult to simultaneously minimize the electron pulse length and spot size/q-resolution due to Space Charge (SC) forces. The goal of multi-objective optimization is to determine the Pareto Front (PF) which represents the system performance limit and gives the trade-offs between key objectives. In this domain, some of the most popular methods are the evolutionary algorithms for their simplicity in implementation and broad applicability^{28}. However, the evolutionary algorithms are extremely data inefficient as they require evaluation of large number of candidate solutions to converge to PF. As a result, the evolutionary algorithms are nearly impossible to use for online accelerator tunings^{23}. To this end, the Multi-Objective Bayesian Optimization (MOBO) scheme^{20,29} was recently introduced. This method uses a set of GP surrogate models, along with a multi-objective HyperVolume (HV) improvement acquisition function, to reduce the number of observations needed. This method can converge by at least an order of magnitude more quickly than evolutionary algorithms, such as Multi-Objective Genetic Optimization (MOGA), and is thus a critical step toward online multi-objective optimization on real accelerator systems.

In this work, we demonstrate Multi-Objective Bayesian Active Learning for speeding up online beam tuning on an MeV-UED facility at SLAC National Accelerator Laboratory. The MOBO algorithm was used for searching the parameter space efficiently in a serialized manner, and actively learning the PF giving trade-offs of key beam properties (electron pulse length, q-resolution and spot size at sample) that have a direct impact on the outcome and quality of scientific user experiments. The achieved performance was comparable with that obtained by experienced human operators. The MOBO scheme enables an unprecedented overview in the multi-dimensional parameter space with a significantly smaller number of measurements required compared with traditional exploration methods such as a Grid Search (GS) scan. While our focus here is the application of MOBO in beam tuning for MeV-UED, the explained methodology can be applied in other experimental scenarios involving high dimensional, nonlinear and correlated systems.

## Results

We conducted experiments at the SLAC MeV-UED facility to demonstrate the feasibility of applying MOBO for online exploration and optimizations of electron beam properties in a multi-dimensional parameter space. The experimental setup and MOBO workflow are illustrated in Fig. 1. The MeV-UED beamline generates 4.2 MeV energy electron pulses using an S-band photoinjector triggered by 60 fs FWHM laser pulses. The electron pulse length downstream is sensitive to the launch phase of the electrons relative to the photoinjector RF field (referred to as the “gun phase" and characterized by the parameter *ϕ*). The electron pulses are then focused using two magnetic solenoids. One is referred to as the “gun solenoid" and characterized by the parameter *B*_{1}, the other is referred to as the “micro-focus solenoid" and characterized by the parameter *B*_{2}. The electrons are delivered to the Interaction Point (IP) for performing pump-probe electron diffraction experiments. The electron diffraction patterns are then recorded and used to extract fs time scale structural dynamics signals. Here, three electron beam properties are optimized. The electron pulse length (*σ*_{t}) at IP sets the smallest temporal resolution that can be achieved for resolving fast dynamical processes. The spot size (*σ*_{x}) at IP sets the transverse probing area and the *q*-resolution (*σ*_{q}) on the diffraction detector represents the transverse momentum resolution in the reciprocal space. Due to space charge forces, *σ*_{t}, *σ*_{x} and *σ*_{q} are competing properties that can not be simultaneously minimized. We used MOBO to explored the response of *σ*_{t}, *σ*_{x} and *σ*_{q} to the input beamline parameters [*ϕ*, *B*_{1}, *B*_{2}] and obtained the PFs giving trade-offs between them. In each iteration, MOBO evaluates a candidate point in the parameter space and updates the GP surrogate model with the newly acquired data. The Expected Hypervolume Improvement (EHVI)^{30} acquisition function is then used to calculate the optimal next observation point (see methods). The process is performed iteratively and ultimately providing an approximation of the best achievable PF.

We first conducted *σ*_{t} vs *σ*_{q} optimizations by varying gun phase (*ϕ*) and solenoid strengths (*B*_{1} and *B*_{2}). The initial pulse charge was set to be 10 fC. The gun amplitude was 90 MV/m. A 200 *μ*m collimator was used as an emittance filter located after the gun solenoid. We initialized the exploration with 10 random sampling points in the chosen subdomain of input parameter space (Table 1). Fig. 2 illustrates the exploration result after 121 measurements. For each measurement, three observations of *σ*_{t} and *σ*_{q} were recorded for averaging the fluctuations due to system jitters. These measurements are then used to train GP models of *σ*_{t} and *σ*_{q} responses to the input parameter *ϕ*, *B*_{1} and *B*_{2}. A Matérn kernel with *ν* = 5/2 was used and hyperparameter training was done by maximizing the log marginal likelihood of the GP model with the gradient based Adam optimization algorithm. Measurements of *σ*_{t} projected to the *ϕ* - *B*_{2} subspace, along with the posterior mean predicted by the GP model, are plotted in Fig. 2a. Estimated length scales from the GP models are shown in Table 1. The \({{{{{{{\mathcal{L}}}}}}}}\)(*σ*_{t}) for *ϕ*, *B*_{1} and *B*_{2} are at the same scale, implying that *σ*_{t} depends on all three input parameters. This is consistent with previous observations as *σ*_{t} depends on both the temporal-energy chirp at gun exit (changed by *ϕ*) and SC induced temporal broadening during beam transport (changed by *B*_{1} and *B*_{2}). Fig. 2b, c illustrates the *σ*_{t} and *σ*_{q} responses projected to the *B*_{1} - *B*_{2} subspace. The \({{{{{{{\mathcal{L}}}}}}}}\)(*σ*_{q}) for *B*_{1} is significantly shorter than that for *B*_{2}, indicating that *σ*_{q} varies faster with *B*_{1}. Again, this is consistent with previous observations that q-resolution mainly depends on the transmitted beam emittance and gun solenoid strength. On the other hand, The \({{{{{{{\mathcal{L}}}}}}}}\)(*σ*_{q}) for *ϕ* is significantly larger than the \({{{{{{{\mathcal{L}}}}}}}}\)(*σ*_{q}) for *B*_{1} and *B*_{2}, indicating that the q-resolution is weakly correlated to gun phase. The GP predicted PF curve (denoted with green squares) is plotted in Fig. 2b, c. The GP predicted PF curve connects the GP predicted optimal set points for lowest *σ*_{t} at [*B*_{1} = 0.131, *B*_{2} = 0.240] and lowest *σ*_{q} at [*B*_{1} = 0.123, *B*_{2} = 0.217]. Here, we define the empirical non-dominated data points as the approximate PF. The approximate PF points are plotted with green stars, the difference between approximate PF and GP predicted PF indicates that further exploration is needed to obtain the ultimate PF, and the lighter colored regions (both in *σ*_{t} and *σ*_{q} plots) are particularly valuable and remain to be explored. Fig. 2d, e show the calculated EHVI acquisition function projected onto the *ϕ* - *B*_{2} and *B*_{1} - *B*_{2} space, the most valuable next observation point was found to be at [*ϕ* = 46.0, *B*_{1} = 0.125, *B*_{2} = 0.237]. This is consistent with the expectation that the EHVI should suggest exploring points on the predicted PF curve to efficiently improve the hypervolume. Here, the advantage of the MOBO scheme can be clearly seen. It strategically proposes the next observation point which optimally increase the Pareto Frontier HV, and is thus more data efficient than a broad, undirected search for the PF. Fig. 2f shows the measured data points in the objective space. The approximate PF shows clear trade-off between *σ*_{t} and *σ*_{q}. The smallest *σ*_{q} was found to be 0.162 Å^{−1} at *σ*_{t} = 108 fs, while smallest *σ*_{t} = 67 fs can be achieved with *σ*_{q} = 0.217 Å^{−1}.

We then used MOBO to conduct spot size (*σ*_{x}) vs *q*-resolution (*σ*_{q}) explorations by varying *B*_{1} and *B*_{2} at 10 fC, 50 fC and 100 fC initial pulse charges, the input parameter ranges used are shown in Supplementary Table 1. For each run, 10 random sampling points were used to initialize the exploration and in total 150 measurements were taken. Figure 3a illustrates the exploration results, all measured data points are plotted in the *σ*_{x} - *σ*_{q} space. The approximate PFs clearly shows trade-offs between *σ*_{x} and *σ*_{q} at different initial pulse charges. We observe that the approximate PF obtained at lower pulse charge (10 fC) shows significant improvement compared with higher pulse charge cases (50 fC and 100 fC). This observation is consistent with previous observations that smaller *σ*_{x} or *σ*_{q} can be achieved by lowering initial pulse charge, as spot size and q-resolution are limited by SC induced emittance growth at 4.2 MeV beam energy. At 10 fC initial pulse charge, the smallest *σ*_{x} was found to be 45 *μ*m at *σ*_{q} = 0.351 Å^{−1}, while smallest *σ*_{q} = 0.162 Å^{−1} can be achieved with *σ*_{x} = 100 *μ*m. We also observe that *σ*_{q} flattens with *σ*_{x} > 100 *μ*m, implying that other source of broadening on the diffraction detector, such as the detector Point Spread Function (PSF) are the primary limitation for further improvement in the *q*-resolution. We ran 9 independent optimizations for the 10 fC initial pulse charge case, each with a different set of 10 randomly sampled initial points. After each measurement, the hypervolume of the approximate PF point set was calculated in normalized objective space. Fig. 3b shows the convergence plot of approximate PF hypervolume versus number of iterations. One can clearly see improvement of hypervolume across the optimization process. The averaged hypervolume (blue) reaches 95% of its maximum within 30 measurements. We conducted a simulated Grid Search (GS) with step size equal to 10% of the parameter space subdomain using the interpolated dataset. The hypervolume obtained using GS was 62% of that obtained using MOBO after 30 measurements and 91% after 100 measurements. A direct comparison between MOBO and GS scheme is plotted in Fig. 3b, the advantage of MOBO to improve both search efficiency and maximum achievable hypervolume can be clearly seen.

## Discussion

Here we have experimentally demonstrated MOBO scheme to autonomously and efficiently optimize a subset of critical electron beam properties for an MeV-UED facility. The MOBO algorithm was used for sampling the multi-dimensional parameter space efficiently with little prior knowledge of the experimental system, which makes it practical for use in online beam tuning. By proposing solutions which optimally increase the hypervolume at each measurement step, the MOBO algorithm was capable to active-learn the PFs which give the trade-offs between key beam properties of interest for scientific experiments. The PF offers an unprecedented overview of the machine’s performance limitations and can greatly assist human scientists in rapid decision-making, thereby maximizing the scientific output within the very limited beam time. The MOBO scheme was capable to achieve system performance comparable with that obtained by experienced operators and requires significantly fewer measurements compared with traditional exploration methods such as a GS scan. It is anticipated that this advancement will have a direct and substantial impact on the scientific experiments conducted at the SLAC MeV-UED facility, particularly in the studies which require simultaneously optimizing electron pulse length and q-resolution/spot size, such as the studies of charge density wave orders^{31}, ultrafast energy transfer in small-scale, low-dimensional systems^{32}, and other complex phenomena such as unconventional superconductivity in twisted-angle graphene super lattices^{33}. While this work focuses on the application of the MOBO scheme in electron beam tuning for MeV-UED, this algorithm is flexible, efficient and can be used to replace GS in any experimental scenarios that require online explorations in a multi-dimensional, nonlinear parameter space while simultaneously optimizing multiple objectives, and we expect it to have broad impact across researches in different diciplines (physics, chemistry and biology) at large scale, complex scientific user facilities, such as free electron lasers, synchrotron radiation light sources and neutron sources.

While our demonstration of MOBO for online tuning was conducted in a relatively low-dimensional input parameter space, it is expected that MOBO can be scaled up to higher dimensional parameter space^{34}. During our experiment, the extra computation time associated with GP fitting and EHVI acquisition function optimization is small relative to the reduction in electron beam property evaluation time associated with faster convergence of HV (as shown in Supplementary Fig. 2). One major challenge is the rapidly increasing computational cost when the number of data points becomes large, as is often the case when conducting explorations in high dimensional parameter spaces. One solution is to use Neural Network (NN) surrogate models as the prior mean to improve the BO efficiency, even with erroneous predictions^{35}. Work in the multi-objective Bayesian optimization field has produced efficient methods for HV and acquisition function calculations^{36}. Finally, if the evaluations can be conducted in parallel, as in simulations or under the multi-beamline scenario, recently developed parallelized acquisition functions, such as q-Expected Hypervolume Improvement (q-EHVI)^{37} can be used to significantly reduce overall optimization time while maintaining the sampling efficiency advantages of EHVI.

## Methods

### Gaussian process modeling

Nonparametric GP surrogate models were used to predict the value of an objective function *f*(**x**) using Bayesian statistics^{24}. The GP model includes a distribution of possible functions \(y({{{{{{{\bf{x}}}}}}}}) \sim {{{{{{{\mathcal{GP}}}}}}}}(\mu ({{{{{{{\bf{x}}}}}}}}),k({{{{{{{\bf{x}}}}}}}},{{{{{{{{\bf{x}}}}}}}}}^{{\prime} }))\). With *μ*(**x**) presenting the predicted mean of objective function *y*(**x**), \(k({{{{{{{\bf{x}}}}}}}},{{{{{{{{\bf{x}}}}}}}}}^{{\prime} })\) is the kernel function based on the objective function behavior^{20}. Given N previous measurements \({{{{{{{\mathcal{D}}}}}}}}=\{({x}_{1},{y}_{1}),({x}_{2},{y}_{2}),...,({x}_{N},{y}_{N})\}\), the predictive probability distribution of the function value is given by a normal distribution:

where

where \({{{{{{{\bf{y}}}}}}}}={[{y}_{1},{y}_{2},\ldots,{y}_{N}]}^{T}\) and *σ*_{n} represents the noise hyperparameter. In this work, a Matérn kernel function was used for GP modeling:

With \(\parallel {{{{{{{\bf{x}}}}}}}}-{{{{{{{{\bf{x}}}}}}}}}^{{\prime} }\parallel\) reprents the Euclidean distance between inputs, Γ is the gamma function, and *K*_{ν} is the modified Bessel function. *ν* = 2.5 was used in this work for modeling functions in the absence of prior information. The hyperparameter \({{{{{{{\mathcal{L}}}}}}}}\) determines the characteristic length-scale of the kernel, where small and large values correspond to rapidly and slowly varying functional behavior respectively.

### Multi-objective Bayesian optimization

The goal of multi-objective optimization is to search the input parameter space of the experimental system and to optimize the vector objective function **y**(**x**) = {*y*_{1}(**x**), *y*_{2}(**x**), . . . , *y*_{M}(**x**)}. Usually, there is no best single solution **x**^{*} that can simultaneously optimize all objectives. Instead, multi-objective optimization algorithms attempt to find a set of points, known as the PF that optimally balances the trade-offs between the competing objectives. The Pareto Frontier set \({{{{{{{\mathcal{P}}}}}}}}\) is defined as the set of non-dominated points in objective space. For the minimization case, an objective vector **y**(**x**) dominates another vector \({{{{{{{\bf{y}}}}}}}}({{{{{{{{\bf{x}}}}}}}}}^{{\prime} })\) if \({y}_{m}({{{{{{{\bf{x}}}}}}}})\le {y}_{m}({{{{{{{{\bf{x}}}}}}}}}^{{\prime} })\) for all *m* = 1, . . . , *M* and there exists at least one *n* such that \({y}_{n}({{{{{{{\bf{x}}}}}}}})\, < \, {y}_{n}({{{{{{{{\bf{x}}}}}}}}}^{{\prime} })\). HV is an often used metric to evaluate the quality of a PF. The HV is defined as the M-dimensional Lebsegue measure of the subspace dominated by \({{{{{{{\mathcal{P}}}}}}}}\) and bounded below by a reference point **r**^{30}:

Here *λ*_{M} is the Lebesgue measure on \({{\mathbb{R}}}^{M}\). A larger HV corresponds to a better solution set \({{{{{{{\mathcal{P}}}}}}}}\). The MOBO technique aims to maximize the HV through the following process. Given a set of *N* observations:*D*_{N} = {(**x**_{1}, **y**_{1}), (**x**_{2}, **y**_{2}), . . . , (**x**_{N}, **y**_{N})}, each objective is modeled as an independent GP surrogate model:

The second part of MOBO is to construct an acquisition function to propose points which are likely to maximally increase the Pareto Frontier HV. A commonly used acquisition function is the Expected Hypervolume Improvement (EHVI)^{30}, which calculates the average increase in hypervolume using the posterior probablity distribution of each objective function from the surrogate model. The EHVI acquisition function is defined as:

With \({H}_{I}({{{{{{{\mathcal{P}}}}}}}},{{{{{{{\bf{y}}}}}}}},{{{{{{{\bf{r}}}}}}}})\) being the hypervolume improvement from an observed point **y** in objective space, \({{{{{{{{\mathcal{N}}}}}}}}}_{\mu,\sigma }\) is the multivariate normal distribution function defined by the GP predicted mean *μ* and uncertainty *σ*. The hypervolume improvement is defined by the exclusive HV contribution to the current PF by adding **y** to the Pareto set. Combining the GP surrogate model and acquisition function, MOBO optimization can be performed. In each iteration, MOBO evaluates a candidate point in the parameter space and updates the GP surrogate model with the newly acquired data. The EHVI acquisition function is then used to calculate the next observation point in the parameters space. The process is performed iteratively and ultimately providing an approximation of the best achievable PF.

### Determination of temporal length

The measurements of temporal length of electron pulses at IP was accomplished through interaction with quasi-single-cycle THz pulses generated via optical rectification of 800 nm laser pulses in a LiNbO_{3} crystal^{38,39}. An Off-Axis Parabolic (OAP) mirror was used to focus the THz pulses into a high field enhancement parallel-plate waveguide (PPWG)^{40} streaking structure placed at IP. The THz pulses are then focused at the 70 μm slit in the PPWG and impart a transverse momentum kick to the electron beam which streaks the longitudinal profile onto the y axis on the downstream detector. The single-shot temporal resolution of THz streaking diagnostics was better than 1.5 fs with 3 *μ*J THz pulse energy.

### Determination of q-resolution

The q-resolution quantifies the extent to which tiny features can be resolved within a given diffraction pattern. The instrumental q-resolution can be expressed as^{41}:

*σ*_{ND} is the non-dispersive broadening which depends on transverse beam emittance and focusing solenoid settings. *σ*_{E} is the dispersive component which depends on beam energy spread Δ*E* and scattering wave vector *q*:

*E*_{k} and *γ* are the beam kinetic energy and Lorentz factor. During experiment, *σ*_{ND} was measured using the electron diffraction detector (phosphor screen coupled with an Electron-Multiplying CCD) located 3.2 m downstream the IP. Reciprocal space calibration was performed using a single crystal gold sample. Within the experimental parameter range, *σ*_{E} is calculated to be <0.011 *Å*^{−1}, thus the *q*-resolution is dominated by *σ*_{ND}.

## Data availability

The raw data generated in this study have been deposited in the Zenodo repository under accession code: https://doi.org/10.5281/zenodo.11095450^{42}.

## Code availability

This research used open source Python software libraries, including BoTorch^{43} and Xopt^{44}. The data analysis codes are available from the corresponding author upon request.

## References

Filippetto, D. et al. Ultrafast electron diffraction: visualizing dynamic states of matter.

*Rev. Mod. Phy.***94**, 045004 (2022).SLAC.

*Mega-electronvolt Ultrafast Electron Diffraction Instrument*. https://lcls.slac.stanford.edu/instruments/mev-ued (2024).Shen, X. et al. Femtosecond gas-phase mega-electron-volt ultrafast electron diffraction.

*Struct. Dyn.***6**, 054305 (2019).Kim, H. W. et al. Towards jitter-free ultrafast electron diffraction technology.

*Nat. Photonics***14**, 245–249 (2020).Qi, F. et al. Breaking 50 femtosecond resolution barrier in MeV ultrafast electron diffraction with a double bend achromat compressor.

*Phys. Rev. Lett.***124**, 134803 (2020).Ji, F. et al. Ultrafast relativistic electron nanoprobes.

*Comm. Phys.***2**, 54 (2019).Nunes, J. P. F. et al. Liquid-phase mega-electron-volt ultrafast electron diffraction.

*Struct. Dyn.***7**, 024301 (2020).Wolf, T. J. A. et al. The photochemical ring-opening of 1,3-cyclohexadiene imaged by ultrafast electron diffraction.

*Nat. Chem.***11**, 504 (2019).Yang, J. et al. Simultaneous observation of nuclear and electronic dynamics by ultrafast electron diffraction.

*Science***368**, 885–889 (2020).Yang, J. et al. Direct observation of ultrafast hydrogen bond strengthening in liquid water.

*Nature***596**, 531–535 (2021).Sie, E. J. et al. An ultrafast symmetry switch in a Weyl semimetal.

*Nature***565**, 61–66 (2019).Aditya Sood. Universal phase dynamics in VO2 switches revealed by ultrafast operando diffraction.

*Science***373**, 352–355 (2021).Vaswani, A. et al. Attention is all you need. In

*Proceedings of the 2017 International Conference on Neural Information Processing Systems (NeurIPS 2017).*6000–6010, https://doi.org/10.5555/3295222.3295349 (2017).Jumper, J. Highly accurate protein structure prediction with AlphaFold.

*Nature***596**, 583–589 (2021).Degrave, J. Magnetic control of tokamak plasmas through deep reinforcement learning.

*Nature***602**, 414–419 (2022).Edelen, A. et al. Machine learning for orders of magnitude speedup in multiobjective optimization of particle accelerator systems.

*Phys. Rev. Accel. Beams***23**, 044601 (2020).Sheinker, A. Demonstration of model-independent control of the longitudinal phase space of electron beams in the linac-coherent light source with femtosecond resolution.

*Phys. Rev. Lett***121**, 044801 (2018).Leemann, S. C. Demonstration of machine learning-based model-independent stabilization of source properties in synchrotron light sources.

*Phys. Rev. Lett.***123**, 194801 (2019).Duris, J. Bayesian optimization of a free-electron laser.

*Phys. Rev. Lett***124**, 124801 (2020).Roussel, R. Multiobjective Bayesian optimization for online accelerator tuning.

*Phys. Rev. Accel. Beams***24**, 062801 (2021).Hanuka, A. Physics model-informed Gaussian process for online optimization of particle accelerators.

*Phys. Rev. Accel. Beams***24**, 072802 (2021).Roussel, R. et al. Turn-key constrained parameter space exploration for particle accelerators using Bayesian active learning.

*Nat. Commun.***12**, 5621 (2021).Roussel, R. et al. Bayesian optimization algorithms for accelerator physics.

*arXiv:2312.05667*https://doi.org/10.48550/arXiv.2312.05667 (2023).Rasmussen, C. E. & Williams, K. I.

*Gaussian Processes for Machine Learning, Adaptive Computation and Machine Learning.*Ch. 2. 13, (MIT Press, Cambridge, MA, 2006).Emmerich, M., Yang, K., Deutz, A., Wang, H. & Fonseca, C. M. A multi-criteria generalization of Bayesian global optimization. In

*Advances in Stochastic and Deterministic Global Optimization, Springer Optimization and Its Applications*Vol. 106 (eds Pardalos, P., Zhigljavsky, A. & Žilinskas, J.). 229–242 (Springer, Cham, 2024).Kusne, A. G. et al. On-the-fly closed-loop materials discovery via Bayesian active learning.

*Nat. Commun.***11**, 5966 (2020).Abolhasani, M. & Kumacheva, E. The rise of self-driving labs in chemical and materials sciences.

*Nat. Synth***2**, 483–492 (2023).Maier, H. R. et al. Introductory overview: optimization using evolutionary algorithms and other metaheuristics.

*Environ. Model. Softw.***114**, 195 (2019).Jalas, S. et al. Tuning curves for a laser-plasma accelerator.

*Phys. Rev. Accel. Beams***26**, 071302 (2023).Yang, K., Emmerich, M., Deutz, A. & Bäck, T. Multi-objective Bayesian global optimization using expected hypervolume improvement gradient.

*Swarm Evol. Comput.***44**, 945 (2019).Kogar, A. et al. Light-induced charge density wave in LaTe3.

*Nat. Phys.***16**, 159–163 (2020).Sood, A. et al. Bidirectional phonon emission in two-dimensional heterostructures triggered by ultrafast charge transfer.

*Nat. Nanotechnol.***18**, 29–35 (2023).Cao, Y. et al. Unconventional superconductivity in magic-angle graphene superlattices.

*Nature***556**, 43–50 (2018).Daulton, S., Eriksson, D., Balandat, M. & Bakshy, E. Multi-Objective Bayesian Optimization over High-Dimensional Search Spaces,in

*Proceedings of the Thirty-Eighth Conference on Uncertainty in Artificial Intelligence,**PMLR*180, 507–517, https://proceedings.mlr.press/v180/daulton22a/daulton22a.pdf (2022).Xu, C., Roussel, R. & Edelen, A. Neural network prior mean for particle accelerator injector tuning. in

*Machine Learning And The Physical Sciences Workshop, NeurIPS 2022.*(2022).Yang, K. et al. Efficient computation of expected hypervolume improvement using box decomposition algorithms.

*J. Glob. Optim.***75**, 3–34 (2019).Daulton, S., Balandat, M. & Bakshy, E. Differentiable expected hypervolume improvement for parallel multi-objective Bayesian optimization. In

*Proceedings of the 2020 International Conference on Neural Information Processing Systems (NeurIPS 2020).*9851–9864,*arXiv*https://doi.org/10.48550/arXiv.2006.05078 (2020).Snively, E. C. et al. Femtosecond compression dynamics and timing jitter suppression in a THz-driven electron bunch compressor.

*Phys. Rev. Lett***124**, 054801 (2020).Li, R. et al. Terahertz-based subfemtosecond metrology of relativistic electron beams.

*Phys. Rev. Accel. Beams***22**, 012803 (2019).Othman, M. A. K. et al. Measurement of femtosecond dynamics of ultrafast electron beams through terahertz compression and time-stamping.

*Appl. Phys. Lett***122**, 141107 (2023).Williams, J. et al. Active control of bright electron beams with RF optics for femtosecond microscopy.

*Struct. Dyn.***4**, 044035 (2017).Ji, F. et al. Raw dataset for 'multi-objective Bayesian active learning for MeV-ultrafast electron diffraction’.

*Zenodo*https://doi.org/10.5281/zenodo.11095450 (2024).Balandat, M. et al. BoTorch: a framework for efficient Monte-Carlo Bayesian optimization. In

*Proceedings of the 2020 International Conference on Neural Information Processing Systems (NeurIPS 2020).*21524–21538 https://doi.org/10.48550/arXiv.1910.06403 (2020).Roussel, R. et al. Xopt: A simplified framework for optimization of accelerator problems using advanced algorithms. In

*Proceedings of 14th International Particle Accelerator Conference (IPAC 2023).*4796–4799 (JACoW Publishing, 2023).

## Acknowledgements

This work was supported by U.S. Department of Energy Office of Science, Office of Basic Energy Sciences (Contract No. DE-AC02-76SF00515 and DE-SC0021984). M. M. acknowledges the support from DOE Fusion Energy Science under FWP No. 100182. The SLAC MeV-UED program is supported by the U.S. Department of Energy Office of Science, Office of Basic Energy Science under FWP 10075, 100713 and 100940.

## Author information

### Authors and Affiliations

### Contributions

F.J., A.E. and R.J.E. designed the experiment. A.E., R.R., F.J. and C.M. wrote the software required to perform data collection and online multi-objective bayesian optimizations. F.J., A.E., X.S., S.M., S.W., D.L., M.M., A.R., M.A.K.O., P.K., X.W. and E.N. conducted the experiment. R.J.E. and M.M. provided guidance and oversights. F.J., R.J.E., X.S. and R.R. performed data analysis and wrote the manuscript. All authors contributed to the completion of the manuscript.

### Corresponding authors

## Ethics declarations

### Competing interests

The authors declare no competing interests.

## Peer review

### Peer review information

*Nature Communications* thanks Dalong Qi and Xiaogang Yang for their contribution to the peer review of this work. A peer review file is available.

## Additional information

**Publisher’s note** Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

## Supplementary information

## Rights and permissions

**Open Access** This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence, and indicate if changes were made. The images or other third party material in this article are included in the article’s Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article’s Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this licence, visit http://creativecommons.org/licenses/by/4.0/.

## About this article

### Cite this article

Ji, F., Edelen, A., Roussel, R. *et al.* Multi-objective Bayesian active learning for MeV-ultrafast electron diffraction.
*Nat Commun* **15**, 4726 (2024). https://doi.org/10.1038/s41467-024-48923-9

Received:

Accepted:

Published:

DOI: https://doi.org/10.1038/s41467-024-48923-9

## Comments

By submitting a comment you agree to abide by our Terms and Community Guidelines. If you find something abusive or that does not comply with our terms or guidelines please flag it as inappropriate.