Commit c2d5bca
committed
Use rank-2 linear for UMA spectral gates
SpectralAtomwise kept a singleton coefficient dimension when projecting its scalar slice. Linear consequently lowered the production [1000, 1, 128] input to four broadcast BMMs in both the forward and input-gradient graphs.
Squeeze that known singleton dimension before the scalar MLP. GateActivation already consumes the resulting rank-2 tensor, so this changes no model semantics and lets Inductor emit ordinary addmm/mm calls without layout conversions. The focused test compares the old expression with the new path bitwise on CPU and records the Linear input rank.
The exact internal-v3, external_graph_gen=False endpoint improved by an order-balanced 0.250852 ms (1.353%), with all six paired cycles positive and all seven energy/forces/stress perturbations passing.
Test Plan:
```
PYTHONPATH=$PWD/src:/data/users/mlazos/pytorch python -m pytest -q tests/core/models/uma/test_escn_md.py
ruff check --ignore UP035 src/fairchem/core/models/uma/escn_md_block.py tests/core/models/uma/test_escn_md.py
git diff --check
```
Authored with assistance from Codex.1 parent cb4f933 commit c2d5bca
2 files changed
Lines changed: 42 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
321 | 321 | | |
322 | 322 | | |
323 | 323 | | |
324 | | - | |
| 324 | + | |
| 325 | + | |
325 | 326 | | |
326 | 327 | | |
327 | 328 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
21 | 61 | | |
22 | 62 | | |
23 | 63 | | |
| |||
0 commit comments