Deformations of Boltzmann Distributions
Bálint Máté
University of Geneva
balint.mate@unige.ch

François Fleuret
University of Geneva
francois.fleuret@unige.ch

Abstract
Consider a one-parameter family of Boltzmann distributions pt (x) = Z1t e−St (x) .
This work studies the problem of sampling from pt0 by first sampling from pt1
and then applying a transformation Ψtt01 so that the transformed samples follow pt0 .
We derive an equation relating Ψ and the corresponding family of unnormalized
log-likelihoods St . The utility of this idea is demonstrated on the ϕ4 lattice field
theory by extending its defining action S0 to a family of actions St and finding a τsuch that normalizing flows perform better at learning the Boltzmann distributionpτ than at learning p0 .

1

Introduction

Sampling from unnormalized densities has been studied by many due to its relevance for the sciences[1–11]. The problem can be summarized as follows. Given an unnormalized log-density S : Rn → R
can we efficiently generate samples from the probability density p(x) = Z1 e−S(x) ? In particular,
there are no samples given, all we have is the ability to evaluate S for any sample candidate. A
popular technique for attacking this problem is to use a normalizing flow to parametrise a distributionqθ and optimize the parameters θ to minimize the reverse KL divergenceKL[qθ , p] = Ex∼qθ (log qθ (x) − log p(x)) = Ex∼qθ (log qθ (x) + S(x)) + Z.

(1)

As a motivating example for this paper, let S be the defining action of the lattice ϕ4 theory (See §4
for details), and consider the family of distributions pβ (x) ∝ e−βS(x) parametrized by β ∈ R+ . In
terms of statistical physics β corresponds to the inverse temperature and controls how ordered thegiven system is. As seen in Fig. 1 the performance of a normalizing flow is sensitive to the parameterβ. Continuous normalizing flows converge faster at higher temperatures. Somewhat surprisingly,
the RealNVP architecture converges faster both at β = .1 and β = 10 than at β = 1. A possible
explanation is that both the smoother distribution (β = 0.1) and the more localized (β = 10) is easierto learn than a combination of these characteristics at β = 1.
Motivated by this observation, this paper studies the following problem. Suppose we are given afamily of actions St (x), parametrised by t, inducing a family of distributions, pt (x) ∝ e−St (x) .
We are interested in how these distributions are related for different values of t. From a practical
viewpoint, the goal is to sample from pt2 by first sampling from pt1 and making the samples flow
along some vector field Vt . We will refer to this Vt as the deformation field or transport field.
The contributions of this paper can be summarized as:• In §3 we derive a PDE, the deformation equation, that translates between infinitesimal
deformations of actions and the infinitesimal deformations of the Boltzmann distributions
they induce.
• In §4 we put the theory into practice in the case of a simple deformation of the lattice ϕ4theory and show that it improves the performance of normalizing flows.
Machine Learning and the Physical Sciences workshop, NeurIPS 2022.

1.0

1.0

0.8
= 0.1
=1
= 10

0.6
0.4

ESS

ESS

0.8

0.4

= 0.1
=1
= 10

0.2

0.2

0.0

0.0
0

2000

4000

6000

8000

10000

0

1.0

MCMC acceptance rate

MCMC acceptance rate

0.6

0.8
= 0.1
=1
= 10

0.6
0.4
0.2
0.0
0

2000

4000

6000

8000

10000

20000

30000

40000

0.8
0.6
0.4

= 0.1
=1
= 10

0.2
0.0

10000

0

10000

20000

30000

40000

Figure 1: Sensitivity of the training to the inverse temperature β on a 12 × 12 lattice. We trained
the continous normalizing flow of Gerdes et al. [7] (left) and a RealNVP (right). In both cases weused the action of the ϕ4 theory with different values of β ∈ {0.1, 1, 10} and with m2 and λ values
same as in the work of Gerdes et al. [7]. The x-axis represents the number of training steps, while they-axis represents the performance metrics. Mean and standard deviation over 5 runs are shown.

N(0, 1)

4

4

4

3

3

3

2

2

2

1

1

1

0

0

0

1

1

1

2

2

2

3

3

3

4

4

4

3

2

1

0

1

S1 = 12 x2

2

3

4

4

3

2

1

0

Vt(x) =

1

2

3

4

4

N(0, 1/t)

4

3

x
2t

2

1

0

1

2

3

4

St = t 12 x2

Figure 2: Deformation of a two-dimensional standard Gaussian into a family of isotropic Gaussians
with different variances. Samples from a two-dimensional standard Gaussian (left). The deformation
field (center). The samples in the left plot flowing along the deformation field from 1 to t follow a
Gaussian centered at the origin with covariance 1/t (right).

2

Background

Change of variables Let p0 (z) be a probability density on Rn and Ψ : Rn → Rn a diffeomorphism.
Pushing the the density forward along Ψ induces a new probability density p implicitly defined bylog p0 (z) = log p(Ψz) + log | det JΨ (z)|.

(2)

The term log | det JΨ (z)| measures how much the function Ψ expands volume locally at z.
Continous change of variables Suppose Vt is a time-dependent vector field. Let Ψτ denote thediffeomorphism of following the trajectories of Vt from 0 to τ . This family of diffeomorphisms
generates a one-parameter family of densitiespτ . The amount of volume expansion a particle
Rτ
experiences along this trajectory of Ψτ is 0 div Vt (Ψt z)dt. The log-likelihoods are then related byZ τlog p0 (z) = log pτ (Ψτ z) +div Vt (Ψt z)dt.
(3)
0

2

Normalizing flows Normalizing flows[12–15] (continous normalizing flows [16], respectively)
parametrize a subset of the space of all distributions on Rn . They do this by first fixing a basedensity p0 and using a neural network that parametrizes the transformation Ψ (the vector field Vt ,respectively). The change of variables formula in Eq. 2 (Eq. 3, respectively) is then applied tocompute the distribution induced by Ψ (Vt , respectively).
Performance metrics To evaluate the performance of normalizing flows, we employ the following
two metrics. First, let qθ be the distribution parametrized by a normalizing flow and p ∝ e−S thetarget distribution. Given a batch of samples xi , the effective sample size can be computed as
2
P1
i p[xi ]/qθ [xi ]N
ESS = 1 P.
(4)
2
i (p[xi ]/qθ [xi ])N
We now think of the samples as being generated sequentially in a MCMC manner. We always accept
the first sample x0 , and each of the following samples are accepted with probabilityqθ [xi−1 ] p[xi ]paccept (xi |xi−1 ) = min 1,.
(5)p[xi−1 ] qθ [xi ]Note that all ratios p[x]/qθ [x] are invariant to change of coordinates because both the numerator anddenominator get multiplied with determinant of the same Jacobian. This in turn implies that both the
ESS and the MCMC acceptance probability are invariant under a change of coordinates.
Boltzmann
Let S : Rn → R be a function with a finite normalizing constant
R −S(x)distributionsn
Z= ed x. Physically speaking, S might be the action of some physical theory or the energy
associated to configurations of some system. Either way, S induces a Boltzmann distribution over theconfigurations x ∈ Rn1p(x) = e−S(x) .
(6)
Z
Conversely, given a probability density function p : Rn → R+,0 the corresponding action can berecovered up to a constant S = − log p − log Z and Eqs. 2 and 3 can be interpreted as equations
relating (the actions and normalizing constants of) two physical theories over the same configuration
space.

3

The deformation equation

In what follows, we will use the symbols ∂t f and ∇f to denote the derivatives with respect to thetime parameter and the gradient over the remaining n, spatial components of a time-dependent scalarvalued function f : R × Rn → R.
The Boltzmann distribution of Eq. 6 can be equivalently defined by setting the ratios of likelihoods
between all x and y top(x)= eS(y)−S(x) .
(7)p(y)
Our aim is then to construct the time-dependent vector field Vt such that flowing along Vt from t1 to
t2 transforms between the two densities
pt1 (x) = pt2 (Ψtt21 x)LΨt2 (x),

(8)

t1

where Ψtt21 denotes the operation of "flowing along Vt from t1 to t2 " and LΨt2 is the likelihood
t1

contribution of Ψtt21 . In terms of Eq. 7, we are looking for Ψ such that for any pair of x, y we havept1 (x)pt (Ψx) LΨ (x)= 2,
pt1 (y)pt2 (Ψy) LΨ (y)(9)

where we dropped the indices from Ψ for readability. For Boltzmann distributions, this expression isequivalent toLΨ (x)
eSt1 (y)−St1 (x) = eSt2 (Ψy)−St2 (Ψx).
(10)
LΨ (y)
3

Taking the logarithm and rearranging
St1 (x) − St2 (Ψx) + log LΨ (x) = St1 (y) − St2 (Ψy) + log LΨ (y).

(11)

This is satisfied if and only if the expression (with reinserted indices on Ψ)
ftt12 (x) = St1 (x) − St2 (Ψtt21 x) + log LΨt2 (x),

(12)

t1

is independent of x. Which happens if and only if ∇ftt12 (x) vanishes for all x, t1 , t2 . We now
construct the vector field Vt , the infinitesimal generator of Ψ. Expanding ∇ftt12 in t2 at t1 up to firstorder yields∇ftt12 (x) = ∇ftt12 (x)δt + O(δt2 )+ ∂t2 ∇ ftt12 (x)
|
{z
}
t =t
t2 =t1{z 2 }1 ∇∂t2

|

(13)

0


= ∇ −∂t St1 (x) − St1 (∂t2 Ψtt21 x) + div V (x)δt + O(δt2 )



(14)

t2 =t1= ∇ [−∂t St1 (x) − ⟨∇St1 , Vt1 (x)⟩ + div V (x)] δt + O(δt2 ).

(15)

For our purposes ∇ftt12 must vanish everywhere, therefore Vt must be a solution of∇ [∂t St + ⟨∇St , Vt ⟩ − div Vt ] = 0 ⇔ ∂t St + ⟨∇St , Vt ⟩ − div Vt ≈ 0,

(16)

where the symbol ≈ means that the two sides only agree up to a spatially constant function. A closely
related equation is derived by Pfau and Rezende [17, Eq. 6]. Eq. 16 can also be obtained by taking
the gradient of their Eq. 6, removing the t-dependent normalizing constant Zt .
Given an infinitesimal deformation ∂t S of the action S, the vector field Vt generating ∂t S is obtainedby solving Eq. 16 for Vt . Conversely, given a vector field Vt , the infinitesimal deformation it induces
on S is found by solving the same equation for St .
Sanity check: 1D Gaussians
In general, given a family of actions St , it is difficult to solve Eq. 16 for Vt . In the following
toy-example we explicitly find a particular solution. We consider one-dimensional centered gaussians
that are defined by the action
1
St (x) = t x22⇒

pt (x) =1 − t x2e 2 = N (µ = 0, σ 2 = 1/t).
Zt

(17)

Changing t to t + ϵ changes the distribution from N (0, 1/t) to N (0, 1/(t + ϵ)). To map samples
from the former
q to the latter, we can multiply with the ratios of the standard deviations, i.e. apply thet
map x 7→ x t+ϵ. The transport field Vt is then given by the derivative of this map with respect to ϵ,
" r
#
d
t
x
Vt =
x
=− .
dϵ
t + ϵ ϵ=02t(18)This choice for Vt also solves the deformation equation of the previous section. Indeed, plugging
x
St = t 12 x2 and Vt = − 2t
into Eq. 16,


1
x
1
∂x [∂t St + ⟨∇St , Vt ⟩ − div Vt ] = ∂x x2 − tx +
= 0.
(19)
2
2t 2t
This example generalizes to higher dimensional Gaussians, a two dimensional example can be seenin Fig. 2.

4

4

The ϕ4 theory on a 2D latticeR
2
The ϕ4 theory is defined by the action S0 [ϕ] = ∥∇ϕ∥ + m2 ϕ2 + λϕ4 dx. After discretizing to a
finite lattice L, the action becomes
X
X
X

4
ϕ(x)∆Lm2 ϕ2 (x) +λ0 ϕ4 (x) = ϕT ∆L + m2 ϕ + λ0 ∥ϕ∥4 ,(20)
x,y ϕ(y) +
|
{z
}
x,y∈L
x∈L
x∈L
K0

L

where ∆ is the Laplacian of the lattice L. We now deform with one of the simplest non-trivial
vector fields, Vt (ϕ) = V (ϕ) = ϕ. As a function, V is just the identity, and the dynamics it induces isa radial expansion centered at the origin. Plugging it into Eq. 16,
4∂t St = div V − ⟨∇St , V ⟩ = dim ϕ − 2Kt ϕ + 4λt ϕ3 , ϕ ≈ −2ϕT Kt ϕ − 4λt ∥ϕ∥4 ,(21)

4where we assumed that St is of the form St = ϕT Kt ϕ + λt ∥ϕ∥4 . Indeed, setting Kt = e−2t K0 and
λt = e−4t λ0 yields a solution,
4
St [ϕ] = e−2t ϕT K0 ϕ + e−4t λ0 ∥ϕ∥4 .
(22)

An interesting point to note here is the similarity between the family of actions St given by Eq. 22
and the family Sβ = βS0 that motivated this paper. The family Sβ deforms S0 by scaling the wholeaction with the same multiplicative constant, while the family St deforms S0 by scaling quartic terms
quadratically faster than the quadratic terms. Fig. 3 shows how the deformation in Eq. 22 with apositive value of t improves the performance of normalizing flows.
1.0

0.6

t=1
t=0
t = -1

0.4

t=1
t=0
t = -1

0.6
0.4

ESS

ESS

0.8

0.2

0.2
0.0

0.0
0

2000

4000

6000

8000

10000

0

MCMC acceptance rate

MCMC acceptance rate

1.0
0.8
0.6

t=1
t=0
t = -1

0.4
0.2
0.0
0

2000

4000

6000

8000

10000

10000

20000

30000

40000

0.6
0.4
t=1
t=0
t = -1

0.2
0.0
0

10000

20000

30000

40000

Figure 3: Sensitivity of the training to the deformation parameter t on a 12 × 12 lattice. We trained
the continous normalizing flow of Gerdes et al. [7] (left) and a RealNVP (right). In both cases weused the action given in Eq. 22 with different values of t ∈ {−1, 0, 1} and with m2 and λ values
same as in the work of Gerdes et al. [7]. The x-axis represents the number of training steps, while they-axis represents the performance metrics. Mean and standard deviation over 5 runs are shown.

5

Conclusion and Impact Statement

Conclusion and limitations We propose a technique that deforms one Boltzmann distribution into
an other that is easier to model with normalizing flows. We experimentally support this in the caseof the ϕ4 lattice field theory. Our experiments indicate that the technique leads to improved ESS
and acceptance rates. It is important to note however that good ESS and acceptance rate values does
not mean that qθ is perfectly matching p. For example, if there are several modes of p, qθ could be
missing some of the modes while still obtaining good ESS and acceptance rate values.
Impact Statement Beyond the application in lattice field theory that we presented in this paper, thetechnique of deforming distributions naturally lends itself to being used for modelling other physicaland chemical systems. The potential impact of the technique introduced in this paper is to allow theabove tasks to be solved more efficiently. In particular, the authors do not see any ethical concerns
nor a direct potential of negative impact to society.
56

Acknowledgement

The authors acknowledge support from the Swiss National Science Foundation under grant number
CRSII5_193716 - "Robust Deep Density Models for High-Energy Particle Physics and Solar Flare
Analysis (RODEM)". We further thank Samuel Klein and Jonas Köhler for discussions.

References[1] Denis Boyda, Gurtej Kanwar, Sébastien Racanière, Danilo Jimenez Rezende, Michael S.
Albergo, Kyle Cranmer, Daniel C. Hackett, and Phiala E. Shanahan. Sampling using SU(n)gauge equivariant flows. Phys. Rev. D, 103:074504, Apr 2021. doi: 10.1103/PhysRevD.103.
074504. URL https://link.aps.org/doi/10.1103/PhysRevD.103.074504.
[2] Michael S. Albergo, Denis Boyda, Daniel C. Hackett, Gurtej Kanwar, Kyle Cranmer, Sébastien
Racanière, Danilo Jimenez Rezende, and Phiala E. Shanahan. Introduction to normalizing flows
for lattice field theory, 2021. URL https://arxiv.org/abs/2101.08176.
[3] Michael S. Albergo, Gurtej Kanwar, Sé bastien Racanière, Danilo J. Rezende, Julian M. Urban,
Denis Boyda, Kyle Cranmer, Daniel C. Hackett, and Phiala E. Shanahan. Flow-based sampling
for fermionic lattice field theories. Physical Review D, 104(11), dec 2021. doi: 10.1103/
physrevd.104.114507. URL https://doi.org/10.1103%2Fphysrevd.104.114507.
[4] Michael S. Albergo, Denis Boyda, Kyle Cranmer, Daniel C. Hackett, Gurtej Kanwar, Sébastien
Racanière, Danilo J. Rezende, Fernando Romero-López, Phiala E. Shanahan, and Julian M.
Urban. Flow-based sampling in the lattice schwinger model at criticality, 2022. URL https://arxiv.org/abs/2202.11712.
[5] Ryan Abbott, Michael S. Albergo, Denis Boyda, Kyle Cranmer, Daniel C. Hackett, Gurtej
Kanwar, Sébastien Racanière, Danilo J. Rezende, Fernando Romero-López, Phiala E. Shanahan,
Betsy Tian, and Julian M. Urban. Gauge-equivariant flow models for sampling in lattice field
theories with pseudofermions, 2022. URL https://arxiv.org/abs/2207.08945.
[6] Pim de Haan, Corrado Rainone, Miranda C. N. Cheng, and Roberto Bondesan. Scaling up
machine learning for quantum field theory with equivariant continuous flows, 2021. URL
https://arxiv.org/abs/2110.02673.
[7] Mathis Gerdes, Pim de Haan, Corrado Rainone, Roberto Bondesan, and Miranda C. N. Cheng.
Learning lattice quantum field theories with equivariant continuous flows, 2022. URL https://arxiv.org/abs/2207.00283.
[8] Frank Noé, Simon Olsson, Jonas Köhler, and Hao Wu. Boltzmann generators – sampling
equilibrium states of many-body systems with deep learning, 2018. URL https://arxiv.
org/abs/1812.01729.
[9] Jonas Köhler, Leon Klein, and Frank Noé. Equivariant flows: Exact likelihood generative
learning for symmetric densities, 2020. URL https://arxiv.org/abs/2006.02425.
[10] Kim A. Nicoli, Shinichi Nakajima, Nils Strodthoff, Wojciech Samek, Klaus-Robert Müller,
and Pan Kessel. Asymptotically unbiased estimation of physical observables with neuralsamplers. Physical Review E, 101(2), feb 2020. doi: 10.1103/physreve.101.023304. URL
https://doi.org/10.1103%2Fphysreve.101.023304.
[11] Kim A Nicoli, Christopher J Anders, Lena Funcke, Tobias Hartung, Karl Jansen, Pan Kessel,
Shinichi Nakajima, and Paolo Stornati. Estimation of thermodynamic observables in latticefield theories with deep generative models. Physical review letters, 126(3):032001, 2021.
[12] Esteban G Tabak and Cristina V Turner. A family of nonparametric density estimation algorithms. Communications on Pure and Applied Mathematics, 66(2):145–164, 2013.
[13] Laurent Dinh, Jascha Sohl-Dickstein, and Samy Bengio. Density estimation using real nvp.
arXiv preprint arXiv:1605.08803, 2016.
6

[14] Diederik P Kingma and Prafulla Dhariwal. Glow: Generative flow with invertible 1x1 convolutions. arXiv preprint arXiv:1807.03039, 2018.
[15] Conor Durkan, Artur Bekasov, Iain Murray, and George Papamakarios. Neural spline flows,
2019.
[16] Ricky T. Q. Chen, Yulia Rubanova, Jesse Bettencourt, and David Duvenaud. Neural ordinary
differential equations, 2018. URL https://arxiv.org/abs/1806.07366.
[17] David Pfau and Danilo Rezende.
arXiv:2012.02035, 2020.

Integrable nonparametric flows.

arXiv preprint[18] Ricky T. Q. Chen. torchdiffeq, 2018. URL https://github.com/rtqichen/torchdiffeq.

Checklist
1. For all authors...
(a) Do the main claims made in the abstract and introduction accurately reflect the paper’s
contributions and scope? [Yes](b) Did you describe the limitations of your work? [Yes](c) Did you discuss any potential negative societal impacts of your work? [Yes](d) Have you read the ethics review guidelines and ensured that your paper conforms tothem? [Yes]2. If you are including theoretical results...
(a) Did you state the full set of assumptions of all theoretical results? [Yes](b) Did you include complete proofs of all theoretical results? [Yes]3. If you ran experiments...
(a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [Yes](b) Did you specify all the training details (e.g., data splits, hyperparameters, how they
were chosen)? [Yes](c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes](d) Did you include the total amount of compute and the type of resources used (e.g., typeof GPUs, internal cluster, or cloud provider)? [Yes]4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
(a) If your work uses existing assets, did you cite the creators? [N/A](b) Did you mention the license of the assets? [N/A](c) Did you include any new assets either in the supplemental material or as a URL? [N/A](d) Did you discuss whether and how consent was obtained from people whose data you’reusing/curating? [N/A](e) Did you discuss whether the data you are using/curating contains personally identifiable
information or offensive content? [N/A]
5. If you used crowdsourcing or conducted research with human subjects...
(a) Did you include the full text of instructions given to participants and screenshots, if
applicable? [N/A](b) Did you describe any potential participant risks, with links to Institutional Review
Board (IRB) approvals, if applicable? [N/A](c) Did you include the estimated hourly wage paid to participants and the total amountspent on participant compensation? [N/A]7

A

Experimental details

All of our experiments were implemented in PyTorch. We trained all the models with a sample sizeof 128 at each training step. The learning rate was initialized to 3 × 10−3 and annealed to 0 following
a cosine schedule.
RealNVP The RealNVP architectures use an alternating checkerboard masking and a 3-layer
convolutional network in each layer with kernel size 3 to compute the parameters of the affine
transformations. The overall architecture contains 24 such layers.
Continous NF The experiments involving continous normalizing flows used the architecture
proposed by Gerdes et al. [7] with F = 16 field basis functions and D = 9 time kernels, and coupling
dimensions F ′ = 8, D′ = 8. The 4th order Runge-Kutta solver of the torchdiffeq package [18] witha step size of 0.02 was used.

8