Luthaf / rascaline

Computing representations for atomistic machine learning
https://luthaf.fr/rascaline/
BSD 3-Clause "New" or "Revised" License
44 stars 13 forks source link

Make Labels selection not O(n^2) #320

Closed Luthaf closed 1 month ago

Luthaf commented 1 month ago

Instead we can exploit the underlying HashMap structure of Labels.

Fixes #319, bringing the calculation down to 2.5s on my machine. There might be more optimizations to do here, but at least the worst issue is gone.

╔════╦══════════════════════════════════════════════╦════════════╦═══════════╦══════════╦══════════╗
║ id ║ span name                                    ║ call count ║ called by ║ total    ║ mean     ║
╠════╬══════════════════════════════════════════════╬════════════╬═══════════╬══════════╬══════════╣
║  1 ║ Calculator::prepare                          ║          1 ║         — ║    1.65s ║    1.65s ║
╠════╬══════════════════════════════════════════════╬════════════╬═══════════╬══════════╬══════════╣
║  0 ║ NeighborsList                                ║          1 ║         1 ║ 375.89ms ║ 375.89ms ║
╠════╬══════════════════════════════════════════════╬════════════╬═══════════╬══════════╬══════════╣
║  2 ║ NeighborList::compute                        ║          1 ║         — ║ 786.14ms ║ 786.14ms ║
╚════╩══════════════════════════════════════════════╩════════════╩═══════════╩══════════╩══════════╝

📚 Documentation preview 📚: https://rascaline--320.org.readthedocs.build/en/320/

github-actions[bot] commented 1 month ago

Here is a pre-built version of the code in this pull request: wheels.zip, you can install it locally by unzipping wheels.zip and using pip to install the file matching your system