Skip to content

[metatomic] make the code faster by avoiding torch::Tensor indexing#1305

Merged
carlocamilloni merged 2 commits intoplumed:v2.10from
lab-cosmo:faster-metatomic
Jul 26, 2025
Merged

[metatomic] make the code faster by avoiding torch::Tensor indexing#1305
carlocamilloni merged 2 commits intoplumed:v2.10from
lab-cosmo:faster-metatomic

Conversation

@Luthaf
Copy link
Contributor

@Luthaf Luthaf commented Jul 22, 2025

Description

This makes running metatomic model a lot faster, cutting the time from 3s to 900ms (most of which should also be avoidable but requires changes to our libraries first).

Target release

I would like my code to appear in release v2.10

Type of contribution
  • changes to code or doc authored by PLUMED developers, or additions of code in the core or within the default modules
  • changes to a module not authored by you
  • new module contribution or edit of a module authored by you
Copyright
  • I agree to transfer the copyright of the code I have written to the PLUMED developers or to the author of the code I am modifying.
  • the module I added or modified contains a COPYRIGHT file with the correct license information. Code should be released under an open source license. I also used the command cd src && ./header.sh mymodulename in order to make sure the headers of the module are correct.
Tests
  • I added a new regtest or modified an existing regtest to validate my changes.
  • I verified that all regtests are passed successfully on GitHub Actions.

operator[] on torch::Tensor does a lot of things from gradients tracking
to bound checks, and is a lot (~3 orders of magnitude) slower than directly
operating on the data.
@Luthaf Luthaf force-pushed the faster-metatomic branch from edaeb9e to fb7af28 Compare July 25, 2025 12:12
@carlocamilloni carlocamilloni merged commit 8011a23 into plumed:v2.10 Jul 26, 2025
18 checks passed
@Luthaf Luthaf deleted the faster-metatomic branch July 26, 2025 16:09
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.

2 participants