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

Replica exchange exchanging biases #1184

Open
GiovanniBussi opened this issue Jan 23, 2025 · 3 comments
Open

Replica exchange exchanging biases #1184

GiovanniBussi opened this issue Jan 23, 2025 · 3 comments

Comments

@GiovanniBussi
Copy link
Member

GiovanniBussi commented Jan 23, 2025

Currently, we only support replica exchange where coordinates are exchanged. This is necessary to avoid the need to "transfer the plumed object" to a different replica.

There's one special case however that could be straightforward to implement namely:

  • all plumed files are identical to each other, except for a replica-dependent scaling factor applied in front of the bias
  • there's no history dependence (e.g. no METAD)

In this case, it is conceivable to have an action like this:

EXCHANGEABLE_BIASVALUE ARG=bb FACTORS={0.0 0.2 0.4 0.6 0.8 1.0} PACE=1000 HISTORY=exchanges.dat

This action would store the current permutation of factors and, instantaneously, apply a the corresponding factor to the current replica. It would then try an exchange every 1000 paces, and append the permutation to the exchange.dat file, so that it can be read when restarting.

To have slightly more flexibility, we could have an array of arguments, e.g.

EXCHANGEABLE_BIASVALUE ...
  ARG=bb1,bb2
  FACTORS={{0.0 1.0} {0.2 0.8} {0.4 0.6} {0.6 0.4} {0.8 0.2} {1.0 0.0}}
  # this would interpolate between bb1 and bb2 across six replicas
  PACE=1000 HISTORY=exchanges.dat
...

This could even enable replica exchange umbrella sampling

c1: CUSTOM ARG=d FUNC=x^2 PERIODIC=NO
c2: CUSTOM ARG=d FUNC=(x-0.1)^2 PERIODIC=NO
c3: CUSTOM ARG=d FUNC=(x-0.2)^2 PERIODIC=NO
c4: CUSTOM ARG=d FUNC=(x-0.3)^2 PERIODIC=NO
c5: CUSTOM ARG=d FUNC=(x-0.4)^2 PERIODIC=NO
c6: CUSTOM ARG=d FUNC=(x-0.5)^2 PERIODIC=NO
EXCHANGEABLE_BIASVALUE ...
  ARG=c1,c2,c3,c4,c5,c6
  FACTORS={
  {1 0 0 0 0 0}
  {0 1 0 0 0 0}
  {0 0 1 0 0 0}
  {0 0 0 1 0 0}
  {0 0 0 0 1 0}
  {0 0 0 0 0 1}
  }
  PACE=1000 HISTORY=exchanges.dat
...

Nicely, this would work with all codes that support multiple replicas (including the vanilla gromacs versions, when this will be merged).

Any comments on the syntax/usability?

@ollyfutur
Copy link

Some suggestions on the syntax:

  • Use FILE instead of HISTORY for consistency with, e.g, METAD
  • EXCHANGEABLE_BIASVALUE sounds a bit verbose, I wonder if BIASEXCHANGE could do the job
  • also maybe COEFFICIENTS instead of FACTORS for consistency with COMBINE

Is there a specific reason to choose the {a b c} notation instead of the usual a,b,c (also consistent with the @replicas syntax)?

I would maybe argue that intuitively this

EXCHANGEABLE_BIASVALUE ...
  ARG=c1,c2,c3,c4,c5,c6
  FACTORS={
  {1 0 0 0 0 0}
  {0 1 0 0 0 0}
  {0 0 1 0 0 0}
  {0 0 0 1 0 0}
  {0 0 0 0 1 0}
  {0 0 0 0 0 1}
  }
  PACE=1000 HISTORY=exchanges.dat
...

could be the implied default to

EXCHANGEABLE_BIASVALUE ...
  ARG=c1,c2,c3,c4,c5,c6
  PACE=1000 HISTORY=exchanges.dat
...

equivalent to

EXCHANGEABLE_BIASVALUE ...
  ARG=c1,c2,c3,c4,c5,c6
  FACTORS=1,1,1,1,1,1
  PACE=1000 HISTORY=exchanges.dat
...

It makes sense to me intuitively that each "ARG" is interpreted as one "exchangeable bias". With this perspective

EXCHANGEABLE_BIASVALUE ARG=bb FACTORS={0.0 0.2 0.4 0.6 0.8 1.0} PACE=1000 HISTORY=exchanges.dat

can be rewritten

EXCHANGEABLE_BIASVALUE ARG=bb,bb,bb,bb,bb,bb FACTORS=0.0,0.2,0.4,0.6,0.8,1.0 PACE=1000 HISTORY=exchanges.dat

Though the repetition may be undesirable… But the case where we are using different scalings of the same bias seems more like a special case than the general case. What do you think?

@GiovanniBussi
Copy link
Member Author

GiovanniBussi commented Jan 24, 2025

Thanks @ollyfutur !

Use FILE instead of HISTORY for consistency with, e.g, METAD

Good point

EXCHANGEABLE_BIASVALUE sounds a bit verbose, I wonder if BIASEXCHANGE could do the job

I agree EXCHANGEABLE_BIASVALUE is quite verbose. But I would avoid BIASEXCHANGE or people will associate it immediately with bias exchange metadynamics.

also maybe COEFFICIENTS instead of FACTORS for consistency with COMBINE

Good point

Is there a specific reason to choose the {a b c} notation instead of the usual a,b,c

Both are possible (comma separated or space separated), and equivalent. I prefer to use space separated when there are matrices involved.

About the default COEFFICIENTS, I have to think about it. In the most general case:

  • ARG has L elements
  • COEFFICIENTS has M x N elements

Then, perhaps:

  • an empty COEFFICIENTS argument could implicitly be set to an NxN identity matrix.
  • a vector COEFFICIENTS argument (with N elements) could implicitly be set to an 1xN matrix

The result would be:

For replica exchange umbrella sampling

EXCHANGEABLE_BIASVALUE ARG=c1,c2,c3,c4,c5,c6 PACE=10000 FILE=exchanges.dat
# equivalent to:
EXCHANGEABLE_BIASVALUE ...
  ARG=c1,c2,c3,c4,c5,c6
  COEFFICIENTS={
  {1 0 0 0 0 0}
  {0 1 0 0 0 0}
  {0 0 1 0 0 0}
  {0 0 0 1 0 0}
  {0 0 0 0 1 0}
  {0 0 0 0 0 1}
  }
 PACE=10000 FILE=exchanges.dat
...

For interpolation between two potentials

EXCHANGEABLE_BIASVALUE ...
  ARG=bb1,bb2
  COMPONENTS={{0.0 1.0} {0.2 0.8} {0.4 0.6} {0.6 0.4} {0.8 0.2} {1.0 0.0}}
  # this would interpolate between bb1 and bb2 across six replicas
  PACE=1000 FILE=exchanges.dat
...

For scaling across replicas*

EXCHANGEABLE_BIASVALUE ...
  ARG=bb
  COMPONENTS={0.0 0.2 0.4 0.6 0.8 1.0}
  PACE=1000 FILE=exchanges.dat
...




Un

@ollyfutur
Copy link

ollyfutur commented Jan 24, 2025

Another suggestion is REPLEX_BIASVALUE

So these "broadcasting rules" for $N$ input CVs and $M$ replicas:

ARG COEFFICIENTS IMPLIED BIASES
($1$) $a$ ($M$) $c_1,c_2,…,c_M$ $[c_1a\ c_2a\ …\ c_Ma]$
($M$) $a_1,…,a_M$ — (default: $1,…,1$) $[a_1\ …\ a_M]$
($M$) $a_1,…,a_M$ ($M$) $c_1,c_2,…,c_M$ $[c_1a_1\ …\ c_Ma_M]$
($N$) $a_1,…,a_N$ ($M×N$) $[[c_{11}\ …\ c_{1N}] … [c_{M1}\ …\ c_{MN}]]$ $[\sum_n^Nc_{1n}a_n\ …\ \sum_n^Nc_{Mn}a_n]$
($N$) $a_1,…,a_N$ ($M$) $c_1,c_2,…,c_M$ error
($1$) $a$ error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants