Experience with a Virtual Multi-Slit Phase Space
Diagnostic at Fermilab’s FAST Facility
Auralee Edelen
SLAC National Accelerator Laboratory
AI@SLAC Seminar
27 August, 2018

Fermilab’s FAST Facility

to high energy line
and IOTA

fit to obtain
subset of phasespace parameters

The subject of this virtual diagnostic work

beam mask!"
!!′
! $"

screenMulti-slit phase space measurement takes 10-15 seconds
For studies, often want both an upstream and downstream measurement

Fermilab’s FAST Facility
Generally consistent machine configuration (changing settings only)

to high energy lineand IOTA

fit to obtain
subset of phasespace parameters

The subject of this virtual diagnostic work

beam mask!"!!′! $"

screenMulti-slit phase space measurement takes 10-15 seconds
For studies, often want both an upstream and downstream measurement
à can we get an online prediction of what the upstream intercepting diagnostic would show?

Virtual Diagnostics
Predict what the output of a diagnostic would look like when it is unavailable

Virtual Diagnostics
Predict what the output of a diagnostic would look like when it is unavailable
fast-executing physics-based simulation

measuredmachineinputsOnlineModel

Real-time prediction of beam characteristics or explicit
diagnostic output

Virtual Diagnostics
Predict what the output of a diagnostic would look like when it is unavailable
fast-executing physics-based simulation

measuredmachineinputsOnlineModel

Real-time prediction of beam characteristics or explicit
diagnostic output

e.g. GPU-accelerated
HPSim at LANSCE(based on PARMILA)
X. Pang, et al., PAC13, MOPMA13
X. Pang and L. Rybarcyk, CPC185, is. 3 (2014)
L. Rybarcyk, et al., IPAC15, MOPWI033
L. Rybarcyk, HB2016,WEPM4Y01

Virtual Diagnostics
Predict what the output of a diagnostic would look like when it is unavailable
fast-executing physics-based simulation

measuredmachine
inputsOnlineModel

Real-time prediction of beam characteristics or explicit
diagnostic output

e.g. GPU-accelerated
HPSim at LANSCE(based on PARMILA)
X. Pang, et al., PAC13, MOPMA13
X. Pang and L. Rybarcyk, CPC185, is. 3 (2014)
L. Rybarcyk, et al., IPAC15, MOPWI033
L. Rybarcyk, HB2016,WEPM4Y01

Challenges with this approach:
Execution often still isn’t so fast
Can require HPC resources
Still need a lot of work to getsimulation to match the machinecloselyAnother approach: machine learning modelOnce trained, neural networks can execute quickly

One approach: faster modeling codes

Train on data from slow, high-fidelity simulations+
Train on measured data

Simpler models (tradeoff with accuracy)
analytic calculations
e. g. J. Galambos, et al., HPPA5, 2007
Parallelization and GPU-acceleration of existing codes
HPSim/PARMILA
elegant

X. Pang, PAC13, MOPMA13
I.V. Pogorelov, et al., IPAC15, MOPMA035

Improvements to modeling algorithms
Lorentz-boosted frame

NN ModelJ.-L.Vay, Phys. Rev. Lett.98 (2007) 130405

Simulation+ Machine
An initial study at Fermilab:
A. L. Edelen, et al. NAPAC16, TUPOA51
One PARMELA run with 2-D space charge: ~ 20 minutes
Neural network model: ~ a millisecondVirtual Diagnostics
Predict what the output of a diagnostic would look like when it is unavailable
fast-executing physics-based simulation

measuredmachine
inputsOnline
Model

Real-time prediction of beam characteristics or explicitdiagnostic output
ML modelmeasuredmachineinputsOnlineModeldiagnostic
measurements

Virtual Diagnostics
Predict what the output of a diagnostic would look like when it is unavailable
fast-executing physics-based simulation

measuredmachineinputsOnlineModel

Real-time prediction of beam characteristics or explicit
diagnostic output
training
updatesmeasuredmachineinputsOnlineModeldiagnostic
measurements
diagnostic
prediction

Virtual Diagnostics
Predict what the output of a diagnostic would look like when it is unavailable
fast-executing physics-based simulation

measuredmachineinputsmeasuredmachineinputsOnlineModelOnline
ModelReal-time prediction of beam characteristics or explicit
diagnostic output

diagnostic
measurements
diagnostic
prediction

Real diagnostic no longer available:• moved to another location (e.g. cost constraints)• destructive, would interrupt normal ops• blocked for update time
But still have diagnostic prediction

The Low Energy Beamline at FAST
Generally consistent machine configuration (changing settings only)

to high energy lineand IOTA

fit to obtain
subset of phasespace parameters

The subject of this virtual diagnostic work

beam mask!"!!′! $"

screenMulti-slit phase space measurement takes 10-15 seconds
For studies, often want both an upstream and downstream measurement
à can we get an online prediction of what the upstream intercepting diagnostic would show?

Neural Network Model

subject of this virtual diagnostic work
Solenoid TheCurrent
Transverse Sigma Matrix
NeuralPhases (Gun, CC1, CC2)
Average Beam Energy
Network
Initial Bunch Properties(charge, length, εx,y , x-y corr.)

Transmission
εx,y αx,y βx,y— 600— 250— fully— tanhScanned Parameters on Machine
gun phase scanssolenoid current scans(with two different laser intensities)

fit to obtain
subset of phasespace parameters

gun phase scanssolenoid current scans(with two different laser intensities)

beam mask

beam maskother settingchangeslit mask and repeat for measurements
in x
OPAL
combinations!"
!!′
! $"

screenelegant+

full sigma
matrixsimulate gun to X107 in OPAL (space charge), the mask in python, and remainder in elegant

screeCould in principle use measured data alone, but want to be efficient with machine timeà use simulation data to fill in wider range of settings

fit to obtain
subset of phasespace parameters

gun phase scanssolenoid current scans(with two different laser intensities)

beam maskother setting
combinations

OPAL
cathode à CC2
with 3-D space charge routine!"
!!′
! $"

screenelegant+

full sigma
matrixsimulate gun to X107 in OPAL (space charge), the mask in python, and remainder in elegant

Training on physics model . . . NN will only be as accurate as the physics model

Poor agreement between simulation andmeasured data for some input/output
relationships

à can we update the NN model withmeasured data without disrupting the otherpredictions?

Physics-based
simulation had poor
agreement withmeasurements

Physics-based
simulation had
good agreementwith measurements

Updated with Measured Data
Trained on Simulation Only

Solenoid Scan
Phase Scan

Trained on Simulation Only

Phase Scan

Updated with Measured Data

Solenoid Scan

Why bother with simulation? à Rough initial solution facilitates training with small amount of measured data

But that still relies on the slit fits…
• Fitting procedure changes (e.g. how image is processed, alignment) à need to re-train• Non-ideal beam à poor slit fitsPredicting Image Output DirectlySimulated

NN Predictions

A. L. Edelen, et al. IPAC18, WEPAF040

Difference

Work with J. Edelen, D. Edstrom, A. Halavanau, J. Ruan, P. Piot, A. RomanovBigger Picture for FAST

Earlier work: account for changes in laser spot
A. L. Edelen, et al. NAPAC16, TUPOA51(E)

Fast-executing, accurate machine model
Online:faster machine studies + online optimization

Offline:study planningdownstream component design
controller training(εnx , εny)
(βx , βy)(αx , αy)(Np)

NN-based round-to-flat beam transformOne piece of a larger set of studies:• Accounting for laser spot changes• NN controller (e.g. round-to-flat beam transform)• Final aim would be to combine these

Initial Sigma Matrix
or upstream settings
Desired Sigma Matrix

Q118
NeuralNetwork

Q119
Q120

to high enerand IOT

Lots of interesting work now at SLAC along these lines …

Virtual Diagnostics•

Used archived data to learn correlation between fast and slowdiagnostics•

Looked at a variety of ML methods and different diagnostics

A. Sanchez-Gonzalez, et al. https://arxiv.org/pdf/1610.03378.pdf

Longitudinal Phase Space Prediction for FACET-II and LCLS••

Simulation + NN results match well for FACET-II (see left)
Small proof-of-principle study with LCLS machine data and XTCAV images (see below)

Figures courtesy C. Emma
Emma, Edelen, et al. in preparation

Computer Vision + Neural Network-based Control Policies• Image diagnostics à nice to use directly, and some yield relatively complicated informationC. Behrens, et al., Nat. Commun. 5, 3762 (2014)

D. Ratner, et al., PRSTAB18, 030704 (2015)

A. Marinelli, et al., Nat. Commun. 6, 6369 (2015)• Neural Networks à very good for image processing + can learn control policies from data

Could use image-based diagnostics directly in learned control policies to switch
quickly between requested operating conditions, including to different target phasespace images from the XTCAVWork with C. Emma, A. Scheinker, D. Bohler, A. Lutman

Use neural network as a warm start for a standard optimizer• The Extremum Seeking (ES) algorithm has beenused successfully for particle accelerator tuning• ES can get stuck in local minima and takes

awhile to converge• Given some desired beam characteristics, a NN

can provide initial settings
à fewer iterations of ES then needed to converge(see A.L. Edelen et al., FEL ’17 for a simple NN control policy example)

Figure: Alex Scheinker

Work with C. Emma, A. Scheinker, D. Bohler, A. Lutman

Preliminary Results• Conducted scan of L1S phase and BC2 peak current à trained NN• Used NN to give suggested settings based on a new target XTCAV image,starting from far away
• ES alone unable to converge in this case, but able to converge with suggested settingsfrom NN

Figures: Alex Scheinker

Work with C. Emma, A. Scheinker, D. Bohler, A. Lutman

Preliminary Results• Conducted scan of L1S phase and BC2 peak current à trained NN• Used NN to give suggested settings based on a new target XTCAV image,

starting from far away
• ES alone unable to converge in this case, but able to converge with suggested settingsfrom NN

Figures: Alex Scheinker

Conclusions + Outlook• Virtual diagnostics using MLà potentially useful both for prediction and control when physical diagnostics
have some limitations to their use (e.g. destructive measurement, too slow to update)à limitations need to be more fully explored (e.g. sensitivity to machine drift, upstream errors)• Good preliminary results + experience from transverse phase space diagnostic at FAST
• Previous demonstration at SLAC using quickly-updating diagnostics to predict measurements

derived from slow diagnostics• Ongoing work at SLAC (FACET-II and LCLS) to rigorously demonstrate in operation for

longitudinal phase space prediction, as well as to facilitate control