원시데이터 수집 시스템
선정목록으로

A general Bayesian algorithm for the autonomous alignment of beamlines

관련 필름·전자재료 · (13) 프리즘 필름

기본 정보

저자
  1. T. W. Morris — Brookhaven National Laboratory, Upton, NY 11973, USA|||Lawrence Berkeley National Laboratory, Berkeley, CA 94720, USA
  2. Maksim Rakitin — Brookhaven National Laboratory, Upton, NY 11973, USA
  3. Yonghua Du — Brookhaven National Laboratory, Upton, NY 11973, USA
  4. Mikhail Fedurin — Brookhaven National Laboratory, Upton, NY 11973, USA
  5. Abigail Giles — Brookhaven National Laboratory, Upton, NY 11973, USA
  6. Denis Leshchev — Brookhaven National Laboratory, Upton, NY 11973, USA
  7. William Li — Brookhaven National Laboratory, Upton, NY 11973, USA
  8. Brianna Romasky — Brookhaven National Laboratory, Upton, NY 11973, USA|||Stony Brook University, New York, NY 11974, USA
  9. Eli Stavitski — Brookhaven National Laboratory, Upton, NY 11973, USA
  10. Andrew L. Walter — Brookhaven National Laboratory, Upton, NY 11973, USA
  11. Paul Moeller — RadiaSoft LLC, Boulder, CO 80301, USA
  12. Boaz Nash — RadiaSoft LLC, Boulder, CO 80301, USA
  13. Antoine Islegen-Wojdyla — Lawrence Berkeley National Laboratory, Berkeley, CA 94720, USA
DOI
10.1107/s1600577524008993
저널
Journal of Synchrotron Radiation
발행년도
2024
발행기관
Wiley
피인용수
7
라이선스
cc-by
논문 유형
–
언어
–
원문 페이지
https://doi.org/10.1107/s1600577524008993
토픽
Advancements in Photolithography Techniques
OpenAlex ID
W4403821371

평가 내용

관련도
관련
사업분야
필름·전자재료 · (13) 프리즘 필름
부 분야
–
R&D 측면
–
확신도
–
근거 용어
–
판단 근거
임베딩 유사도 기반 평가로 '필름·전자재료 > 프리즘 필름' 분야에 선정된 논문입니다.
R&D 활용 포인트
–
평가 입력
–

초록

Autonomous methods to align beamlines can decrease the amount of time spent on diagnostics, and also uncover better global optima leading to better beam quality. The alignment of these beamlines is a high-dimensional expensive-to-sample optimization problem involving the simultaneous treatment of many optical elements with correlated and nonlinear dynamics. Bayesian optimization is a strategy of efficient global optimization that has proved successful in similar regimes in a wide variety of beamline alignment applications, though it has typically been implemented for particular beamlines and optimization tasks. In this paper, we present a basic formulation of Bayesian inference and Gaussian process models as they relate to multi-objective Bayesian optimization, as well as the practical challenges presented by beamline alignment. We show that the same general implementation of Bayesian optimization with special consideration for beamline alignment can quickly learn the dynamics of particular beamlines in an online fashion through hyperparameter fitting with no prior information. We present the implementation of a concise software framework for beamline alignment and test it on four different optimization problems for experiments on X-ray beamlines at the National Synchrotron Light Source II and the Advanced Light Source, and an electron beam at the Accelerator Test Facility, along with benchmarking on a simulated digital twin. We discuss new applications of the framework, and the potential for a unified approach to beamline alignment at synchrotron facilities.

본문 39,516자

본문 펼치기
Autonomous methods to align beamlines can decrease the amount of time spent on diagnostics, and also uncover better global optima leading to better beam quality.The alignment of these beamlines is a high-dimensional, expensive-to-sample optimization problem involving the simultaneous treatment of many optical elements with correlated and nonlinear dynamics.Bayesian optimization is a strategy of efficient global optimization that has proved successful in similar regimes in a wide variety of beamline alignment applications, though it has typically been implemented for particular beamlines and optimization tasks.In this paper, we present a basic formulation of Bayesian inference and Gaussian process models as they relate to multiobjective Bayesian optimization, as well as the practical challenges presented by beamline alignment.We show that the same general implementation of Bayesian optimization with special consideration for beamline alignment can quickly learn the dynamics of particular beamlines in an online fashion through hyperparameter fitting with no prior information.We present the implementation of a concise software framework for beamline alignment and test it on four different optimization problems for experiments at x-ray beamlines of the National Synchrotron Light Source II and the Advanced Light Source and an electron beam at the Accelerator Test Facility, along with benchmarking on a simulated digital twin.We discuss new applications of the framework, and the potential for a unified approach to beamline alignment at synchrotron facilities. I. INTRODUCTION Synchrotron light sources are invaluable scientific tools that allow the probing of materials across bulk, micron, and nanometer scales.These facilities perform a wide variety of research, with applications in the study of catalysis, biological function, and material science.Several next-generation synchrotron and free-electron laser facilities are slated for upgrades which will increase their brilliance by several orders of magnitude [1][2][3][4].However, more advanced experiments will require more precise and complex optical setups.Beamlines consist of a large number of optical components (e.g.mirrors, magnets, apertures), each with many degrees of freedom (corresponding to e.g.motors that translate, rotate, and bend the components). 1These degrees of freedom can be highly correlated or degenerate, making beamline alignment in essence a high-dimensional (D ≳ 10), highly non-linear optimization problem.This is typically done manually, 2but as the complexity and precision of beamlines grow, the development of efficient and robust automated alignment methods is necessary for the efficient operation of light sources now and in the future.Such methods allow us to reach an acceptable level of alignment more quickly and robustly than with manual methods when realignment is necessary, saving preparation and commissioning time which could be used for experiments.They further allow us to potentially find better global optima than an operator could discover manually by considering all dimensions of the beamline simultaneously.They also represent the first step toward a fully autonomous beamline [5].Some attempts at beamline alignment apply methods like genetic and differential evolution [6][7][8][9], attempt to match beamline data to an online model [10,11], or use families of commonly-used optimization algorithms [12,13].These approaches are limited in that they give no guarantee of convergence to a global optimum.They also make no consideration of minimizing the number of function evaluations, and beamline optimization almost universally involves a prohibitively expensive-to-sample function, both at the real beamline (relying on the movement of precise motors, which can be slow) and on simulated digital twins (relying on computationally intensive ray-tracing [14] or Fourier-based methods [15]) meaning that their use is intractable for large numbers of dimensions.In contrast to the classical methods above, al-gorithms based on machine learning construct and fit a model to understand the effects of changing the parameter inputs, as well as the interaction of the output beam qualities (e.g.flux, spatial resolution, energy resolution, polarization, coherence), leading to a more efficient search of the parameter space.Some machine learning methods like reinforcement learning [16] suffer from similar drawbacks to the methods above in that they may take too long to learn enough to be useful, at which point beamline parameters and hyperparameters may have drifted substantially.From a practical point of view, then, we should greatly prefer alignment methods that converge as quickly as possible, and rely on little to no prior input. I. INTRODUCTION A machine learning framework well-suited for expensive-to-sample functions is Bayesian optimization, which performs well with no prior information on optimization problems that are expensive-to-sample, high-dimensional, and potentially very noisy.Bayesian optimization has been applied in such a wide variety of contexts as synchrotron light sources [17,18], free-electron lasers [19], particle colliders [20], and laser-plasma-based ion sources [21].These implementations, however, are typically applicable to single experiments; indeed, much of the difficulty in implementing machine learning solutions to any problem is the trade-off of specificity and generality where an algorithm that is specific enough to be effective in some context is too specific to be applied generally. I. INTRODUCTION Bayesian optimization is highly generalizable in the choice of the kernel model used to describe the parameter space, and that many facilities are moving toward shared software environments and shared data acquisition protocols like Bluesky [22,23] suggest the benefit of a general agent.This paper demonstrates an implementation of a Bayesian agent that can learn the dynamics and idiosyncrasies of a particular beamline and can thus be deployed across many different beamlines with relatively little implementation cost by applying the same code to a range of optimization problems at different synchrotron and non-synchrotron facilities. I. INTRODUCTION In Sections II, III, and IV we present a general but brief formulation of multiobjective Bayesian optimization with Gaussian process regression as it relates to this work (for a more thorough introduction see Frazier 24).Section V addresses beamline-specific considerations for Bayesian optimization, and Section VI presents their implementation in a software package.Section VII describes the application of the code at beamlines across the National Synchrotron Light Source II and Accelerator Test Facility at Brookhaven National Laboratory and the Advanced Light Source at Lawrence Berkeley National Laboratory, and presents the results of benchmarking on a simulated digital twin.Finally, Section VIII discusses the future development of the algorithm. II. BAYESIAN OPTIMIZATION Consider an expensive-to-sample black-box function f (x) with d-dimensional inputs x ∈ R d .In finding the right input x to achieve the maximal value of f (x), it is untenable to utilize optimization methods that rely on lots of function samples.We can address this by treating the function as a stochastic process (which describes a distribution over all possible realizations of the function) and using Bayesian inference to construct a posterior distribution p(f ), i.e. describing how likely it is that every possible function f is the true function. 3If we sample the function at points x = {x 1 , x 2 , ..., x n } and observe values y = {f (x 1 ), f (x 2 ), ..., f (x n )}, then we can use Bayesian inference to write our posterior belief about f given that we observe x and y as II. BAYESIAN OPTIMIZATION where the quantity p(y | f, x) (called the likelihood ) is the probability of observing values y at inputs x for a given function f , the quantity p(f ) (called the prior ) is our knowledge about the probability of a given function f before we have seen any data, and the quantity p(y | x) (called the marginal likelihood ), represents the distribution of y after marginalizing over the distribution of f . 4 A representation of conditioning a prior on observations to construct a posterior is shown in Figure 2.Each iteration of Bayesian optimization then consists of three steps: II. BAYESIAN OPTIMIZATION 1. Estimate the posterior p(f | y, x) from some historical observations (x, y). II. BAYESIAN OPTIMIZATION 2. Use the posterior to find the most desirable point x ⋆ within some predefined bounds. II. BAYESIAN OPTIMIZATION 3. Sample that point, and add it to our historical observations. II. BAYESIAN OPTIMIZATION Constructing a posterior from observations in the first step is almost always done with a Gaussian process (GP), the particulars of which are described in Section III. II. BAYESIAN OPTIMIZATION Quantifying the desirability of candidate points in the second step is done using acquisition functions which are described in Section IV.A concrete example of an iteration of Bayesian optimization as applied to minimizing Himmelblau's function is shown in Figure 1, using a GP model and an acquisition function that computes II. BAYESIAN OPTIMIZATION because the sum of all the probabilities in the posterior must sum to unity. the expected improvement in the cumulative maximum by sampling each candidate point. III. GAUSSIAN PROCESS MODELS A Gaussian process (GP) is a stochastic process where every collection of variables y has a multivariate normal distribution; for notational simplicity and without loss of generality, we assume throughout the paper that all of our processes are zero-mean.The GP is described entirely by the covariance matrix Σ describing the observations y.A Gaussian process model consists of assigning a covariance matrix to a set of sample data y at inputs x and computing the posterior mean and posterior variance at every other input.In practice, the covariance of the process is not known a priori and is approximated by constructing and fitting a kernel. A. Kernels and hyperparameter optimization We model the covariance matrix with a kernel matrix K(x, x ′ , θ), where A. Kernels and hyperparameter optimization where k is a kernel function, x i and x j are two inputs, and θ is a set of hyperparameters which tune k.The only constraint on a kernel matrix K is that it is positivedefinite. 5A simplifying assumption is to require that the kernel is stationary, that is, that the correlation of the function at two inputs depends only on their distance A. Kernels and hyperparameter optimization To construct our kernel, we take the hyperparameters which maximize the marginal likelihood A. Kernels and hyperparameter optimization For a Gaussian process, the marginal likelihood is given by B. Posterior estimation Once we have our kernel K(x i , x j , θ) and optimized hyperparameters θ, we can use Gaussian process regression to construct posteriors.Given our measurements y at points x, our posterior estimate of the distribution of the process at points x ⋆ is a Gaussian distribution with posterior mean f (x ⋆ ) = Af (x) and posterior covariance B. Posterior estimation The vector of variances for each individual point is the diagonal of the posterior covariance B. B. Posterior estimation GP posterior (with noise) FIG.2: The prior distribution, noiseless posterior distribution, and noisy posterior distributions for a Gaussian process with covariance ⟨f (xi)f (xj)⟩ = M 5/2 (|xi − xj|/4), where Mν (r) is the Matérn function as defined in Equation 19.For each distribution, we draw four random functions (colored lines).The black line represents the mean of each distribution, while the darkand light-shaded regions represent the 1σ and 2σ intervals. C. Noisy models It may be the case that our observations are noisy, i.e. that observing the function at points x will yield y = f (x)+ϵ where ϵ is a random noise term.If we assume that ϵ is homoskedastic and Gaussian, then we can account for the noise by adding a constant noise variance σ 2 to the diagonal of the kernel K. 6 IV. ACQUISITION FUNCTIONS The acquisition function A(x) is a model of a given objective over possible inputs which, given a posterior p(f | x, y), quantifies the desirability of sampling a given input x.For each iteration of the optimization, we optimize the acquisition function over the inputs as IV. ACQUISITION FUNCTIONS Acquisition functions over posteriors are typically cheap to compute, and so classical algorithms (like LM-BFGS) are used to optimize them. 7Acquisition functions can be either analytic or non-analytic; below, we show benefits and examples of either approach. A. Analytic acquisition functions Analytic acquisition functions are directly computable from the posterior; as the posterior for a GP is determined entirely by the mean µ and variance σ, they may be expressed as A. Analytic acquisition functions The simplest example is the expected mean A. Analytic acquisition functions where on every iteration the algorithm will sample the point with the largest expected mean.A less risk-averse example is the expected improvement A. Analytic acquisition functions which is our expectation for how much the cumulative maximum f ⋆ will increase if we were to sample x.We can compute this directly as A. Analytic acquisition functions where z = (µ(x) − f * )/σ(x), and ϕ(z) and Φ(z) are the PDF and CDF of the standard normal distribution. A. Analytic acquisition functions Because repeated sampling of a point will strictly decrease the posterior variance, this algorithm will (for wellbehaved problems) eventually explore every point in the parameter space. B. Monte Carlo acquisition functions Some useful acquisition functions cannot be computed directly from the mean and variance of the posterior.Acquisition functions that involve sampling from the posterior to estimate some ensemble are more flexible and often more robust.One example of this is in selecting multiple points, as in when we want to find the best n points to sample given some analytic acquisition function A(x): presumably they should be spread out to better cover the parameter space, but there no obvious way to quantify and thus compute that analytically.We address this interdependence with a Monte Carlo acquisition function, where we might evaluate the acquisition of some collection of points by sampling from the posterior and taking an ensemble average of the result.There is a large benefit in sampling multiple points at once for beamline optimization, as it allows us to find a batch of points to sample and then optimally route the beamline parameters between them to reduce travel time. B. Monte Carlo acquisition functions Note that all analytic acquisition functions have a Monte-Carlo equivalent; an example is shown in the farright panel of Figure 1, where we use the q-expected improvement as an acquisition function to find a parallel set of eight inputs to sample next. 8Monte Carlo methods also allow for more sophisticated information theory-based acquisition functions like Predictive Entropy Search [25], Maximum Entropy Search [26], or Joint Entropy Search [27]. C. Multiobjective optimization Optimization problems often require managing tradeoffs.For example, a common beamline design consists of a secondary-source aperture (SSA), which cuts off some flux in the interest of having a smaller and tighter beam.One method of multiobjective optimization is scalarization, which is to use a function that maps a vector output to a scalar output, leading to one quantity to be maximized.In this work, we use affine scalarizations (i.e.assigning a weight to each objective and summing them) to construct a single fitness function over which to optimize an acquisition function. C. Multiobjective optimization There are, however, are other useful ways to carry out multiobjective optimization like Pareto efficient searches (i.e.finding the set of inputs where no one objective can be increased without decreasing some other objective).But while fully multiobjective methods do allow for more flexibility in the alignment, that flexibility is not compatible with an autonomous beamline, which must decide on a single best beam and thus must collapse the beam to a single fitness function. V. BEAMLINE-SPECIFIC CONSIDERATIONS In this section, we consider beamline-specific considerations that improve the practical application of Bayesian optimization to the automated alignment problem.In this paper, we consider the common optimization problem of maximizing the beam power density, defined as V. BEAMLINE-SPECIFIC CONSIDERATIONS where x represents the beamline inputs to optimize and where Φ(x), σ x (x), and σ y (x) are the input-dependent flux, horizontal spread, and vertical spread of the beam.These parameters are inferred from an image of the beam profile, taken using either an area detector (e.g.Figures 6 and 8) or a beam stop and microscope (e.g.Figures 5 and 9).In practice, it is better to model the fitness as V. BEAMLINE-SPECIFIC CONSIDERATIONS because the distribution in variations in beam flux and size are both roughly log-normal, and so their logarithms are better described by a Gaussian process.It also preserves the convexity of the problem and, being inherently dimensionless, allows us to affinely scalarize many simultaneous objectives as a single Gaussian process. A. A kernel for latent beamline dimensions Input parameters for beamlines can be highly coupled, as shown in Figure 3.In fitting Gaussian processes to beamline data, we adopt a kernel of the form A. A kernel for latent beamline dimensions where f (r) is some radial function, D is a diagonal matrix with positive entries, exp(•) is the matrix exponential, and S is a skew-symmetric matrix.Because the matrix exponential of a real skew-symmetric matrix is an orthogonal matrix, this kernel represents a norm-preserving transformation in the parameter space by exp(S) and a scaling of each dimension in the new basis by D. This kernel design is guaranteed to be positive-definite so long as f is a positive-definite function. 9A commonly used positive-definite function in kernel construction is the Matérn function, which can be written as A. A kernel for latent beamline dimensions where K ν (z) is the modified Bessel function of the second kind of order ν, and where a, ℓ, ν > 0 are hyperparameters.For our purposes, ℓ as a lengthscale parameter is redundant and can be subsumed into the hyperparameters defining T .This leaves us with a normalized form A. A kernel for latent beamline dimensions Bessel functions are expensive to compute for arbitrary ν, so we constrain our kernel to ν = n + 1/2, n ∈ Z, for which Equation 19 reduces to the product of a polynomial and an exponential.Unless otherwise specified, we use ν = 5/2 throughout the paper. B. Dirichlet-based validity constraints The application of Bayesian optimization relies on reliable diagnostic feedback, which is often not a realistic assumption for real-life scenarios.Undesirable behavior in the diagnostics can occur both sporadically (e.g. in the case of a beam dump or a hardware failure) and also systematically (a certain beamline orientation causes the beam to miss a mirror or detector).We want to be able to classify regions of the parameter space as invalid and encode that knowledge into our acquisition function, but we don't want a single unrepresentative glitch to rule out an otherwise worthy part of the parameter space.For this purpose a probabilistic classification model is ideal, and it is also able to easily adjust expectation-and entropybased acquisition functions. B. Dirichlet-based validity constraints We use the classification method outlined in [28] which fits a Dirichlet distribution to the data from which we can generate class probabilities.This method has the benefit of avoiding expensive posterior sampling (as in the case with stochastic variational methods) at the expense of not being able to quantify uncertainty. B. Dirichlet-based validity constraints A Dirichlet distribution of order N is defined as B. Dirichlet-based validity constraints where the vector parameter p = {p 1 , ..., p N } describes the probabilities of classes in a N − 1 simplex (so that i p i = 1), and the concentration parameters α = {α 1 , ..., α N } parameterize the concentration of the distribution in that simplex.We use transformed Gaussian processes to model the concentration parameter α i for each classification i according to [28].As the order-N Dirichlet distribution is the conjugate prior to the Ncategorical distribution, we can obtain the probability of a beamline input being valid as B. Dirichlet-based validity constraints where Gamma(α, β) is the Gamma distribution, and γ i are samples from that distribution.Using this probability, we can weight any objective-based acquisition function to prefer inputs that lead to valid outputs.This approach has the added benefit of being generalizable to any number of classification labels, which could be made more nuanced than a binary model of validity. C. Sampling expense Bayesian optimization is particularly useful when sampling the objective function f (x) is expensive.This is strictly true for some beamlines where computing a diagnostic is expensive, e.g.those that involve intensive data processing or a complicated metaroutine like a knife-edge scan [29].Many beamlines, though, have no latency in the diagnostics and are only expensive to sample because they are expensive to move around.This is due to the high precision of the motors, which must move slowly so as not to damage the optics, and need time to settle to prevent backlash and make sure that it is exactly at its setpoint; this is typically on the order of several seconds. C. Sampling expense A good acquisition function, then, should take into account travel time: a simple solution is to optimize a Monte Carlo acquisition function over a "batch" of points that we can compute the most efficient route between using e.g.https://github.com/google/or-tools. Ideally, the acquisition function would consider the variable time cost of traveling to a given set of points, but the computational cost of this can be unwieldy. D. Hysteresis Another challenge to ML-based optimization is hysteresis, which manifests at beamlines when the actual position of some input varies from the desired input.This can happen when the motor approaches the same position from different directions, primarily from physical backlashes in the hardware.A core assumption of Bayesian optimization is that the relevant function f (x) always yields the same output (modulo some noise).Hysteresis can be mitigated by overestimating the noise level, or with a more thorough treatment of uncertainty in the inputs of the underlying Gaussian process [30].We note the benefit of motor encoders, which can lead to more precise and consistent control of beamline hardware. E. Composite objectives Even though we combine estimates of the different beam attributes into a scalar fitness to maximize, it is still beneficial to construct and train three separate models for the flux, horizontal spread, and vertical spread, a method typically referred to as composite optimization.This allows us to take advantage of how different inputs affect different outputs; indeed, many beamlines are designed to separate components that tune the flux from those that tune the focus.This can significantly reduce the effective dimensionality of the alignment problem.Our beamline alignment tools are implemented in the Blop10 Python package, relying on the BoTorch Python package [31].In Blop we develop a customized kernel which fits to latent beamline dimensions outlined in Section V A, and weight common acquisition functions by the probabilistic constraint outlined in Section V B. We also use BoTorch for model fitting and acquisition function optimization.The algorithm is used in terms of an agent, which we instantiate with motors and diagnostic equipment.We can "tell" the agent about the values of pre-defined objectives (e.g.beam height, coherence) and "ask" it for new points to sample.The agent wraps the steps of Bayesian optimization in a single customizable routine (implemented in Python as a .learn()method), which yields a plan accepted by the Bluesky experiment orchestration system. 11This routine can be tailored to each beamline (or to each alignment problem for a given beamline).Encapsulating the optimization as a single process simplifies the alignment from the point of view of the user, making experimentation more accessible to users who have less familiarity with a given beamline (i.e.hardware, data acquisition, control systems), or with less familiarity with software in general. B. Bluesky Bluesky [22,23] is a software package that allows for the orchestration and execution of experiments from Python, and is in the process of being adapted by various light sources. 12We design Blop with Bluesky in mind, as it can use Bluesky to automatically take data, analyze it, and optimize the inputs with the same feedback and control systems used for beamline experiments.This allows the Blop agent to both command and control the beamline, leading to an easier implementation. 13Bluesky has been mainly developed by NSLS-II, with a growing international collaboration at multiple facilities where it is used and expanded.The adoption of a single standard for experimental control and analysis across many facilities allows us to apply the same automated alignment tools with relatively little effort.The TES beamline [32] is a tender x-ray microspectroscopy beamline at NSLS-II with an energy range of 2-5.5 keV and a beam size which can be tuned between 5 and 20 microns.The x-rays are produced from a bending magnet source and pass through a Si(111) double crystal monochromator.A toroidal mirror prefocuses the beam onto a secondary source aperture (SSA), after which the beam is refocused onto the sample by a pair of Kirkpatrick-Baez (K-B) mirrors in the endstation chamber.A schematic of the beamline is represented in Figure 4. We optimize for the flux density on the sample by allowing each K-B mirror and the toroidal mirror to pitch and translate into and out of the beam for a total of six degrees of freedom.Figure 5 shows an example of the beam feedback provided by the camera, with the alignment being gradually improved. B. Alignment of a Johann Spectrometer at the ISS beamline The Inner Shell Spectroscopy beamline (ISS, 8-ID) beamline [33] is a beamline for x-ray absorption spectroscopy and operando and in-situ characterization of materials.ISS is a damping wiggler beamline with a Si(111) monochromator capable of producing energies between 4.9 and 33 keV.Currently, the beamline is developing high-resolution capabilities with the recent commissioning of a five-analyzer Johann-type spectrometer, where after hitting the sample, the beam is reflected back onto an area detector by several crystals. 14Maximizing the flux on the area detector maximizes the resolution of the spectrometer, and so we seek to colocate the reflections of the crystals onto the same point.We use three crystals to focus the beam onto a two-dimensional area detector.Figure 6 shows the optimization of the threecrystal system.The photon transport system (Figure 7) comprises of a first focusing mirror, a monochromator and a few apertures.The focusing mirror is a vertically deflecting toroidal mirror, creating an image of the source at the sample.The mirror is gold-coated with a nominal grazing angle of 5 mrad, mirror-to-object (p) and mirror-to-image (q) distance of p = q = 12 m.The corresponding tangential and sagittal radius of curvature are respectively R t = 2400 m and R s = 60 mm.The mirror is bendable along the tangential direction to adjust the vertical focus position.The monochromator is a channel-cut double crystal Si(111) monochromator, providing a 25 mm vertical offset.There are a set of 4-jaw slits immediately after the monochromator to block the straight-through beam, and another set of 4-jaw slits immediately before the sample position (12 m downstream of the toroidal mirror).For beam measurement, we used a diamond-based xray beam monitor (ClearXCam from Advent Diamond) with which we computed the flux as the sum of all pixels.We added a preference for a rounder beam (with some coupling between horizontal and vertical size) by defining an "effective area" metric as: B. Alignment of a Johann Spectrometer at the ISS beamline The full scalarized fitness for the effective power density then becomes B. Alignment of a Johann Spectrometer at the ISS beamline The manual optimization is rendered difficult by the interplay between the toroidal mirror angle, monochromator height and angle, all of them changing the beam height and interfering with 4-jaw slits.With the use of the described automated alignment, we were able to maximize the power density on the sample in under five minutes, with a final beam size of 1 mm x 0.3 mm (HxV, FWHM), close to the theoretical limit calculated by raytracing (Figure 8) with an improvement of the intensity by over a factor of two over our best effort using manual alignment. D. Alignment of an electron beam at the Accelerator Test Facility The Accelerator Test Facility (ATF) is a user facility at Brookhaven National Laboratory offering the combination of an 80 MeV electron beam synchronized with a Terawatt picosecond carbon dioxide laser [35].This gives it the capability to develop cutting-edge electron beam techniques including ultrafast electron diffraction and microscopy [36], as well as free-electron laser techniques including direct laser acceleration and using Compton scattering as a high energy x-ray source [37].We modulate three bending quadrupole electromagnets and a solenoid to manipulate the shape of the beam, for a total of four degrees of freedom.We employ the alternate fitness function in Equation 23 that was also used to align ATF. Figure 9 shows an example of the beam feedback provided by the inhouse beam diagnostic, with the alignment being gradually improved. E. Simulated alignment of the TES beamline The use of most beamlines is extremely competitive, and benchmarking alignment methods by performing ensembles of different runs is too time-intensive to be viable.Instead, we use digital twins of beamlines using the Sirepo-Bluesky backend [38], allowing us to optimize the beam with the same Bluesky-based code used to align real beamlines.We use a ray tracing-based beamline simulation code called Shadow [14] to model beam propagation, which does not recreate diffraction effects but accurately recreates the behavior of the beam under misalignments.Even this heuristic method is slow, requiring several seconds per scan and thus many hours for comprehensive benchmarking; we note the development accelerated approximate models of beam propagation under misalignments, which would aid the efficient development of automated alignment tools [39]. E. Simulated alignment of the TES beamline For benchmarking, we consider the digital twin of the TES beamline at NSLS-II.In the 8-dimensional case, we use the six degrees of freedom outlined in Section VII A, but also allow the toroidal mirror to yaw and translate horizontally for a total of eight degrees of freedom.Each K-B motor can move up to ± 0.25 mm from a fiducial starting point, while the range of each toroidal motor was bounded by the points where the misalignment of that motor caused the flux through the SSA to fall to 50% of the maximum.The results of this benchmark are shown in Figure 10. E. Simulated alignment of the TES beamline A simpler benchmark is shown in Figure 11, where the agent realigns the 4-dimensional K-B system under small misalignments (up to 0.05 mm) in each mirror's motors. VIII. FURTHER DEVELOPMENT AND DISCUSSION We have applied the same automated alignment tools to several different facilities, and have shown that the same python package can effectively align a range of beamlines.Further refinement of these automated alignment tools will involve applying them to more beamlines at more facilities, with different flavors of optimization problems.How practical automated alignment can be necessitates an intuitive graphical user interface, from which the configuration of the optimizer is easy to understand.Further development also includes the implementation of new features and better performance in the software.The enabling of Pareto efficient optimization will give the beamline scientist more control over the beam quality, and making the agent take into account the traveling cost of moving the inputs into the acquisition function would allow for more informed optimization.We also plan to allow for a decentralized agent, which can run on a high-performance computing server and communicate with the control system using a streaming system like Kafka and feedback to the experiment control using Bluesky-Queueserver. 15 Fly-scanning, the strategy of sampling while moving parameters (instead of stopping and settling at each input), presents the potential to speed up beamline alignment, as the sampling expense at most beamlines comes from the accelerating and decelerating of components while varying parameters.This requires a very accurate synchronization between the feedback of inputs and outputs (another use of the motor encoders mentioned in Section V D), and is actively being developed at many light source facilities. VIII. FURTHER DEVELOPMENT AND DISCUSSION We also note that the largest obstacle to applying automated alignment to existing beamlines is the difficulty in constructing robust feedbacks, as many beam diagnostics have non-negligible backgrounds or malfunctioning pixels.While an experienced beamline scientist is able to ignore and look past these artifacts, they may interfere with simpler methods of estimating beam flux, position and size from an image (e.g.computing the spread of a profile summed along one dimension).This is especially significant in the case of Bayesian optimization, which relies on accurate sampling of the true objective.This suggests the benefit of more sophisticated diagnostic methods, using machine learning techniques like image segmentation. FIG. 1 : FIG. 1: An example of an iteration of a Bayesian optimization algorithm trying to maximize the negated Himmelblau's function f (x1, x2) = −(x 2 1 + x2 − 11) 2 − (x1 + x 2 2 − 7) 2 , whose true global optima are marked as white circles.Using existing data points (far left) and the assumption that the function is distributed as a Gaussian process, we can use Bayesian inference to compute a posterior consisting of a mean (center left) and error (center right), upon which we can compute an acquisition function (far right) which informs us of the best points to sample.The black-edged diamonds superimposed on the acquisition function show the best eight points to sample, optimized in parallel, and the optimal routing represented by the red line. 10 1 10 2 FIG. 3 : FIG. 3: Upper left: the result of changing the positions of two coupled dimensions of the TES beamline.Upper right: a quasi-random sample of 16 points from the ground truth.Lower left: a non-latent GP fitted to the parameter space fitted to the sampled points.Lower right: a latent GP fitted to the same points, which correctly infers the latent dimensions. 10 1 10 2 FIG. 3 : The hyperparameters θ define the entries of D and S, which for an d-dimensional parameter space have d and d(d − 1)/2 degrees of freedom respectively, together defining a total transformation matrix T = D exp(S) with d(d + 1)/2 degrees of freedom. 10 1 10 2 FIG. 3 : FIG.4:A schematic of the Tender-Energy X-ray Absorption Spectroscopy (TES, 8-BM) beamline at NSLS-II.This representation shows the many optical components that make up modern beamlines, with each optical component having many degrees of freedom that must be optimized in concert in order to carry out experiments effectively. FIG. 5 : FIG. 5: Four different beams configurations at the National Synchrotron Light Source II's Tender Energy X-ray Absorption Spectroscopy (TES, 8-BM) beamline, where the upper left panel shows the initial beam and where the lower right represents the optimal alignment.In this alignment test, we adjust the translation and rotation of each of the horizontal and vertical Kirkpatrick-Baez mirrors and the pitch and vertical translation of a toroidal mirror, for a total of six degrees of freedom to maximize the flux density of the beam. FIG. 6 : FIG. 6: Four different beam configurations at the National Synchrotron Light Source II's Inner Shell Spectroscopy (ISS, 8-ID) beamline during automated alignment, where the upper left panel shows the initial beam and the lower right panel represents the optimal alignment.In this alignment test, we adjust the translation of a central crystal and the translation and pitch of two ancillary crystals for a total of five degrees of freedom to maximize the flux density of the total beam on the area detector. C . Photon transport optimization at the Advanced Light Source beamline 5.3.1 Beamline 5.3.1 at the Advanced Light Source at Lawrence Berkeley National Laboratory is a research and development beamline.It is a bending magnet beamline, operating in the tender x-ray regime (2.4-12 keV photon energy range.),where the instrument controls have recently been upgraded to the EPICS/Bluesky framework. FIG. 7 : Photon beam FIG. 8 : FIG. 8: Four different beam configurations at the Advanced Light Source's Beamline 5.3.1 during automated alignment.In total, the photon transport has four active degrees of freedom: the focusing mirror pitch and tangential bend, the channel cut crystal angle and height.The upper left panel shows the initial, manually aligned beam and the lower right the final beam after automated alignment.Upper right and lower left panels show intermediary points collected in the automated alignment process. FIG. 9 : FIG.9: Four different electron beam configurations at the Brookhaven National Laboratory's Accelerator Test Facility (ATF) at different stages of automated alignment, where the upper left panel shows the starting beam and the lower right the optimal beam.In this alignment test, we tune the current of four quadrupole electromagnets to maximize the objective in Equation23. FIG. 9 : FIG.10:8-dimensional optimization of the simulated TES beamline, where the degrees of freedom comprise the toroidal and Kirkpatrick-Baez mirrors.The colors show different varieties of Bayesian optimization algorithms with and without both of latent inputs and composite outputs, with both the cumulative maximum of all individual runs (thin lines) and the median cumulative maximum (thick line).Each variety starts out with a quasi-random sampling of 32 points (shaded light blue), and then performs a Bayesian optimization loop with the expected improvement acquisition function.The benefit of using both latent inputs and composite outputs is shown, as we can achieve a better optimum more robustly and more quickly. FIG. 9 : FIG.11:The 4-dimensional optimization of just the K-B mirrors, whose motors are each misaligned by up 0.05 mm.After an initial quasi-random sample of 16 points (shaded light blue), the agent is able to almost instantly return to the optimal alignment.

섹션 본문 72문단 · 37,340자

(제목 없음)

1Autonomous methods to align beamlines can decrease the amount of time spent on diagnostics, and also uncover better global optima leading to better beam quality.The alignment of these beamlines is a high-dimensional, expensive-to-sample optimization problem involving the simultaneous treatment of many optical elements with correlated and nonlinear dynamics.Bayesian optimization is a strategy of efficient global optimization that has proved successful in similar regimes in a wide variety of beamline alignment applications, though it has typically been implemented for particular beamlines and optimization tasks.In this paper, we present a basic formulation of Bayesian inference and Gaussian process models as they relate to multiobjective Bayesian optimization, as well as the practical challenges presented by beamline alignment.We show that the same general implementation of Bayesian optimization with special consideration for beamline alignment can quickly learn the dynamics of particular beamlines in an online fashion through hyperparameter fitting with no prior information.We present the implementation of a concise software framework for beamline alignment and test it on four different optimization problems for experiments at x-ray beamlines of the National Synchrotron Light Source II and the Advanced Light Source and an electron beam at the Accelerator Test Facility, along with benchmarking on a simulated digital twin.We discuss new applications of the framework, and the potential for a unified approach to beamline alignment at synchrotron facilities.

I. INTRODUCTION

2Synchrotron light sources are invaluable scientific tools that allow the probing of materials across bulk, micron, and nanometer scales.These facilities perform a wide variety of research, with applications in the study of catalysis, biological function, and material science.Several next-generation synchrotron and free-electron laser facilities are slated for upgrades which will increase their brilliance by several orders of magnitude [1][2][3][4].However, more advanced experiments will require more precise and complex optical setups.Beamlines consist of a large number of optical components (e.g.mirrors, magnets, apertures), each with many degrees of freedom (corresponding to e.g.motors that translate, rotate, and bend the components). 1These degrees of freedom can be highly correlated or degenerate, making beamline alignment in essence a high-dimensional (D ≳ 10), highly non-linear optimization problem.This is typically done manually, 2but as the complexity and precision of beamlines grow, the development of efficient and robust automated alignment methods is necessary for the efficient operation of light sources now and in the future.Such methods allow us to reach an acceptable level of alignment more quickly and robustly than with manual methods when realignment is necessary, saving preparation and commissioning time which could be used for experiments.They further allow us to potentially find better global optima than an operator could discover manually by considering all dimensions of the beamline simultaneously.They also represent the first step toward a fully autonomous beamline [5].Some attempts at beamline alignment apply methods like genetic and differential evolution [6][7][8][9], attempt to match beamline data to an online model [10,11], or use families of commonly-used optimization algorithms [12,13].These approaches are limited in that they give no guarantee of convergence to a global optimum.They also make no consideration of minimizing the number of function evaluations, and beamline optimization almost universally involves a prohibitively expensive-to-sample function, both at the real beamline (relying on the movement of precise motors, which can be slow) and on simulated digital twins (relying on computationally intensive ray-tracing [14] or Fourier-based methods [15]) meaning that their use is intractable for large numbers of dimensions.In contrast to the classical methods above, al-gorithms based on machine learning construct and fit a model to understand the effects of changing the parameter inputs, as well as the interaction of the output beam qualities (e.g.flux, spatial resolution, energy resolution, polarization, coherence), leading to a more efficient search of the parameter space.Some machine learning methods like reinforcement learning [16] suffer from similar drawbacks to the methods above in that they may take too long to learn enough to be useful, at which point beamline parameters and hyperparameters may have drifted substantially.From a practical point of view, then, we should greatly prefer alignment methods that converge as quickly as possible, and rely on little to no prior input.

3A machine learning framework well-suited for expensive-to-sample functions is Bayesian optimization, which performs well with no prior information on optimization problems that are expensive-to-sample, high-dimensional, and potentially very noisy.Bayesian optimization has been applied in such a wide variety of contexts as synchrotron light sources [17,18], free-electron lasers [19], particle colliders [20], and laser-plasma-based ion sources [21].These implementations, however, are typically applicable to single experiments; indeed, much of the difficulty in implementing machine learning solutions to any problem is the trade-off of specificity and generality where an algorithm that is specific enough to be effective in some context is too specific to be applied generally.

4Bayesian optimization is highly generalizable in the choice of the kernel model used to describe the parameter space, and that many facilities are moving toward shared software environments and shared data acquisition protocols like Bluesky [22,23] suggest the benefit of a general agent.This paper demonstrates an implementation of a Bayesian agent that can learn the dynamics and idiosyncrasies of a particular beamline and can thus be deployed across many different beamlines with relatively little implementation cost by applying the same code to a range of optimization problems at different synchrotron and non-synchrotron facilities.

5In Sections II, III, and IV we present a general but brief formulation of multiobjective Bayesian optimization with Gaussian process regression as it relates to this work (for a more thorough introduction see Frazier 24).Section V addresses beamline-specific considerations for Bayesian optimization, and Section VI presents their implementation in a software package.Section VII describes the application of the code at beamlines across the National Synchrotron Light Source II and Accelerator Test Facility at Brookhaven National Laboratory and the Advanced Light Source at Lawrence Berkeley National Laboratory, and presents the results of benchmarking on a simulated digital twin.Finally, Section VIII discusses the future development of the algorithm.

II. BAYESIAN OPTIMIZATION

6Consider an expensive-to-sample black-box function f (x) with d-dimensional inputs x ∈ R d .In finding the right input x to achieve the maximal value of f (x), it is untenable to utilize optimization methods that rely on lots of function samples.We can address this by treating the function as a stochastic process (which describes a distribution over all possible realizations of the function) and using Bayesian inference to construct a posterior distribution p(f ), i.e. describing how likely it is that every possible function f is the true function. 3If we sample the function at points x = {x 1 , x 2 , ..., x n } and observe values y = {f (x 1 ), f (x 2 ), ..., f (x n )}, then we can use Bayesian inference to write our posterior belief about f given that we observe x and y as

7where the quantity p(y | f, x) (called the likelihood ) is the probability of observing values y at inputs x for a given function f , the quantity p(f ) (called the prior ) is our knowledge about the probability of a given function f before we have seen any data, and the quantity p(y | x) (called the marginal likelihood ), represents the distribution of y after marginalizing over the distribution of f . 4 A representation of conditioning a prior on observations to construct a posterior is shown in Figure 2.Each iteration of Bayesian optimization then consists of three steps:

81. Estimate the posterior p(f | y, x) from some historical observations (x, y).

92. Use the posterior to find the most desirable point x ⋆ within some predefined bounds.

103. Sample that point, and add it to our historical observations.

11Constructing a posterior from observations in the first step is almost always done with a Gaussian process (GP), the particulars of which are described in Section III.

12Quantifying the desirability of candidate points in the second step is done using acquisition functions which are described in Section IV.A concrete example of an iteration of Bayesian optimization as applied to minimizing Himmelblau's function is shown in Figure 1, using a GP model and an acquisition function that computes

13because the sum of all the probabilities in the posterior must sum to unity. the expected improvement in the cumulative maximum by sampling each candidate point.

III. GAUSSIAN PROCESS MODELS

14A Gaussian process (GP) is a stochastic process where every collection of variables y has a multivariate normal distribution; for notational simplicity and without loss of generality, we assume throughout the paper that all of our processes are zero-mean.The GP is described entirely by the covariance matrix Σ describing the observations y.A Gaussian process model consists of assigning a covariance matrix to a set of sample data y at inputs x and computing the posterior mean and posterior variance at every other input.In practice, the covariance of the process is not known a priori and is approximated by constructing and fitting a kernel.

A. Kernels and hyperparameter optimization

15We model the covariance matrix with a kernel matrix K(x, x ′ , θ), where

16where k is a kernel function, x i and x j are two inputs, and θ is a set of hyperparameters which tune k.The only constraint on a kernel matrix K is that it is positivedefinite. 5A simplifying assumption is to require that the kernel is stationary, that is, that the correlation of the function at two inputs depends only on their distance

17To construct our kernel, we take the hyperparameters which maximize the marginal likelihood

18For a Gaussian process, the marginal likelihood is given by

B. Posterior estimation

19Once we have our kernel K(x i , x j , θ) and optimized hyperparameters θ, we can use Gaussian process regression to construct posteriors.Given our measurements y at points x, our posterior estimate of the distribution of the process at points x ⋆ is a Gaussian distribution with posterior mean f (x ⋆ ) = Af (x) and posterior covariance

20The vector of variances for each individual point is the diagonal of the posterior covariance B.

21GP posterior (with noise) FIG.2: The prior distribution, noiseless posterior distribution, and noisy posterior distributions for a Gaussian process with covariance ⟨f (xi)f (xj)⟩ = M 5/2 (|xi − xj|/4), where Mν (r) is the Matérn function as defined in Equation 19.For each distribution, we draw four random functions (colored lines).The black line represents the mean of each distribution, while the darkand light-shaded regions represent the 1σ and 2σ intervals.

C. Noisy models

22It may be the case that our observations are noisy, i.e. that observing the function at points x will yield y = f (x)+ϵ where ϵ is a random noise term.If we assume that ϵ is homoskedastic and Gaussian, then we can account for the noise by adding a constant noise variance σ 2 to the diagonal of the kernel K. 6

IV. ACQUISITION FUNCTIONS

23The acquisition function A(x) is a model of a given objective over possible inputs which, given a posterior p(f | x, y), quantifies the desirability of sampling a given input x.For each iteration of the optimization, we optimize the acquisition function over the inputs as

24Acquisition functions over posteriors are typically cheap to compute, and so classical algorithms (like LM-BFGS) are used to optimize them. 7Acquisition functions can be either analytic or non-analytic; below, we show benefits and examples of either approach.

A. Analytic acquisition functions

25Analytic acquisition functions are directly computable from the posterior; as the posterior for a GP is determined entirely by the mean µ and variance σ, they may be expressed as

26The simplest example is the expected mean

27where on every iteration the algorithm will sample the point with the largest expected mean.A less risk-averse example is the expected improvement

28which is our expectation for how much the cumulative maximum f ⋆ will increase if we were to sample x.We can compute this directly as

29where z = (µ(x) − f * )/σ(x), and ϕ(z) and Φ(z) are the PDF and CDF of the standard normal distribution.

30Because repeated sampling of a point will strictly decrease the posterior variance, this algorithm will (for wellbehaved problems) eventually explore every point in the parameter space.

B. Monte Carlo acquisition functions

31Some useful acquisition functions cannot be computed directly from the mean and variance of the posterior.Acquisition functions that involve sampling from the posterior to estimate some ensemble are more flexible and often more robust.One example of this is in selecting multiple points, as in when we want to find the best n points to sample given some analytic acquisition function A(x): presumably they should be spread out to better cover the parameter space, but there no obvious way to quantify and thus compute that analytically.We address this interdependence with a Monte Carlo acquisition function, where we might evaluate the acquisition of some collection of points by sampling from the posterior and taking an ensemble average of the result.There is a large benefit in sampling multiple points at once for beamline optimization, as it allows us to find a batch of points to sample and then optimally route the beamline parameters between them to reduce travel time.

32Note that all analytic acquisition functions have a Monte-Carlo equivalent; an example is shown in the farright panel of Figure 1, where we use the q-expected improvement as an acquisition function to find a parallel set of eight inputs to sample next. 8Monte Carlo methods also allow for more sophisticated information theory-based acquisition functions like Predictive Entropy Search [25], Maximum Entropy Search [26], or Joint Entropy Search [27].

C. Multiobjective optimization

33Optimization problems often require managing tradeoffs.For example, a common beamline design consists of a secondary-source aperture (SSA), which cuts off some flux in the interest of having a smaller and tighter beam.One method of multiobjective optimization is scalarization, which is to use a function that maps a vector output to a scalar output, leading to one quantity to be maximized.In this work, we use affine scalarizations (i.e.assigning a weight to each objective and summing them) to construct a single fitness function over which to optimize an acquisition function.

34There are, however, are other useful ways to carry out multiobjective optimization like Pareto efficient searches (i.e.finding the set of inputs where no one objective can be increased without decreasing some other objective).But while fully multiobjective methods do allow for more flexibility in the alignment, that flexibility is not compatible with an autonomous beamline, which must decide on a single best beam and thus must collapse the beam to a single fitness function.

V. BEAMLINE-SPECIFIC CONSIDERATIONS

35In this section, we consider beamline-specific considerations that improve the practical application of Bayesian optimization to the automated alignment problem.In this paper, we consider the common optimization problem of maximizing the beam power density, defined as

36where x represents the beamline inputs to optimize and where Φ(x), σ x (x), and σ y (x) are the input-dependent flux, horizontal spread, and vertical spread of the beam.These parameters are inferred from an image of the beam profile, taken using either an area detector (e.g.Figures 6 and 8) or a beam stop and microscope (e.g.Figures 5 and 9).In practice, it is better to model the fitness as

37because the distribution in variations in beam flux and size are both roughly log-normal, and so their logarithms are better described by a Gaussian process.It also preserves the convexity of the problem and, being inherently dimensionless, allows us to affinely scalarize many simultaneous objectives as a single Gaussian process.

A. A kernel for latent beamline dimensions

38Input parameters for beamlines can be highly coupled, as shown in Figure 3.In fitting Gaussian processes to beamline data, we adopt a kernel of the form

39where f (r) is some radial function, D is a diagonal matrix with positive entries, exp(•) is the matrix exponential, and S is a skew-symmetric matrix.Because the matrix exponential of a real skew-symmetric matrix is an orthogonal matrix, this kernel represents a norm-preserving transformation in the parameter space by exp(S) and a scaling of each dimension in the new basis by D. This kernel design is guaranteed to be positive-definite so long as f is a positive-definite function. 9A commonly used positive-definite function in kernel construction is the Matérn function, which can be written as

40where K ν (z) is the modified Bessel function of the second kind of order ν, and where a, ℓ, ν > 0 are hyperparameters.For our purposes, ℓ as a lengthscale parameter is redundant and can be subsumed into the hyperparameters defining T .This leaves us with a normalized form

41Bessel functions are expensive to compute for arbitrary ν, so we constrain our kernel to ν = n + 1/2, n ∈ Z, for which Equation 19 reduces to the product of a polynomial and an exponential.Unless otherwise specified, we use ν = 5/2 throughout the paper.

B. Dirichlet-based validity constraints

42The application of Bayesian optimization relies on reliable diagnostic feedback, which is often not a realistic assumption for real-life scenarios.Undesirable behavior in the diagnostics can occur both sporadically (e.g. in the case of a beam dump or a hardware failure) and also systematically (a certain beamline orientation causes the beam to miss a mirror or detector).We want to be able to classify regions of the parameter space as invalid and encode that knowledge into our acquisition function, but we don't want a single unrepresentative glitch to rule out an otherwise worthy part of the parameter space.For this purpose a probabilistic classification model is ideal, and it is also able to easily adjust expectation-and entropybased acquisition functions.

43We use the classification method outlined in [28] which fits a Dirichlet distribution to the data from which we can generate class probabilities.This method has the benefit of avoiding expensive posterior sampling (as in the case with stochastic variational methods) at the expense of not being able to quantify uncertainty.

44A Dirichlet distribution of order N is defined as

45where the vector parameter p = {p 1 , ..., p N } describes the probabilities of classes in a N − 1 simplex (so that i p i = 1), and the concentration parameters α = {α 1 , ..., α N } parameterize the concentration of the distribution in that simplex.We use transformed Gaussian processes to model the concentration parameter α i for each classification i according to [28].As the order-N Dirichlet distribution is the conjugate prior to the Ncategorical distribution, we can obtain the probability of a beamline input being valid as

46where Gamma(α, β) is the Gamma distribution, and γ i are samples from that distribution.Using this probability, we can weight any objective-based acquisition function to prefer inputs that lead to valid outputs.This approach has the added benefit of being generalizable to any number of classification labels, which could be made more nuanced than a binary model of validity.

C. Sampling expense

47Bayesian optimization is particularly useful when sampling the objective function f (x) is expensive.This is strictly true for some beamlines where computing a diagnostic is expensive, e.g.those that involve intensive data processing or a complicated metaroutine like a knife-edge scan [29].Many beamlines, though, have no latency in the diagnostics and are only expensive to sample because they are expensive to move around.This is due to the high precision of the motors, which must move slowly so as not to damage the optics, and need time to settle to prevent backlash and make sure that it is exactly at its setpoint; this is typically on the order of several seconds.

48A good acquisition function, then, should take into account travel time: a simple solution is to optimize a Monte Carlo acquisition function over a "batch" of points that we can compute the most efficient route between using e.g.https://github.com/google/or-tools. Ideally, the acquisition function would consider the variable time cost of traveling to a given set of points, but the computational cost of this can be unwieldy.

D. Hysteresis

49Another challenge to ML-based optimization is hysteresis, which manifests at beamlines when the actual position of some input varies from the desired input.This can happen when the motor approaches the same position from different directions, primarily from physical backlashes in the hardware.A core assumption of Bayesian optimization is that the relevant function f (x) always yields the same output (modulo some noise).Hysteresis can be mitigated by overestimating the noise level, or with a more thorough treatment of uncertainty in the inputs of the underlying Gaussian process [30].We note the benefit of motor encoders, which can lead to more precise and consistent control of beamline hardware.

E. Composite objectives

50Even though we combine estimates of the different beam attributes into a scalar fitness to maximize, it is still beneficial to construct and train three separate models for the flux, horizontal spread, and vertical spread, a method typically referred to as composite optimization.This allows us to take advantage of how different inputs affect different outputs; indeed, many beamlines are designed to separate components that tune the flux from those that tune the focus.This can significantly reduce the effective dimensionality of the alignment problem.Our beamline alignment tools are implemented in the Blop10 Python package, relying on the BoTorch Python package [31].In Blop we develop a customized kernel which fits to latent beamline dimensions outlined in Section V A, and weight common acquisition functions by the probabilistic constraint outlined in Section V B. We also use BoTorch for model fitting and acquisition function optimization.The algorithm is used in terms of an agent, which we instantiate with motors and diagnostic equipment.We can "tell" the agent about the values of pre-defined objectives (e.g.beam height, coherence) and "ask" it for new points to sample.The agent wraps the steps of Bayesian optimization in a single customizable routine (implemented in Python as a .learn()method), which yields a plan accepted by the Bluesky experiment orchestration system. 11This routine can be tailored to each beamline (or to each alignment problem for a given beamline).Encapsulating the optimization as a single process simplifies the alignment from the point of view of the user, making experimentation more accessible to users who have less familiarity with a given beamline (i.e.hardware, data acquisition, control systems), or with less familiarity with software in general.

B. Bluesky

51Bluesky [22,23] is a software package that allows for the orchestration and execution of experiments from Python, and is in the process of being adapted by various light sources. 12We design Blop with Bluesky in mind, as it can use Bluesky to automatically take data, analyze it, and optimize the inputs with the same feedback and control systems used for beamline experiments.This allows the Blop agent to both command and control the beamline, leading to an easier implementation. 13Bluesky has been mainly developed by NSLS-II, with a growing international collaboration at multiple facilities where it is used and expanded.The adoption of a single standard for experimental control and analysis across many facilities allows us to apply the same automated alignment tools with relatively little effort.The TES beamline [32] is a tender x-ray microspectroscopy beamline at NSLS-II with an energy range of 2-5.5 keV and a beam size which can be tuned between 5 and 20 microns.The x-rays are produced from a bending magnet source and pass through a Si(111) double crystal monochromator.A toroidal mirror prefocuses the beam onto a secondary source aperture (SSA), after which the beam is refocused onto the sample by a pair of Kirkpatrick-Baez (K-B) mirrors in the endstation chamber.A schematic of the beamline is represented in Figure 4. We optimize for the flux density on the sample by allowing each K-B mirror and the toroidal mirror to pitch and translate into and out of the beam for a total of six degrees of freedom.Figure 5 shows an example of the beam feedback provided by the camera, with the alignment being gradually improved.

B. Alignment of a Johann Spectrometer at the ISS beamline

52The Inner Shell Spectroscopy beamline (ISS, 8-ID) beamline [33] is a beamline for x-ray absorption spectroscopy and operando and in-situ characterization of materials.ISS is a damping wiggler beamline with a Si(111) monochromator capable of producing energies between 4.9 and 33 keV.Currently, the beamline is developing high-resolution capabilities with the recent commissioning of a five-analyzer Johann-type spectrometer, where after hitting the sample, the beam is reflected back onto an area detector by several crystals. 14Maximizing the flux on the area detector maximizes the resolution of the spectrometer, and so we seek to colocate the reflections of the crystals onto the same point.We use three crystals to focus the beam onto a two-dimensional area detector.Figure 6 shows the optimization of the threecrystal system.The photon transport system (Figure 7) comprises of a first focusing mirror, a monochromator and a few apertures.The focusing mirror is a vertically deflecting toroidal mirror, creating an image of the source at the sample.The mirror is gold-coated with a nominal grazing angle of 5 mrad, mirror-to-object (p) and mirror-to-image (q) distance of p = q = 12 m.The corresponding tangential and sagittal radius of curvature are respectively R t = 2400 m and R s = 60 mm.The mirror is bendable along the tangential direction to adjust the vertical focus position.The monochromator is a channel-cut double crystal Si(111) monochromator, providing a 25 mm vertical offset.There are a set of 4-jaw slits immediately after the monochromator to block the straight-through beam, and another set of 4-jaw slits immediately before the sample position (12 m downstream of the toroidal mirror).For beam measurement, we used a diamond-based xray beam monitor (ClearXCam from Advent Diamond) with which we computed the flux as the sum of all pixels.We added a preference for a rounder beam (with some coupling between horizontal and vertical size) by defining an "effective area" metric as:

53The full scalarized fitness for the effective power density then becomes

54The manual optimization is rendered difficult by the interplay between the toroidal mirror angle, monochromator height and angle, all of them changing the beam height and interfering with 4-jaw slits.With the use of the described automated alignment, we were able to maximize the power density on the sample in under five minutes, with a final beam size of 1 mm x 0.3 mm (HxV, FWHM), close to the theoretical limit calculated by raytracing (Figure 8) with an improvement of the intensity by over a factor of two over our best effort using manual alignment.

D. Alignment of an electron beam at the Accelerator Test Facility

55The Accelerator Test Facility (ATF) is a user facility at Brookhaven National Laboratory offering the combination of an 80 MeV electron beam synchronized with a Terawatt picosecond carbon dioxide laser [35].This gives it the capability to develop cutting-edge electron beam techniques including ultrafast electron diffraction and microscopy [36], as well as free-electron laser techniques including direct laser acceleration and using Compton scattering as a high energy x-ray source [37].We modulate three bending quadrupole electromagnets and a solenoid to manipulate the shape of the beam, for a total of four degrees of freedom.We employ the alternate fitness function in Equation 23 that was also used to align ATF. Figure 9 shows an example of the beam feedback provided by the inhouse beam diagnostic, with the alignment being gradually improved.

E. Simulated alignment of the TES beamline

56The use of most beamlines is extremely competitive, and benchmarking alignment methods by performing ensembles of different runs is too time-intensive to be viable.Instead, we use digital twins of beamlines using the Sirepo-Bluesky backend [38], allowing us to optimize the beam with the same Bluesky-based code used to align real beamlines.We use a ray tracing-based beamline simulation code called Shadow [14] to model beam propagation, which does not recreate diffraction effects but accurately recreates the behavior of the beam under misalignments.Even this heuristic method is slow, requiring several seconds per scan and thus many hours for comprehensive benchmarking; we note the development accelerated approximate models of beam propagation under misalignments, which would aid the efficient development of automated alignment tools [39].

57For benchmarking, we consider the digital twin of the TES beamline at NSLS-II.In the 8-dimensional case, we use the six degrees of freedom outlined in Section VII A, but also allow the toroidal mirror to yaw and translate horizontally for a total of eight degrees of freedom.Each K-B motor can move up to ± 0.25 mm from a fiducial starting point, while the range of each toroidal motor was bounded by the points where the misalignment of that motor caused the flux through the SSA to fall to 50% of the maximum.The results of this benchmark are shown in Figure 10.

58A simpler benchmark is shown in Figure 11, where the agent realigns the 4-dimensional K-B system under small misalignments (up to 0.05 mm) in each mirror's motors.

VIII. FURTHER DEVELOPMENT AND DISCUSSION

59We have applied the same automated alignment tools to several different facilities, and have shown that the same python package can effectively align a range of beamlines.Further refinement of these automated alignment tools will involve applying them to more beamlines at more facilities, with different flavors of optimization problems.How practical automated alignment can be necessitates an intuitive graphical user interface, from which the configuration of the optimizer is easy to understand.Further development also includes the implementation of new features and better performance in the software.The enabling of Pareto efficient optimization will give the beamline scientist more control over the beam quality, and making the agent take into account the traveling cost of moving the inputs into the acquisition function would allow for more informed optimization.We also plan to allow for a decentralized agent, which can run on a high-performance computing server and communicate with the control system using a streaming system like Kafka and feedback to the experiment control using Bluesky-Queueserver. 15 Fly-scanning, the strategy of sampling while moving parameters (instead of stopping and settling at each input), presents the potential to speed up beamline alignment, as the sampling expense at most beamlines comes from the accelerating and decelerating of components while varying parameters.This requires a very accurate synchronization between the feedback of inputs and outputs (another use of the motor encoders mentioned in Section V D), and is actively being developed at many light source facilities.

60We also note that the largest obstacle to applying automated alignment to existing beamlines is the difficulty in constructing robust feedbacks, as many beam diagnostics have non-negligible backgrounds or malfunctioning pixels.While an experienced beamline scientist is able to ignore and look past these artifacts, they may interfere with simpler methods of estimating beam flux, position and size from an image (e.g.computing the spread of a profile summed along one dimension).This is especially significant in the case of Bayesian optimization, which relies on accurate sampling of the true objective.This suggests the benefit of more sophisticated diagnostic methods, using machine learning techniques like image segmentation.

FIG. 1 :

61FIG. 1: An example of an iteration of a Bayesian optimization algorithm trying to maximize the negated Himmelblau's function f (x1, x2) = −(x 2 1 + x2 − 11) 2 − (x1 + x 2 2 − 7) 2 , whose true global optima are marked as white circles.Using existing data points (far left) and the assumption that the function is distributed as a Gaussian process, we can use Bayesian inference to compute a posterior consisting of a mean (center left) and error (center right), upon which we can compute an acquisition function (far right) which informs us of the best points to sample.The black-edged diamonds superimposed on the acquisition function show the best eight points to sample, optimized in parallel, and the optimal routing represented by the red line.

10 1 10 2 FIG. 3 :

62FIG. 3: Upper left: the result of changing the positions of two coupled dimensions of the TES beamline.Upper right: a quasi-random sample of 16 points from the ground truth.Lower left: a non-latent GP fitted to the parameter space fitted to the sampled points.Lower right: a latent GP fitted to the same points, which correctly infers the latent dimensions.

63The hyperparameters θ define the entries of D and S, which for an d-dimensional parameter space have d and d(d − 1)/2 degrees of freedom respectively, together defining a total transformation matrix T = D exp(S) with d(d + 1)/2 degrees of freedom.

64FIG.4:A schematic of the Tender-Energy X-ray Absorption Spectroscopy (TES, 8-BM) beamline at NSLS-II.This representation shows the many optical components that make up modern beamlines, with each optical component having many degrees of freedom that must be optimized in concert in order to carry out experiments effectively.

FIG. 5 :

65FIG. 5: Four different beams configurations at the National Synchrotron Light Source II's Tender Energy X-ray Absorption Spectroscopy (TES, 8-BM) beamline, where the upper left panel shows the initial beam and where the lower right represents the optimal alignment.In this alignment test, we adjust the translation and rotation of each of the horizontal and vertical Kirkpatrick-Baez mirrors and the pitch and vertical translation of a toroidal mirror, for a total of six degrees of freedom to maximize the flux density of the beam.

FIG. 6 :

66FIG. 6: Four different beam configurations at the National Synchrotron Light Source II's Inner Shell Spectroscopy (ISS, 8-ID) beamline during automated alignment, where the upper left panel shows the initial beam and the lower right panel represents the optimal alignment.In this alignment test, we adjust the translation of a central crystal and the translation and pitch of two ancillary crystals for a total of five degrees of freedom to maximize the flux density of the total beam on the area detector.

C

67. Photon transport optimization at the Advanced Light Source beamline 5.3.1 Beamline 5.3.1 at the Advanced Light Source at Lawrence Berkeley National Laboratory is a research and development beamline.It is a bending magnet beamline, operating in the tender x-ray regime (2.4-12 keV photon energy range.),where the instrument controls have recently been upgraded to the EPICS/Bluesky framework.

FIG. 7 :

68Photon beam

FIG. 8 :

69FIG. 8: Four different beam configurations at the Advanced Light Source's Beamline 5.3.1 during automated alignment.In total, the photon transport has four active degrees of freedom: the focusing mirror pitch and tangential bend, the channel cut crystal angle and height.The upper left panel shows the initial, manually aligned beam and the lower right the final beam after automated alignment.Upper right and lower left panels show intermediary points collected in the automated alignment process.

FIG. 9 :

70FIG.9: Four different electron beam configurations at the Brookhaven National Laboratory's Accelerator Test Facility (ATF) at different stages of automated alignment, where the upper left panel shows the starting beam and the lower right the optimal beam.In this alignment test, we tune the current of four quadrupole electromagnets to maximize the objective in Equation23.

71FIG.10:8-dimensional optimization of the simulated TES beamline, where the degrees of freedom comprise the toroidal and Kirkpatrick-Baez mirrors.The colors show different varieties of Bayesian optimization algorithms with and without both of latent inputs and composite outputs, with both the cumulative maximum of all individual runs (thin lines) and the median cumulative maximum (thick line).Each variety starts out with a quasi-random sampling of 32 points (shaded light blue), and then performs a Bayesian optimization loop with the expected improvement acquisition function.The benefit of using both latent inputs and composite outputs is shown, as we can achieve a better optimum more robustly and more quickly.

72FIG.11:The 4-dimensional optimization of just the K-B mirrors, whose motors are each misaligned by up 0.05 mm.After an initial quasi-random sample of 16 points (shaded light blue), the agent is able to almost instantly return to the optimal alignment.

참고문헌 24건

  1. General method for automatic on-line beamline optimization based on genetic algorithm Journal of Synchrotron Radiation · Wiley · 2015 10.1107/s1600577515001861
  2. Brookhaven National Laboratory's Accelerator Test Facility: research highlights and plans Plasma Physics and Controlled Fusion · IOP Publishing · 2014 10.1088/0741-3335/56/8/084017
  3. A microwiggler free-electron laser at the Brookhaven accelerator test facility Nuclear Instruments and Methods in Physics Research Section A Accelerators Spectrometers Detectors and Associated Equipment · Elsevier BV · 1990 10.1016/0168-9002(90)91216-x
  4. Design of the laser-driven RF electron gun for the BNL accelerator test facility IEEE Transactions on Electron Devices · Institute of Electrical and Electronics Engineers · 1988 10.1109/16.7427
  5. <i>SHADOW3</i>: a new version of the synchrotron X-ray optics modelling package Journal of Synchrotron Radiation · Wiley · 2011 10.1107/s0909049511026306
  6. Wavefront propagation simulations for beamlines and experiments with "Synchrotron Radiation Workshop" Journal of Physics Conference Series · IOP Publishing · 2013 10.1088/1742-6596/425/16/162001
  7. <i>AI-BL</i>1.0: a program for automatic on-line beamline optimization using the evolutionary algorithm Journal of Synchrotron Radiation · Wiley · 2016 10.1107/s1600577516018117
  8. ESRF: Inside the Extremely Brilliant Source Upgrade Synchrotron Radiation News · Taylor & Francis · 2018 10.1080/08940886.2018.1409562
  9. A New Light for Berkeley Lab—the Advanced Light Source Upgrade Synchrotron Radiation News · Taylor & Francis · 2019 10.1080/08940886.2019.1559608
  10. Knife-edge based measurement of the 4D transverse phase space of electron beams with picometer-scale emittance Physical Review Accelerators and Beams · American Physical Society · 2019 101103physrevaccelbeams22082801
  11. Bluesky's Ahead: A Multi-Facility Collaboration for an <i>a la Carte</i> Software Project for Data Acquisition and Management Synchrotron Radiation News · Taylor & Francis · 2019 10.1080/08940886.2019.1608121
  12. Bayesian Optimization of a Free-Electron Laser Physical Review Letters · American Physical Society · 2020 10.1103/physrevlett.124.124801
  13. The TES beamline (8-BM) at NSLS-II: tender-energy spatially resolved X-ray absorption spectroscopy and X-ray fluorescence imaging Journal of Synchrotron Radiation · Wiley · 2019 10.1107/s1600577519012761
  14. Knife-edge based measurement of the 4D transverse phase space of electron beams with picometer-scale emittance Physical Review Accelerators and Beams · American Physical Society · 2019 10.1103/physrevaccelbeams.22.082801
  15. An automated approach to the alignment of compound refractive lenses Journal of Synchrotron Radiation · Wiley · 2022 10.1107/s1600577522004039
  16. The Inner Shell Spectroscopy beamline at NSLS-II: a facility for in situ and operando X-ray absorption spectroscopy for materials research Journal of Synchrotron Radiation · Wiley · 2022 10.1107/s160057752200460x
  17. Multi-parameter Bayesian optimisation of laser-driven ion acceleration in particle-in-cell simulations New Journal of Physics · IOP Publishing · 2022 10.1088/1367-2630/ac7db4
  18. Robust Gaussian Process Regression With Input Uncertainty: A PAC-Bayes Perspective IEEE Transactions on Cybernetics · Institute of Electrical and Electronics Engineers · 2022 10.1109/tcyb.2022.3191022
  19. Multi-objective genetic algorithm for synchrotron radiation beamline optimization Journal of Synchrotron Radiation · Wiley · 2022 10.1107/s1600577522010050
  20. Next generation experimental data access at NSLS-II Journal of Physics Conference Series · IOP Publishing · 2022 10.1088/1742-6596/2380/1/012100
  21. Combining diagnostics, modeling, and control systems for automated alignment of the TES beamline Journal of Physics Conference Series · IOP Publishing · 2022 10.1088/1742-6596/2380/1/012103
  22. AutoFocus: AI-driven alignment of nanofocusing X-ray mirror systems Optics Express · Optica Publishing Group · 2023 10.1364/oe.505289
  23. Artificial Intelligence Driven Experiments at User Facilities Chapman and Hall/CRC eBooks · Informa · 2023 10.1201/9781003359593-8
  24. Five-analyzer Johann spectrometer for hard X-ray photon-in/photon-out spectroscopy at the Inner Shell Spectroscopy beamline at NSLS-II: design, alignment and data acquisition Journal of Synchrotron Radiation · Wiley · 2024 10.1107/s1600577524009342