Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] BAR style calculation #54

Open
akalpokas opened this issue Aug 30, 2024 · 2 comments · May be fixed by #64
Open

[Feature Request] BAR style calculation #54

akalpokas opened this issue Aug 30, 2024 · 2 comments · May be fixed by #64
Labels
enhancement New feature or request

Comments

@akalpokas
Copy link
Contributor

akalpokas commented Aug 30, 2024

Given the high impact of updateParametersInContext() code on the performance of FEP calculations with SOMD2 (benchmark openmm/openmm#4610) it would be a very useful feature to allow the user to calculate energy differences to a restricted number of λ-windows, for example only neighbouring ones, thus enabling a "BAR style" calculation. Even with currently proposed OpenMM optimizations, going from a 3 λ-window to a 99 λ-window calculation using RF and 1ps of sampling frequency results with a performance drop from ~900ns/day to ~220ns/day. For PME the performance drop is from ~287ns/day to ~125ns/day.

With a BAR style of a calculation, we could do a calculation involving 99 λ-windows at the computational cost of only 3 (MBAR is meant to be more accurate, although I do believe that in vast majority of cases this is negligible, while the performance gain here is substantial). This would help in use cases where higher number of λ-windows are consistently needed, for example ABFE or ring-breaking FEP. The way GROMACS implements this is by using a calc-lambda-neighbors parameter which controls how many neighbouring λ-windows the energy sampling calculation will be carried out with, with 1 meaning the only the adjacent windows, and -1 meaning every window. I don't think this is too hard to implement in SOMD2, although it will probably involve additional modifications to BioSimSpace.FreeEnergy.Relative.analyse code to support BAR type energy output files (alchemlyb has a BAR estimator, although it cannot produce overlap matrices, like the MBAR one).

@jmichel80
Copy link
Contributor

pymbar has a BAR estimator and can do overlap analyses https://pymbar.readthedocs.io/en/master/

could there be precision benefits in computing perturbed energies for 5-9 neighbouring windows ? The MBAR theory allows variable number of samples per thermodynamic state so it may be possible to padd square matrices and fake a full MBAR analysis.

@lohedges lohedges added the enhancement New feature or request label Sep 2, 2024
@lohedges
Copy link
Contributor

This should now be solved on the development branch of Sire and the feature_repex branch of somd2. It's now possible to specify the --num-energy-neighbours option to somd2, which specifies the number of neighbouring lambda windows that are included in the energy trajectory calculation. (Windows that aren't computed take a large energy value.) Initial testing shows that this works well and can greatly improve performance when a large number of windows are used.

I'll close this issue following further testing once the feature_repex PR is ready.

@lohedges lohedges linked a pull request Feb 10, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants