kups.relaxation.transforms
¶
Per-system relaxation transforms compatible with the
:class:kups.relaxation.optimizer.Optimizer protocol.
These are batch-aware versions of the transforms in
:mod:kups.relaxation.optax: they accept an index_prefix pytree at
init time identifying which system each element belongs to, so batched
systems are clipped or scaled independently.
ClipByGlobalNorm
¶
Bases: Optimizer[Params, ClipByGlobalNormState]
Clip the per-system L2 norm of updates to max_norm.
With index_prefix=None this reduces to the standard
:func:optax.clip_by_global_norm (a single tree-global L2 norm).
Attributes:
| Name | Type | Description |
|---|---|---|
max_norm |
float
|
Maximum allowed per-system L2 norm of the update. |
Source code in src/kups/relaxation/transforms/clip_by_global_norm.py
ClipByGlobalNormState
¶
State carrying the index_prefix captured at init time.
Attributes:
| Name | Type | Description |
|---|---|---|
index_prefix |
PyTree | None
|
Tree prefix of the parameter pytree whose leaves are
|
Source code in src/kups/relaxation/transforms/clip_by_global_norm.py
MaxStepSize
¶
Bases: Optimizer[Params, MaxStepSizeState]
Clip updates so no element of any system moves more than max_step_size.
Per-element norms are computed along the last axis. For every system, the
maximum norm across all elements assigned to that system (across every leaf
of updates) is found, and updates for those elements are uniformly
scaled so the worst-case norm does not exceed max_step_size. Different
systems are scaled independently.
Attributes:
| Name | Type | Description |
|---|---|---|
max_step_size |
float
|
Maximum allowed per-element displacement norm. |
Source code in src/kups/relaxation/transforms/max_step_size.py
MaxStepSizeState
¶
Optimizer state holding the index_prefix captured at init time.
Attributes:
| Name | Type | Description |
|---|---|---|
index_prefix |
PyTree | None
|
Tree prefix of the parameter pytree whose leaves are
:class: |
Source code in src/kups/relaxation/transforms/max_step_size.py
ScaleByAseLbfgs
¶
Bases: Optimizer[Params, ScaleByAseLbfgsState]
L-BFGS preconditioner with per-system block-diagonal Hessian.
With a trivial index_prefix (one system) this reduces to the same
algorithm as :func:kups.relaxation.optax.scale_by_ase_lbfgs:
the initial inverse Hessian is (1/alpha) * I (ASE convention) and
the recursion buffers memory_size past (diff_params, diff_updates)
pairs. With multiple systems, every system maintains its own
independent inverse-Hessian approximation and its own ρᵢ weights.
Attributes:
| Name | Type | Description |
|---|---|---|
memory_size |
int
|
Number of past difference pairs to store. |
alpha |
float
|
Initial inverse Hessian is |
Source code in src/kups/relaxation/transforms/lbfgs.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 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 | |
ScaleByAseLbfgsState
¶
State for the per-system ASE-flavor L-BFGS preconditioner.
Attributes:
| Name | Type | Description |
|---|---|---|
count |
Array
|
Total update steps taken so far (scalar int32). |
params |
PyTree
|
Last seen parameters, pytree matching |
updates |
PyTree
|
Last seen gradients/updates. |
diff_params_memory |
PyTree
|
Stacked past parameter differences, shape
|
diff_updates_memory |
PyTree
|
Stacked past update differences, same shape. |
weights_memory |
Table[Any, Array]
|
Per-system per-slot |
index_prefix |
PyTree
|
Tree prefix of the parameter pytree whose leaves are
|
Source code in src/kups/relaxation/transforms/lbfgs.py
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 | |
ScaleByFire2
¶
Bases: Optimizer[Params, ScaleByFire2State]
FIRE 2.0 (with optional ABC-FIRE) with per-system block-diagonal state.
Per-system port of the LAMMPS-style FIRE 2.0 integrator described in
Guénolé et al. 2020, with the ABC-FIRE bias correction
(use_abc=True) of Echeverri Restrepo & Andric 2023. With a single
system this reduces to the algorithm from
kups.relaxation.optax.scale_by_fire2; with multiple systems each
system independently adapts its own dt / alpha / n_pos
and sees its own per-system power, norms and dmax.
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 external
clipping live in the surrounding
:func:kups.relaxation.optimizer.chain — see the module docstring
for a worked example. The LAMMPS-style dmax clip configured via
:attr:max_step is internal to FIRE 2.0 and applies on top of any
composed clipping.
Attributes:
| Name | Type | Description |
|---|---|---|
dt_start |
float
|
Initial timestep. |
dt_max |
float
|
Maximum timestep (LAMMPS |
dt_min |
float
|
Minimum timestep (LAMMPS |
max_step |
float | None
|
Per-step displacement bound |
f_inc |
float
|
Factor to grow |
f_dec |
float
|
Factor to shrink |
alpha_start |
float
|
Initial velocity-mixing parameter (LAMMPS |
f_alpha |
float
|
Factor to decay |
n_min |
int
|
Minimum positive-power steps before |
use_abc |
bool
|
If True, apply ABC-FIRE bias correction to the mixing. |
halfstepback |
bool
|
If True, apply |
delaystep_start |
bool
|
If True, suppress |
References
- Guénolé et al., Comput. Mater. Sci. 175, 109584 (2020).
- Echeverri Restrepo & Andric, Comput. Mater. Sci. 218, 111978 (2023).
- LAMMPS
src/min_fire.cpp(develop branch).
Source code in src/kups/relaxation/transforms/fire2.py
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 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 | |
ScaleByFire2State
¶
Optimizer state for the per-system FIRE 2.0 transform.
Attributes:
| Name | Type | Description |
|---|---|---|
velocity |
PyTree
|
Velocity estimate, pytree matching the parameters. |
dt |
Table[Any, Array]
|
Per-system adaptive timestep. |
alpha |
Table[Any, Array]
|
Per-system velocity-mixing parameter. |
n_pos |
Table[Any, Array]
|
Per-system count of consecutive positive-power steps
(LAMMPS |
n_total |
Array
|
Scalar — total update steps taken so far (drives
|
index_prefix |
PyTree
|
Tree prefix of the parameter pytree whose leaves are
|
Source code in src/kups/relaxation/transforms/fire2.py
ScaleByFireState
¶
Optimizer state for the per-system FIRE transform.
Attributes:
| Name | Type | Description |
|---|---|---|
velocity |
PyTree
|
Velocity estimate (PyTree matching params). |
dt |
Table[Any, Array]
|
Per-system adaptive timestep. |
alpha |
Table[Any, Array]
|
Per-system velocity-mixing parameter. |
n_pos |
Table[Any, Array]
|
Per-system count of consecutive positive-power steps. |
index_prefix |
PyTree
|
Tree prefix of the parameter pytree whose leaves are
|