Skip to content

Fuse compiled single-system periodic shifts - #2142

Open
mlazos wants to merge 1 commit into
mainfrom
uma-fused-periodic-shifts
Open

Fuse compiled single-system periodic shifts#2142
mlazos wants to merge 1 commit into
mainfrom
uma-fused-periodic-shifts

Conversation

@mlazos

@mlazos mlazos commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Summary

For a single system, Inductor currently lowers the fixed-width cell-offset
matrix multiply as an external operation. That prevents it from fusing with
the following edge-vector construction.

While Dynamo is tracing, express the three-column transform as scaled cell
rows so Inductor can fuse the work. Eager execution retains the existing
matrix multiply, and the multi-system path is unchanged.

Performance

With torch.compile(dynamic=True), periodic fusion improved the full endpoint from 16.87322 to 16.83233 ms with fresh caches, a 0.04089 ms (0.24%) gain, and from 16.87650 to 16.82935 ms with warm caches, a 0.04715 ms (0.28%) gain. It removed four external calls.

The isolated dynamic shift and edge-vector benchmark improved from 0.07501 to 0.03298 ms, a 56.0% gain.

Configuration: H100, TF32, UMA-S-1p2, 1,000 atoms, energy/forces/stress, umas_fast_gpu, merge_mole=True, external_graph_gen=False, internal graph v3, internal_graph_skin=0, compile=True, compile_dynamic_shapes=True, and full CUDA graph replay. Steady-state execution had zero recompiles and zero dynamic graph fallbacks.

Testing

CUDA_VISIBLE_DEVICES=0 TORCHINDUCTOR_CACHE_DIR=$PWD/agent_space/cache_shift_compile_test PYTHONPATH=$PWD/src:/data/users/mlazos/pytorch /home/mlazos/.conda/envs/pytorch-3.12/bin/python -m pytest -q tests/core/models/uma/test_compile.py::test_compile_single_system_external_graph
ruff check --ignore PT023,B905 src/fairchem/core/models/uma/escn_md.py tests/core/models/uma/test_compile.py
git diff --check origin/main...HEAD

Pytest reported 1 passed; the process subsequently hit the previously
observed CUDA interpreter-shutdown abort.

Authored with assistance from Codex.

Inductor lowers the fixed-width cell-offset matrix multiply as an external operation, preventing fusion with edge-vector construction. Express the three-column transform as scaled cell rows while Dynamo is tracing so Inductor can fuse it, while retaining the existing matrix multiply for eager execution.

The matched UMA-S-1p2 internal-v3 endpoint improved by 0.098 ms GPU with external_graph_gen=False, merge_mole=True, static model compilation, and full dynamic CUDA graph replay.

Test Plan:
```
CUDA_VISIBLE_DEVICES=0 TORCHINDUCTOR_CACHE_DIR=$PWD/agent_space/cache_shift_compile_test PYTHONPATH=$PWD/src:/data/users/mlazos/pytorch /home/mlazos/.conda/envs/pytorch-3.12/bin/python -m pytest -q tests/core/models/uma/test_compile.py::test_compile_single_system_external_graph
/home/mlazos/.conda/envs/pytorch-3.12/bin/ruff check --ignore PT023,B905 src/fairchem/core/models/uma/escn_md.py tests/core/models/uma/test_compile.py
git diff --check origin/main...HEAD
```

Pytest reported 1 passed before the process hit the previously observed CUDA interpreter-shutdown abort.

Authored with assistance from Codex.
@meta-cla meta-cla Bot added the cla signed label Aug 6, 2026
@mlazos

mlazos commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

AI-Review

Automated multi-agent review (2 Claude + 2 Codex + synthesis). This is AI-generated — please verify findings manually.


No verified issues found.

@mlazos
mlazos marked this pull request as ready for review August 11, 2026 00:30
@mlazos mlazos added patch Patch version release and removed patch Patch version release labels Aug 11, 2026
@lbluque lbluque added the enhancement New feature or request label Aug 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla signed enhancement New feature or request patch Patch version release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants