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

Hamiltonian replica exchange #1128

Merged
merged 82 commits into from
Sep 6, 2023
Merged

Hamiltonian replica exchange #1128

merged 82 commits into from
Sep 6, 2023

Conversation

mcwitt
Copy link
Collaborator

@mcwitt mcwitt commented Aug 18, 2023

Adds a generic implementation of Hamiltonian replica exchange (HREX) and a specialized version for use with RBFE implemented using the former.

Notes

  • This implements a variant of nearest-neighbor HREX (described in 1) that performs many consecutive nearest-neighbor swap attempts per iteration to generate effectively uncorrelated permutations. The matrix of energies by replica and state is computed only once per iteration, so the cost is amortized over many neighbor swap attempts.
  • We use the heuristic $K^3$ for number of neighbor swap attempts per iteration, where $K$ is the number of states. This is derived from the empirical bounds of $K^3$ to $K^5$ in 1.
  • This does not yet switch to using HREX as the default method for production RBFE calculations (i.e. run_leg functions).

To do

  • Add benchmark comparing RBFE performance with and without HREX enabled
  • Avoid modifying global PRNG state
  • Verify / tune added nightly tests

Example plots

Test system: evenly-spaced overlapping Gaussians

transition_matrix accept_rates_convergence replica_state_counts replica_state_counts_heatmap replica_state_counts_convergence

@mcwitt mcwitt marked this pull request as ready for review August 28, 2023 16:46
@mcwitt mcwitt requested a review from maxentile August 28, 2023 17:09
Copy link
Collaborator

@maxentile maxentile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 -- nice!

Only nits in this pass, will attempt some tire-kicking before completing review.

timemachine/md/moves.py Outdated Show resolved Hide resolved
timemachine/md/moves.py Outdated Show resolved Hide resolved
timemachine/md/hrex.py Outdated Show resolved Hide resolved
@mcwitt
Copy link
Collaborator Author

mcwitt commented Sep 6, 2023

Test expansion request: can we add an HREX workload to the performance benchmarking script test_benchmark.py?

Not a full free energy calculation, but running a solvent leg and complex leg with a couple settings of n_windows (maybe 10, 20, 50) for about 30 seconds - 1 minute each? Would be helpful to keep an eye on relative costs of swap attempts vs. MD.

@maxentile I added a nightly benchmark in 33f0e72.

This currently just prints ns per day estimates for sequential and HREX simulations for vacuum, solvent, and complex legs with 5, 10, and 20 windows. (More than 20 is difficult to run in a reasonable time with the restriction that we keep the ratio of MD to HREX swap moves constant)

@mcwitt mcwitt enabled auto-merge (squash) September 6, 2023 21:41
@mcwitt mcwitt merged commit 3c0cc2b into master Sep 6, 2023
@mcwitt mcwitt deleted the hrex branch September 18, 2023 23:03
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.

4 participants