kups.relaxation.transforms.lbfgs
¶
Per-system L-BFGS preconditioner with ASE-style initial Hessian.
Unlike :func:kups.relaxation.optax.scale_by_ase_lbfgs, this version takes
an index_prefix pytree at init time mapping each parameter element to a
system. Every reduction in the L-BFGS two-loop recursion (the
s · q and y · r inner products) is taken per-system, the per-slot
weights ρᵢ = 1/(yᵢ · sᵢ) become per-system scalars stored in a
Table[K, Array] of shape (n_systems, memory_size), and the
resulting inverse-Hessian approximation is therefore block-diagonal across
systems. Running batched independent systems through this transform is
bit-identical to running them one at a time.
ScaleByAseLbfgs
¶
Bases: Optimizer[Params, ScaleByAseLbfgsState[Params]]
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
|
Fixed initial inverse Hessian is |
adaptive_scale |
bool
|
If |
Source code in src/kups/relaxation/transforms/lbfgs.py
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 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 | |
ScaleByAseLbfgsState
¶
State for the per-system ASE-flavor L-BFGS preconditioner.
All parameter-shaped fields are stored as flat lists of raw array leaves
(aligned with index_leaves), never as Table-bearing pytrees, so the
stacked memory_size leading axis on the history buffers never re-runs
Table validation. treedef reconstructs the parameter pytree on exit.
Attributes:
| Name | Type | Description |
|---|---|---|
count |
Array
|
Total update steps taken so far (scalar int32). |
params |
list[Array]
|
Last seen parameter leaves (flat list of arrays). |
updates |
list[Array]
|
Last seen gradient/update leaves (flat list of arrays). |
diff_params_memory |
list[Array]
|
Per leaf, stacked past parameter differences of
shape |
diff_updates_memory |
list[Array]
|
Per leaf, stacked past update differences. |
weights_memory |
Table[SupportsSorting, Array]
|
Per-system per-slot |
index_prefix |
PyTree
|
Tree prefix of the parameter pytree whose leaves are
|
treedef |
PyTreeDef[Params]
|
Static pytree structure of the parameters, used to unflatten the preconditioned update back into the parameter pytree. |