Commit 51e0995
Uma base inference speedups (#2111)
Speed up UMA inference and DDP training without changing numerics
(updated Aug 3rd)
# perf(inference): freeze prepared model parameters
## Summary
Freeze model parameters after inference-specific module preparation.
Inference
may differentiate outputs with respect to positions and cells for
forces,
stress, and Hessians, but it does not need parameter gradients. Freezing
after
MOLE and backend replacement avoids retaining unnecessary
weight-gradient
state while preserving input derivatives.
The policy now covers both `general` and `umas_fast_gpu`. Main's
folded-batch
linear path (`9547a5b3c`) removes the former general-backend
frozen-weight
regression. Prediction retains the full `AtomicData.clone()` boundary
because
graph parallelism, MOLE preparation, and conservative gradients can
mutate
model inputs.
This PR also adds frozen/unfrozen energy, force, stress, and Hessian
parity
coverage for both execution modes, singleton graph-parallel regression
coverage, and pretrained-model test routing markers.
## Performance
Compared current `origin/main` at `9547a5b3c` with the
parameter-freezing
change. Both sides include the new fused Wigner/SO2 edgewise kernels and
folded-batch linear operations.
All GPU runs used UMA-S-1.2.1 (`uma-s-1p2p1`), PyTorch 2.13.0+cu130,
H100
80 GB HBM3 GPUs, and the `h100_ocp_high` QoS.
### Fast GPU backend
Each atom count is one global FCC structure partitioned across a
graph-parallel group containing every allocated GPU; atom counts are not
per
GPU. The primary throughput metric is median synchronized QPS. Peak
allocated
memory is the maximum rank value; total allocated memory is summed
across
ranks.
| GPUs | Atoms | Main QPS | PR QPS | Speedup | Allocated GiB/GPU, main
-> PR | Allocated delta | Reserved delta | Total allocated GiB, main ->
PR |
| ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: |
| 8 | 100 | 30.60 | 32.43 | 1.060x | 0.18 -> 0.17 | -8.9% | -3.0% | 1.44
-> 1.31 |
| 8 | 1,000 | 29.53 | 32.05 | 1.086x | 0.88 -> 0.70 | -20.6% | -20.3% |
7.06 -> 5.60 |
| 8 | 10,000 | 21.08 | 23.08 | 1.095x | 7.32 -> 5.64 | -22.9% | -21.0% |
58.48 -> 45.08 |
| 32 | 100 | 26.86 | 28.42 | 1.058x | 0.13 -> 0.13 | -2.9% | -5.2% |
4.10 -> 4.00 |
| 32 | 1,000 | 26.17 | 27.58 | 1.054x | 0.33 -> 0.27 | -17.2% | -13.0% |
10.41 -> 8.63 |
| 32 | 10,000 | 25.97 | 27.05 | 1.042x | 2.15 -> 1.63 | -24.0% | -21.7%
| 68.19 -> 51.97 |
Freezing remains beneficial after the fused fast-backend kernels: median
QPS
improves in all six cases by 4.2-9.5%, while the 10,000-atom cases save
23-24%
peak allocated memory and 21-22% peak reserved memory.
The fast-backend benchmark used candidate snapshot `a2dca9379`. Its fast
path
is behaviorally identical to final commit `3af44001e`; the final commit
only
extends the same freeze operation to other execution modes and broadens
tests.
### General backend
The general-backend check used one H100 without graph-parallel
initialization.
It applies freezing after MOLE preparation and before compilation,
exactly where
the final implementation applies it.
| Atoms | Main QPS | Frozen QPS | Speedup | Allocated GiB, main ->
frozen | Allocated delta | Reserved delta |
| ---: | ---: | ---: | ---: | ---: | ---: | ---: |
| 100 | 47.53 | 55.52 | 1.168x | 1.04 -> 0.76 | -27.0% | -23.4% |
| 1,000 | 16.98 | 19.55 | 1.151x | 11.80 -> 8.36 | -29.1% | -25.0% |
| 2,000 | 10.24 | 11.76 | 1.149x | 21.40 -> 15.16 | -29.2% | -25.1% |
The folded-batch linear change reverses the former general-backend
regression:
freezing is now 14.9-16.8% faster and saves 27-29% allocated memory.
A local 16-thread CPU check with the general backend and compilation
disabled
measured `1.040x` at 32 atoms and `1.002x` at 1,000 atoms. The new path
is
positive for the small case and neutral for the larger case, rather than
the
previous CPU slowdown.
## Methodology
- Fast settings: FP32 base precision, TF32 enabled, `umas_fast_gpu`,
`merge_mole=True`, `compile=True`, and `activation_checkpointing=False`.
- General settings: the same settings with `execution_mode=general`; the
one-GPU check did not initialize graph parallelism.
- Order on each GPU allocation: main A, candidate A, candidate B, main B
(ABBA).
- Each GPU branch/size result: 5 warmups followed by 3 repeats of 10
predictions.
- Reported QPS: median of 6 synchronized repeats across the two runs.
- Multi-GPU timing: maximum elapsed time across ranks after CUDA
synchronization and a distributed barrier.
- Memory: CUDA peaks reset after warmup; maximum-rank and aggregate
allocated
and reserved memory were recorded.
- Inputs: the same seed-42 FCC structures were used by every branch and
GPU
count; all structure checksums match exactly.
## Fidelity
Energy, force, and stress checksums were captured for every run. Across
the
general and fast comparisons, the maximum main-to-frozen energy-sum
relative
difference was below `4.5e-5`, the maximum-force checksum absolute
difference
was `2.54e-4`, and the maximum-stress checksum absolute difference was
`3.24e-6`. These differences are on the same scale as repeated
distributed GPU
runs of the same commit.
Focused regression tests compare frozen and unfrozen energy, force,
stress, and
Hessian tensors for both execution modes. The fast backend uses
`hessian_vmap=False` because its custom backward operators do not
implement
`vmap` batching.
## Validation
- Pre-commit passed for every modified file after merging `origin/main`.
- `tests/core/common/test_gp_utils.py`: 18 passed on PyTorch 2.13.
- `test_untrained_hessian_cpu`: passed with all model parameters frozen.
- Frozen/unfrozen GPU derivative parity: 2 passed (`general` and
`umas_fast_gpu`) in Slurm job `9976221`.
- General one-GPU ABBA benchmark: completed without failures in job
`9974069`.
- Fast 8- and 32-GPU ABBA benchmarks: completed without failures in jobs
`9973417` and `9973418`.
- `graph_parallel_group_size=None` remains the no-GP path; group size 1
remains
an intentional singleton-GP test path.
---------
Co-authored-by: Ray Gao <7001989+rayg1234@users.noreply.github.com>1 parent 9547a5b commit 51e0995
5 files changed
Lines changed: 126 additions & 3 deletions
File tree
- src/fairchem/core/units/mlip_unit
- tests/core
- common
- components
- units/mlip_unit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
242 | 242 | | |
243 | 243 | | |
244 | 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 | + | |
245 | 271 | | |
246 | 272 | | |
247 | 273 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
41 | | - | |
42 | | - | |
| 40 | + | |
43 | 41 | | |
44 | 42 | | |
45 | 43 | | |
| |||
461 | 459 | | |
462 | 460 | | |
463 | 461 | | |
| 462 | + | |
| 463 | + | |
464 | 464 | | |
465 | 465 | | |
466 | 466 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
34 | 50 | | |
35 | 51 | | |
36 | 52 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
13 | 15 | | |
14 | 16 | | |
| 17 | + | |
| 18 | + | |
15 | 19 | | |
16 | 20 | | |
17 | 21 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1796 | 1796 | | |
1797 | 1797 | | |
1798 | 1798 | | |
| 1799 | + | |
| 1800 | + | |
| 1801 | + | |
| 1802 | + | |
1799 | 1803 | | |
1800 | 1804 | | |
1801 | 1805 | | |
| |||
1816 | 1820 | | |
1817 | 1821 | | |
1818 | 1822 | | |
| 1823 | + | |
| 1824 | + | |
| 1825 | + | |
| 1826 | + | |
| 1827 | + | |
| 1828 | + | |
| 1829 | + | |
| 1830 | + | |
| 1831 | + | |
| 1832 | + | |
| 1833 | + | |
| 1834 | + | |
| 1835 | + | |
| 1836 | + | |
| 1837 | + | |
| 1838 | + | |
| 1839 | + | |
| 1840 | + | |
| 1841 | + | |
| 1842 | + | |
| 1843 | + | |
| 1844 | + | |
| 1845 | + | |
| 1846 | + | |
| 1847 | + | |
| 1848 | + | |
| 1849 | + | |
| 1850 | + | |
| 1851 | + | |
| 1852 | + | |
| 1853 | + | |
| 1854 | + | |
| 1855 | + | |
| 1856 | + | |
| 1857 | + | |
| 1858 | + | |
| 1859 | + | |
| 1860 | + | |
| 1861 | + | |
| 1862 | + | |
| 1863 | + | |
| 1864 | + | |
| 1865 | + | |
| 1866 | + | |
| 1867 | + | |
| 1868 | + | |
| 1869 | + | |
| 1870 | + | |
| 1871 | + | |
| 1872 | + | |
| 1873 | + | |
| 1874 | + | |
| 1875 | + | |
| 1876 | + | |
| 1877 | + | |
| 1878 | + | |
| 1879 | + | |
| 1880 | + | |
| 1881 | + | |
| 1882 | + | |
| 1883 | + | |
| 1884 | + | |
| 1885 | + | |
| 1886 | + | |
| 1887 | + | |
| 1888 | + | |
| 1889 | + | |
| 1890 | + | |
| 1891 | + | |
| 1892 | + | |
| 1893 | + | |
1819 | 1894 | | |
1820 | 1895 | | |
1821 | 1896 | | |
| |||
1993 | 2068 | | |
1994 | 2069 | | |
1995 | 2070 | | |
| 2071 | + | |
1996 | 2072 | | |
1997 | 2073 | | |
1998 | 2074 | | |
| |||
2008 | 2084 | | |
2009 | 2085 | | |
2010 | 2086 | | |
| 2087 | + | |
2011 | 2088 | | |
2012 | 2089 | | |
2013 | 2090 | | |
| |||
0 commit comments