Introduction to normalizing flows
for lattice field theory
Dan Hackett (MIT)March 15, 2023

Dan Hackett - 2023 Mar 15

1About Me

Undergrad: University of Virginia (UVA)

Dan from here

Stony Brookxx

x

BNLNYC
PhD: University of Colorado Boulder

Postdoc (present): MIT
Dan’s house
Dan’s officeDan’s office(former)
Dan Hackett - 2023 Mar 152

Machine learning?

Can we use black boxes
to do lattice field theory?
Yes, but must be careful!

Dan Hackett - 2023 Mar 15

3

Outline• Lattice field theory• Machine learning• Generative models (for LQFT)• Example: affine coupling flow (RealNVP)• The road to QCD• Symmetries and equivariance• Closing thoughts

Dan Hackett - 2023 Mar 15

4

References
Based on 2101.08176
Tutorial Jupyter notebook!
.ipynb link

See also: GomalizingFlow.jl
by Satoshi Terasaki, Akio Tomiya
GitHub link

Dan Hackett - 2023 Mar 15

5

Lattice field theory

Dan Hackett - 2023 Mar 15

6

Lattice field theory (is just integration)
Want to compute:

𝒪 = # 𝑑𝜙𝑒!"($)

𝑍𝒪(𝜙)𝑒 !" #𝑝 𝜙 =𝑍”Probability of 𝜙”

Dan Hackett - 2023 Mar 157

Example: 2D 𝜙 ! theory1𝑆 𝜙 ='' 𝜙 𝐱 + 𝜇, − 𝜙 𝐱2𝐱%∈',)∼ 𝜕% 𝜙**1 *+ 𝑚 𝜙 𝐱 * + 𝜆𝜙 𝐱 +2
Potential 𝑉[𝜙]𝜙 𝐱 ∼ monochromatic images

Dan Hackett - 2023 Mar 15

8

Lattice field theory with Monte Carlo
Monte Carloestimate)1
𝒪 = # 𝑑𝜙 𝑝(𝜙) 𝒪(𝜙) ≈ . 𝒪(𝜙& )𝑁&'(𝜙" ∼ 𝑝

Examples:Magnetization:!
𝒪 = 𝜙. = ! ∑𝒙 𝜙(𝒙)"2-point correlator / propagator / Green’s function:
𝒪 = 𝐺 𝐱, 𝐲 = 𝜙 𝒙 𝜙(𝒚)Dan Hackett - 2023 Mar 15

Average overconfigurations
sampled from 𝑝9Problem: MCMC autocorrelations
Markov chain Monte Carlo (MCMC)
samples are not independent
More autocorrelations↔ Less precise estimates
Better algorithms→ More precision with availablecomputers

Dan Hackett - 2023 Mar 15

10Machine learning

Dan Hackett - 2023 Mar 15

11

Neural networks are just functions

𝑓: ℝ → ℝ

NN w/ ReLU activations= piecewise linear function

Dan Hackett - 2023 Mar 15

12

Neural networks are just functions
𝑓(𝑥$ , 𝑥# )𝑓: ℝ# → ℝ

Dan Hackett - 2023 Mar 15

13

Generative models for LQFT

Dan Hackett - 2023 Mar 15

14

Mapping between distributions
Using a function to transform samples from a distribution gives
samples from another distribution𝑥from “base” dist

Dan Hackett - 2023 Mar 15𝑓(𝑥)from “model” dist15

Mapping between distributions𝑥

Dan Hackett - 2023 Mar 15𝑓(𝑥)16Mapping between distributions

Dan Hackett - 2023 Mar 15

17

Generative models for image generation?
𝜙 ∼ distributionof dog pictures𝑧 ∼ Gaussian noise
NN transforms noise
𝜙 = 𝑓(𝑧)Dan Hackett - 2023 Mar 15

18

Generative models for LQFT sampling?
𝑧 ∼ Gaussian noise𝜙 ∼ model for distributionof lattice fields
1 !"($)𝑞≈ 𝑒𝑍

NN transforms noise
𝜙 = 𝑓(𝑧)Dan Hackett - 2023 Mar 15

19

Physics according to DALL-E 2
What does a proton look like?

Cool!
…but we don’t learn any physics
The interior of a proton

Dan Hackett - 2023 Mar 15

Better models don’t help:
Stable Diffusion, Midjourney,
etc still won’t teach us physics

20Requirements for exactness:
Must be able to compute model density 𝑞)

𝑝 𝜙
1
𝒪 = # 𝑑𝜙 𝑞 𝜙𝒪(𝜙) ≈ . 𝑤 𝜙& 𝒪 𝜙&𝑞(𝜙)𝑁&'(𝜙" ∼ 𝑞
Reweighting factors
𝑝 𝜙𝑤 𝜙 ≡𝑞 𝜙

Dan Hackett - 2023 Mar 15Reweighted averageover configurations
sampled from the “model” 𝑞21Normalizing flow models
Simple base distribution 𝑟• Tractable 𝑟(𝑧)• 𝑟 𝑧 >0• Easy to sample

Learned model distribution 𝑞
𝜕𝜙 !&𝑞 𝜙 = det𝑟(𝑧)
𝜕𝑧
𝑞(𝜙)

𝑟(𝑧)

”Flow” transformation• Invertible• Tractable Jacobian determinant• Parametrized by NNs
Dan Hackett - 2023 Mar 1522

Need for invertibility𝑟𝑧'𝑞𝑥=𝑓 (𝑧')𝑥𝑧)

Dan Hackett - 2023 Mar 15)𝑧(𝑓)=𝑥Non-invertible map:
To compute 𝑞(𝑥), must know all 𝑧
such that 𝑓 𝑧 = 𝑥Intractable search problem!

23

Strategy: “coupling layers”
Composition: build flow by stacking many simple sub-transformations𝑞(𝜙)Variable partitioning:• Freeze some variables• Update others (active vars)…independently…conditioned on frozen vars

Dan Hackett - 2023 Mar 15

𝜙==+Active𝜙'

Frozen𝜙(24Example: affine coupling flow(RealNVP)Dan Hackett - 2023 Mar 1525

Affine coupling transformation (2 variables)
Draw 𝜙! and 𝜙" from 2d Gaussian𝑟 𝜙! , 𝜙"!
"% &#"'&!"=𝑒 "#$Freeze 𝜙" , update 𝜙!
𝜙"( = 𝜙"𝜙!( = 𝑒 )(&!) 𝜙! + 𝑡(𝜙" )→ triangular Jacobian)(&!)
𝜕(𝜙!( , 𝜙"( )𝑒𝐽==
𝜕(𝜙! , 𝜙" )0𝜕𝜙!( ⁄𝜕𝜙"1⇒

det 𝐽 = 𝑒 )(&!)⇒ Model density: 𝑞 𝜙!( , 𝜙"( = 𝑒 %) &! 𝑟(𝜙! , 𝜙" )Dan Hackett - 2023 Mar 1526

Affine coupling transformation is invertible
Invertible by construction:𝑟

Dan Hackett - 2023 Mar 15𝜙)* = 𝑒 +($! ) 𝜙) + 𝑡(𝜙&)𝜙&* = 𝜙&𝜙) = 𝑒 !+ $! 𝜙)* − 𝑡 𝜙&
𝜙& = 𝜙&*𝑞27

Affine coupling (scalar field theory)
For scalar field 𝜙𝐱 on sites 𝐱Partition by site into 𝐱' , 𝐱 (Transform as 𝜙𝐱* " = 𝜙𝐱"

𝜙==

𝜙𝐱* # = 𝑒 + $" 𝐱 # 𝜙𝐱# + 𝑡 𝜙( 𝐱#+Active
𝜙𝐗 %Frozen
𝜙𝐗 &Triangular Jacobian:…
𝜕(𝜙𝐱* # , 𝜙𝐱* " )𝐽==
𝜕(𝜙𝐲# , 𝜙𝐲" )𝑒 + $" 𝐱 #(nonzero)
…

0

1

⇒

det 𝐽 = D 𝑒 7 #" 𝐱!
𝐱!

…
1Dan Hackett - 2023 Mar 1528

Machine-learned flows
Model: stack layers, alternating which variables are updated
Independent 𝑠, 𝑡 in each layer𝑞(𝜙)Model quality: need 𝑞 ≈ 𝑝, or reweighting is very noisy→ Use NNs for 𝑠, 𝑡 (expressive!)→ Train NNs

Dan Hackett - 2023 Mar 1529(Reverse KL) self-training
1. Draw a batch 𝜙8 ∼ 𝑞
2. Compute 𝑝(𝜙8 ), 𝑞(𝜙8 )3. Minimize “reverse” KL divergence

Reverse KL self-training with Adam
optimizer (batch size 16384):𝑞 𝜙
𝐷12 (𝑞| 𝑝 = E 𝑑𝜙 𝑞 𝜙 log
𝑝 𝜙3ESS

1𝑞 𝜙3≈ J log
𝑁𝑝(𝜙3 )

Model quality improves

ESS = “effective sample size
per configuration”

Kullback-Leibler (KL) divergence
𝐷$" (𝑞| 𝑝 ≥ 0
𝐷$" (𝑞| 𝑝 = 0 when 𝑞 = 𝑝

Dan Hackett - 2023 Mar 15

Training step (epoch)
30

The road to QCD

Dan Hackett - 2023 Mar 1531

Progress to date (just my group)

Result: Improved sampling in (1+1)d U(1) gauge theory

Flows for LQFT (scalar field theories)[Albergo, Kanwar, Shanahan 1904.12072][DH, Hsieh, Albergo, Boyda, JW Chen, KF Chen, Cranmer, Kanwar,
Shananan 2107.00734]

Gauge-equivariant flows

U(1) [Kanwar, Albergo, Boyda, Cranmer, DH, Racanière, Rezende,Shanahan 2003.06413]
SU(N) [Kanwar, Albergo, Boyda, Cranmer, DH, Racanière, Rezende,
Shanahan 2003.06413]

Flows for fermionic theories
Yukawa model [Albergo, Kanwar, Racanière, Rezende, Urban, Boyda,Cranmer, DH, Shanahan 2106.05934]

Schwinger model [Albergo, Boyda, Cranmer, DH, Kanwar, Racanière,Rezende, Romero-López, Shanahan, Urban 2202.11712]

Schwinger with pseudofermions [Abbott, Albergo, Boyda,Cranmer, DH, Kanwar, Racanière, Rezende, Romero-López, Shanahan, Tian,Urban 2207.08945]

QCD!

Early demonstration [Abbott, Albergo, Botev, Boyda, Cranmer, DH,Kanwar, Matthews, Racanière, Razavi, Rezende, Romero-López, Shanahan,Urban 2208.03832]

Dan Hackett - 2023 Mar 1532Flows on compact variables
U(1): phases (live on circles)
SU(𝑁): Lie group manifoldp(Pµν )

p(Pµν )

Pµν

Pµν

!
p(Pµν)

?

!
Pµν

!
!
.P(x) = h(Pµν (x)|I(x)).Pµν (x) = h(Pµνµν(x)|I(x))

Base distribution: Haar uniform
Flows on circles and torii

frozenfrozen▶︎

▶︎

▶︎

▶︎

▶︎

▶︎

▶︎

▶︎▶︎

▶︎

▶︎

Dan Hackett - 2023 Mar 15x̃ x▶︎x̃▶︎[Kanwar, Albergo, Boyda, Cranmer, DH, Racanière,Rezende, Shanahan 2003.06413]

I1 (x)I2 (x)▶︎

updateFlow eigenvalue
spectrum
passive
update passive
activeupdate active updatefrozen▶︎▶︎▶︎▶︎▶︎▶︎▶︎

Flows on SU(N) variables

I (x)

▶︎

[Rezende, Papamakarios, Racanière, Albergo, Kanwar,Shanahan, Cranmer 2002.02428]!
!
!
!
P(x)→P(x)(x̃)µν(x)→P(x)Pµν (x̃)→Pµν(x̃)PµνP(x̃)→Pµν µνµν
1µν▶︎▶︎▶︎▶︎▶︎▶︎▶︎▶︎

splines, …▶︎
Non-compact projections,▶︎x33• Training or increasing model size provides
diminishing returns• Need more qualitative algorithm
improvements
Ex: different base distributions for 𝜙 + models

ESS

Need physics-informed ML

Training step (epoch)

Independent Gaussians on e/a site
Free field theory

Incorporating physics → better model!

Model depth (# layers)
Dan Hackett - 2023 Mar 1534

Symmetries and equivariance

Dan Hackett - 2023 Mar 1535

Symmetry
Invariance under 𝑈 → 𝑔(𝑈) ⇔Invariant model:
1. Invariant base
2. Equivariant flow𝑝 𝑔(𝑈) = 𝑝 𝜙𝑟 𝑔(𝑈) = 𝑟 𝑈
𝑓 𝑔(𝑈) = 𝑔(𝑓 𝑈 )DensityDensityDensityi.e. flow commutes with symmetry

InG
vaa
riaungt e(phinysvicas)riantegugaytreerum

PSymNon-invariant model must learnsymmetry
Dan Hackett - 2023 Mar approximate
15InG
vaariuangte(pihnysvicas)riantegu
grayetemr
PSyum

Invariant model has exact
symmetry built in36

Discrete example: global 𝑍! in 𝜙 " theory
1𝑆 𝜙 ='' 𝜙 𝐱 + 𝜇, − 𝜙 𝐱2𝐱%∈',)*1 *+ 𝑚 𝜙 𝐱 * + 𝜆𝜙 𝐱 +2Magnetization in 𝒁𝟐 -broken phase

Symmetric under 𝜙 → −𝜙
𝑆 𝜙 = 𝑆 −𝜙 ⇔ 𝑝 𝜙 = 𝑝 −𝜙
How to model?

Dan Hackett - 2023 Mar 1537

Example: global 𝑍! in 𝜙 " theory
Ex1: Restrict NN architectures
𝜙@A = 𝑒 7(#") 𝜙@ + 𝑡(𝜙B )but: 𝑠 −𝜙B = 𝑠(𝜙B )𝑡 −𝜙B = −𝑡 𝜙B
No bias in linear terms
Odd/even activations

Check:
𝑒 +(!$" ) −𝜙' + 𝑡 −𝜙(= −𝑒 +($" ) 𝜙' − 𝑡 𝜙(= −𝜙'*[Nicoli et al. 2007.07115] [Del Debbio et al. 2105.12481]

Ex2: 𝑍* -symmetrized self-mixture

Apply random sign after flow: 𝜙 = ±𝑓(𝑧)⇒ 𝑞789 𝜙&= : (𝑞 𝜙+ 𝑞 −𝜙 )[DH, Hsieh, Albergo, Boyda, JW Chen, KF Chen,Cranmer, Kanwar, Shananan 2107.00734]
Dan Hackett - 2023 Mar 1538

[Images from freecodecamp.org]

Example: translation symmetry
Translations commute with convolutions

Invariant model:
1. Invariant base: same for each site
2. Equivariant flow: parametrize w/ CNNS
OutputInput (w/ periodic BCs)Dan Hackett - 2023 Mar 1539

Lattice gauge symmetry𝑈; (𝑥)𝑥𝑥+𝜇𝜈

𝑈% 𝑥 → ΩC (𝑥 + 𝜇) 𝑈% 𝑥 Ω(𝑥)…with 𝑈; 𝑥 , Ω 𝑥 ∈ 𝑆𝑈(3)𝜇𝑥

𝑃%G 𝑥 = 𝑈% 𝑥⃗ 𝑈G 𝑥⃗ + 𝜇, 𝑈%C 𝑥⃗ + 𝜈̂ 𝑈GC (𝑥)⃗𝑃%G 𝑥 → ΩC 𝑥 𝑃%G 𝑥 Ω(𝑥)Tr 𝑃%G 𝑥 → Tr 𝑃%G (𝑥)Dan Hackett - 2023 Mar 1540

Gauge equivariant flows
In general:
𝑈% 𝑥 → 𝑈%A 𝑥 = 𝑓 𝑈% (𝑥)𝑈; (𝑥)𝑥𝑥+𝜇

Want:
𝑈%A 𝑥 → ΩC (𝑥 + 𝜇) 𝑈%A 𝑥 Ω(𝑥)⇒ Must construct 𝑓 such that:𝑓 ΩC 𝑈Ω % 𝑥 = ΩC 𝑥 + 𝜇 𝑓 𝑈 % 𝑥 Ω(𝑥)𝑈; 𝑥 → Ω< (𝑥 + 𝜇) 𝑈; 𝑥 Ω(𝑥)No unique way!
See tutorial notebook for one example: 2101.08176

Dan Hackett - 2023 Mar 1541

Many gauge equivariant architectures developed already• Gauge equivariant CNNs (parallel transport)[Favoni, Ipp, Müller, Schuh 2012.12901][Abbott, Albergo, Boyda, Cranmer, DH, Kanwar, Racanière,Rezende, Romero-López, Shanahan, Tian, Urban 2207.08945][Lehner, Wettig 2302.05419]• Gradient flows w/ learned potentials[Bacchio, Kessel, Schaefer, Vaitl 2212.08469]• Learned smearing[Tomiya, Nagai 2103.11965] “Gauge covariant neuralnetwork for 4 dimensional non-abelian gauge theory”

Not competing options:can be combined!

• Spectral flows
U(1) [Kanwar, Albergo, Boyda, Cranmer, DH, Racanière,Rezende, Shanahan 2003.06413]
SU(N) [Boyda, Kanwar, Racanière, Rezende, Albergo,Cranmer, Hackett, Shanahan 2008.05456]
Dan Hackett - 2023 Mar 1542

Closing thoughts
Flows are a promising new approach to LQFT configuration generation
Provably exact physics with ML
Different properties from traditional sampling algorithms
Early results suggest qualitative advantage in some cases

On the way to QCD, but work remains
Model architectures and training schemes are not unique
Lots of ML engineering required, especially to scale up

Many other sampling approaches to explore
e.g. alternating flow and traditional updates → complementarity
e.g. accelerating traditional algos with ML

Only beginning to explore what is possible!

Dan Hackett - 2023 Mar 1543