Skip to content

Add oeq/hybrid acceleration, torch.compile support, and TorchSim interface#1390

Merged
ilyes319 merged 6 commits intoACEsuit:developfrom
ilyes319:torchsim-compile
Mar 3, 2026
Merged

Add oeq/hybrid acceleration, torch.compile support, and TorchSim interface#1390
ilyes319 merged 6 commits intoACEsuit:developfrom
ilyes319:torchsim-compile

Conversation

@ilyes319
Copy link
Copy Markdown
Contributor

@ilyes319 ilyes319 commented Mar 2, 2026

Summary

This PR adds support for accelerated inference backends and torch.compile to the MACE ASE calculator, along with a new TorchSim interface:

  • Hybrid cueq+oeq backend: cueq for symmetric contractions/linear ops, oeq for channelwise tensor products. Includes automatic conv_fusion fallback for non-uniform edge irreps (e.g. 128x0e+32x1o).
  • torch.compile support: Works with both pure e3nn and accelerated backends. Handles oeq-specific constraints (displacement created outside compiled graph for stress, disallow_in_graph(autograd.grad) for oeq ops).
  • Graph padding: Automatic padding of atoms and edges to fixed budgets to avoid recompilation during MD/relaxation. Isolated padding system with self-loops at 2*r_max to prevent spurious interactions with real atoms.
  • TorchSim interface (mace_torchsim.py): Native integration with TorchSim for batched simulation, with padding and backend conversion built in.
  • convert_e3nn_hybrid CLI: New conversion script for e3nn-to-hybrid (cueq+oeq) model conversion.

Files changed (10 files, +1140/-90)

  • mace/calculators/mace.py -- Refactored calculator with backend conversion, compile setup, and padding
  • mace/calculators/mace_torchsim.py -- New TorchSim MACE interface
  • mace/cli/convert_e3nn_hybrid.py -- New e3nn-to-hybrid conversion CLI
  • mace/cli/convert_e3nn_oeq.py -- Minor layout fix
  • mace/data/__init__.py -- Export padding_tools
  • mace/data/padding_tools.py -- New padding utilities for graph padding
  • mace/modules/blocks.py -- 1-line fix
  • mace/modules/utils.py -- Guard requires_grad_ with torch.compiler.is_compiling()
  • mace/modules/wrapper_ops.py -- cueq/oeq layout transposes for hybrid mode
  • mace/tools/scripts_utils.py -- 1-line fix

Test plan

  • test_calculator.py -- 16 passed
  • test_compile.py -- Core compile tests pass
  • test_models.py -- 6 passed
  • test_modules.py -- 8 passed
  • test_run_train.py -- 17 passed
  • Pre-commit (black, isort) clean

Made with Cursor

merge LoRA fixes and re-estimated E0s for ft
remove les from cfg because pypi release block
…rface

- Fix missing oeq_config in RealAgnosticResidualNonLinearInteractionBlock
- Fix convert_e3nn_oeq: enabled=False -> enabled=True, add key guard
- Add with_oeq_conv_fusion/with_oeq_scatter_sum wrappers in wrapper_ops
- Add ir_mul/mul_ir layout transposes for hybrid (cueq+oeq) mode
- Add convert_e3nn_hybrid converter (cueq symcon + oeq conv TP)
- Support external displacement in get_symmetric_displacement for compile
- Add padding_tools with isolated-system padding for torch.compile
- Update ASE calculator: hybrid mode, compile fixes, padding support
- Add MaceTorchSimModel with compile padding and kernel acceleration
- Fix extract_model strict=False for converted models

Made-with: Cursor
@ilyes319 ilyes319 changed the base branch from main to develop March 2, 2026 13:52
@ilyes319 ilyes319 force-pushed the torchsim-compile branch 8 times, most recently from 5b6a544 to 88ac388 Compare March 2, 2026 16:18
When conv_fusion=True fails (non-uniform edge irreps like 128x0e+32x1o),
automatically retry with conv_fusion=False instead of crashing.

Made-with: Cursor
@ilyes319 ilyes319 force-pushed the torchsim-compile branch 2 times, most recently from ab232b8 to e2d8d0d Compare March 2, 2026 16:58
@ilyes319 ilyes319 merged commit 47ea1a7 into ACEsuit:develop Mar 3, 2026
56 of 57 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant