Commit c91b025
committed
Compile UMA energy output operations
> The current end-to-end validation uses UMA-S-1p2 with energy/forces/stress,
> `external_graph_gen=False`, `internal_graph_gen_version=3`, `merge_mole=True`,
> `execution_mode="umas_fast_gpu"`, and `compile_dynamic_shapes=False`. Energy
> output processing is downstream of graph construction and is executed for this
> checkpoint, so removing its explicit compile disable applies unchanged and removes
> one graph break from this internal-graph configuration.
`compute_energy` carried an unconditional compile disable around the float64
per-system reduction. The disable was added for an older float64 `index_add`
accuracy issue, but current Inductor matches eager forward and backward results
byte-for-byte. Keeping it now guarantees a boundary on every inference:
```
@torch.compiler.disable
def compute_energy(...):
...
```
Remove the decorator after adding a regression test for the production-like
float32 node-energy to float64 system-reduction path. The test checks compiled
forward outputs and input gradients byte-for-byte for static and dynamic compilation.
**Numerical validation**
The following AI-assisted numerical analysis was reviewed for inclusion because it
bounds the nondeterminism relevant to this change:
> With identical per-node inputs and deterministic algorithms disabled, two
> arbitrary FP64 atomic or two-worker NCCL reduction orders satisfy
> `|E_a - E_b| <= 2 * gamma_(n-1) * sum_i |e_i|`, where
> `gamma_k = k * 2^-53 / (1 - k * 2^-53)`. This assumes IEEE FP64 rounding and no
> overflow or underflow.
>
> A seeded recreation of the regression test's 257-node, four-system input has a
> maximum bound of `5.57e-13`; the compiled and eager outputs and gradients matched
> exactly. In the 1000-atom two-worker endpoint experiment, the maximum observed
> energy difference was `1.22e-5 eV`. Explaining that difference through FP64
> reduction order alone would require `sum(abs(node_energy)) >= 5.5e7 eV`, or about
> `55,000 eV/atom`. The endpoint difference therefore reflects upstream
> model-parallel FP32 computation rather than this final FP64 system reduction.
>
> If upstream per-node values differ, their contribution is bounded separately by
> `sum_i |e_i^(1) - e_i^(2)|`, in addition to the FP64 rounding terms.
**Activation**
No independent flag enables this fix. Energy output processing remains in the captured graph whenever UMA inference is compiled.
```python
settings = InferenceSettings(compile=True)
```
The current benchmark additionally uses `merge_mole=True`, `external_graph_gen=False`, and `execution_mode="umas_fast_gpu"`, but those settings are not required for this output-processing fix.
Test Plan:
```
PYTHONPATH=$PWD/src:$PYTHONPATH pytest -q tests/core/models/uma/test_outputs.py -k float64_compile
ruff check src/fairchem/core/models/uma/outputs.py
```
Authored with assistance from Codex.
ghstack-source-id: 19b9ddf
Pull Request resolved: #21251 parent 0ca62f1 commit c91b025
2 files changed
Lines changed: 51 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
84 | | - | |
85 | | - | |
86 | 84 | | |
87 | 85 | | |
88 | 86 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
256 | 256 | | |
257 | 257 | | |
258 | 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 | + | |
259 | 310 | | |
260 | 311 | | |
261 | 312 | | |
| |||
0 commit comments