kups.relaxation.transforms.fire
¶
Per-system FIRE optimizer transform.
Unlike :func:kups.relaxation.optax.scale_by_fire, this version takes an
index_prefix pytree at init time mapping each parameter element to a
system. Every reduction that the FIRE algorithm uses (F·v power,
||v||, ||F||, position-update norm) is taken per-system, and the
adaptive dt / alpha / n_pos state is stored as a
Table[K, Array] — one entry per system. Running batched independent
systems through this transform is bit-identical to running them one at a
time.
API convention¶
Following the optax composability pattern, the updates argument to
:meth:ScaleByFire.update is the descent direction (force
F = -∇L), not the raw gradient. The transform integrates updates
directly as a force and emits a position step Δx such that
apply_updates(x, Δx) = x + Δx descends.
If your upstream produces a raw gradient ∇L, prepend a sign-flip in
the chain. Any per-system clipping (force cap or per-particle step cap)
composes the same way:
.. code-block:: python
from kups.relaxation.optimizer import chain
from kups.relaxation.transforms import (
ClipByGlobalNorm, MaxStepSize, ScaleByFire,
)
import optax
optimizer = chain(
optax.scale(-1.0), # ∇L → F = -∇L
ScaleByFire(dt_start=0.1),
ClipByGlobalNorm(max_norm=10.0), # per-system L2 force cap
MaxStepSize(max_step_size=0.1), # per-particle Δx cap
)
ScaleByFire
¶
Bases: Optimizer[Params, ScaleByFireState]
FIRE (Fast Inertial Relaxation Engine) optimizer with per-system state.
Implements Bitzek et al. Phys. Rev. Lett. 97, 170201 (2006), but
every global tree reduction is replaced by a per-system reduction over
the index_prefix. Each system independently adapts its own
dt / alpha / n_pos and sees its own per-system power and
norms.
The transform follows the optax convention: updates passed to
:meth:update is interpreted as the force F = -∇L (the descent
direction). Sign conversion from a raw gradient and any clipping live
in the surrounding :func:kups.relaxation.optimizer.chain — see the
module docstring for a worked example.
.. note::
This is the original FIRE 1.0. For most production relaxations
prefer :class:`kups.relaxation.transforms.ScaleByFire2`, which
Guénolé et al. 2020 (Fig. 4–6) report converges in ~1.5–3×
fewer force calls on Lennard-Jones, EAM and Tersoff
benchmarks. ABC-FIRE (``ScaleByFire2(use_abc=True)``, Echeverri
Restrepo & Andric 2023, Fig. 2–3) is typically a further
~10–40% faster, but takes more aggressive steps and is
correspondingly more prone to diverging on poorly conditioned
or noisy landscapes — enable it only after a plain FIRE 2.0
run is known to be stable. FIRE 1.0 remains useful as a
well-tested baseline and for comparison with legacy results.
Composable clipping:
- :class:
kups.relaxation.transforms.ClipByGlobalNorm— per-system L2 cap on the input force (prepend before FIRE). - :class:
kups.relaxation.transforms.MaxStepSize— per-particle ∞/L2 cap on the output displacement (append after FIRE).
Attributes:
| Name | Type | Description |
|---|---|---|
dt_start |
float
|
Initial timestep. |
dt_max |
float | None
|
Maximum timestep. Defaults to |
dt_min |
float | None
|
Minimum timestep. Defaults to |
f_inc |
float
|
Factor to increase dt when making progress. |
f_dec |
float
|
Factor to decrease dt on a bad step. |
alpha_start |
float
|
Initial velocity-mixing parameter. |
f_alpha |
float
|
Factor to decay alpha when making progress. |
n_min |
int
|
Minimum positive-power steps before dt is allowed to grow. |
Source code in src/kups/relaxation/transforms/fire.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 | |
ScaleByFireState
¶
Optimizer state for the per-system FIRE transform.
Attributes:
| Name | Type | Description |
|---|---|---|
velocity |
PyTree
|
Velocity estimate (PyTree matching params). |
dt |
Table[SupportsSorting, Array]
|
Per-system adaptive timestep. |
alpha |
Table[SupportsSorting, Array]
|
Per-system velocity-mixing parameter. |
n_pos |
Table[SupportsSorting, Array]
|
Per-system count of consecutive positive-power steps. |
index_prefix |
PyTree
|
Tree prefix of the parameter pytree whose leaves are
|