Skip to content

Commit 855b04f

Browse files
committed
Add high level documentation for evolvers
1 parent 5a06542 commit 855b04f

File tree

2 files changed

+105
-1
lines changed

2 files changed

+105
-1
lines changed

docs/pages/evolvers.md

+104
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
\page evolversdoc Evolvers
2+
3+
Evolvers are the main component of HMC evolution.
4+
Their task is transforming one configuration into another one along the Markov chain.
5+
6+
All evolvers must inherit from isle.evolver.Evolver and implement the abstract interface.
7+
- The <B>`evolve`</B> method takes an input configuration `phi` and conjugate momentum `pi`
8+
and returns a new configuration and momentum.
9+
- <B>`save`</B> stores the current state of the evolver in an HDF5 group so the evolver can
10+
be reconstructed by `fromH5` later and resume evolution.
11+
- The classmethod <B>`fromH5`</B> constructs a new instance of the evolver from HDF5 based
12+
on a state previously written with `save`.
13+
14+
15+
### Evolution
16+
17+
Evolvers are responsible for almost all of HMC evolution.
18+
They have to generate suitable proposals for new configurations and
19+
select one all in such a way that reversibility and detailed balance are maintained.
20+
Only the generation of the conjugate momenta is handled by the user.
21+
22+
An examples of this is isle.evolver.ConstStepLeapfrog which uses leapfrog integration
23+
to generate a new `phi` and `pi` out of a starting configuration and momentum.
24+
Those new fields are either accepted or rejected by isle.evolver.BinarySelector which
25+
uses Metropolis accept/reject.
26+
27+
Another example is isle.evolver.TwoPiJumps which generates discrete shifts in the
28+
configuration and uses knowledge of the action to compute the change in energy.
29+
It can do multiple updates and accept or reject each one individually all encapsulated
30+
in one call to `evolve`.
31+
32+
33+
### Save / Load
34+
35+
Since evolvers drive HMC evolution, they can in some cases hold state which needs to be
36+
handled consistently in order to construct a proper Markov chain.
37+
Such state must be recovered when an HMC run is resumed from a checkpoint stored in a file.
38+
Evolvers must therefore be able to save their state, or the relevant portions thereof, to HDF5
39+
and retrieve it later.
40+
In addition, information on the type of the evolver is stored in a separate location in the file.
41+
This allows a run to be continued from just the HDF5 file without any need for
42+
additional, user written files.
43+
44+
#### Saving Types
45+
46+
Saving and loading the type of an evolver is handled by isle.evolver.EvolverManager and the
47+
individual evolvers do not have to do anything special to enable this
48+
(except for the third point below).
49+
An exception to this are collective evolvers such as isle.evolver.Alternator which uses an
50+
evolver manager to save/load the types of its sub evolvers as part of its state.
51+
This is necessary since the manager is unaware of the sub evolvers and cannot handle them when
52+
saving/loading the %Alternator type.
53+
54+
isle.evolver.EvolverManager supports different ways of saving types in order to accommodate
55+
custom evolvers as well as built in ones.
56+
There are three scenarios for saving/loading evolver types
57+
(see \ref filelayout for more details on how this looks in the file):
58+
- The evolver is built into Isle (i.e. defined in module isle.evolver).
59+
In this case, reconstructing it is trivial and only its classname is stored in the file
60+
(dataset `__name__`).
61+
62+
- The evolver is custom defined but is provided as part of the `definitions` argument
63+
to the constructor of EvolverManager.
64+
Again, only the name of the class is stored and there is no visible difference
65+
in the HDF5 file.<br>
66+
The evolver can only be reconstructed if the type is provided to the EvolverManager
67+
which reads the file.
68+
This can potentially be in a different session and thus requires extra work and care by the user.
69+
70+
- The evolver is custom defined and not provided to the manager.
71+
In this case, the full source code of the evolver class is saved to the file in the dataset
72+
`__source__` and `__name__` is set to `"__as_source__"`.
73+
This allows custom evolvers to be reconstructed from file without any additional action by
74+
the user.
75+
This is used for instance by the program `isle continue`.
76+
\attention
77+
Evolvers saved this way must be fully self contained, i.e. import
78+
any required modules (modules `isle`, `evolvers`, and class `Evolver`
79+
are provided and don't have to be imported).
80+
81+
&nbsp;
82+
83+
84+
#### Saving State
85+
86+
Saving and loading state is the responsibility of the evolvers themselves.
87+
The `save` method is given an HDF5 group for the evolver to do with as it pleases.
88+
It must however ensure that calling `fromH5` with an HDF5 group constructs an evolver
89+
that is completely equivalent to the one that was saved, i.e. any observable state must
90+
be the same.
91+
This is necessary to allow Isle to resume an HMC run.
92+
93+
Evolvers are allowed to issue additional save/load commands through the EvolverManager
94+
that is provided to `save` and `fromH5`.
95+
This can be used to save/load sub evolvers which would otherwise not be visible to
96+
the manager.
97+
See for example isle.evolver.Alternator.
98+
99+
`fromH5` has some additional parameters that contain some global parameters / state
100+
of the simulation.
101+
Those are the action, lattice, and random number generator.
102+
The evolver is allowed to store references to them and use them for evolution.
103+
Since those objects are provided, they do not have to be saved by the evolver,
104+
thus avoiding duplication and reducing file size.

docs/pages/file_layout.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ Any other content is determined by the evolver itself.
6767
Evolvers are allowed to refer to the type definitions.
6868

6969
\see Additional information on %evolvers, in particular handling of types,
70-
can be found in \ref evolvers.
70+
can be found in \ref evolversdoc.
7171

7272
### Measurement Files
7373

0 commit comments

Comments
 (0)