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
Speed up scoring function when used with Monte Carlo #959
Comments
Proposal: add a single-bit
This should have the advantage that it is largely transparent to the user, and restraints can use the 'moved' information more intelligently than in a simple decomposition. |
That sounds great! I'm assuming this will work on rigid bodies as well? We could potentially do some caching to incrementally update EM scoring functions (storing a list of which components contribute to each grid point and only recalculating the densities of contributors to those points) although that might require a lot of memory. |
Should do. If you change a rigid body, at model update time all of the rigid body members will get their coordinates updated, so any score that depends on either the rigid body itself or the members should notice the particles have moved and do the "right thing" automatically. |
Awesome! It also looks like this implementation could be easily parallelized. Could that be taken into account somehow? |
Not sure if you're replying to my comment or Charles's here. But model evaluation is already parallelized in IMP (at least with OpenMP) and this certainly shouldn't interfere with that. It certainly should be possible to parallelize individual restraints too, as per #832. |
one note on speed, semi-related to discussion, but strongly related to I was able to almost double the performance of the NPC BrownianDynamic I believe the main reasons that memory access becomes faster are:
An example code (from atom/src/BrownianDynamics.cpp): *// I. Get direct access to property tables: * double const* rotational_diffusion_coefficient_table= // II. Go over a bunch of particles and directly obtain values from
On Fri, Aug 5, 2016 at 11:21 AM, Ben Webb notifications@github.com wrote:
Barak |
Right, the particle |
This flag is cleared after the scoring function is calculated, and set whenever a particle is 'changed' (newly created or an attribute changed). This can be used to speed up restraint evaluation by caching part or all of the score. Relates #959.
Hi Ben, I don't know if you're still working on this, but this is very interesting and will probably give a nice boost (unless this creates a lot of cache misses due to having to fetch more data). Another possibility that I thought of would be to pass a list of movers to the restraints at each evaluation, this way the restraints know which particle have been moved. |
No, the flag is set automatically when particle attributes are changed. Unfortunately my benchmarking of the code (the existing branch is fully functional) shows a small but noticeable slowdown with MD due to the overhead of this tracking. So not acceptable in its current form. MC movers already return a list of particles that they've moved (the |
This should largely be resolved by b8c4d59 and subsequent commits. These provide an alternative path for scoring function evaluation (essentially, an Restraint subclasses can provide alternative implementations of Similarly, It is easy to activate the new code path, simply by setting the Support in more restraints and ScoreStates will be forthcoming. In particular most container restraints, for example excluded volume, don't yet support this optimization and there are large performance gains still to be made there. |
The default IMP scoring function (
RestraintsScoringFunction
) computes the model score by simply evaluating all restraints and returning their sum. This is really inefficient for sampling schemes such as Monte Carlo which rely on making a large number of small perturbations to the system, since many terms in the scoring function are needlessly recomputed at each step.There's an existing mechanism to address this:
IncrementalScoringFunction
. This works by decomposing each Restraint into simpler ones, then building a scoring function for each Particle in the system made up of sums of these simpler restraints. Moving a given Particle then only requires recomputing that Particle's scoring function. However, this approach has drawbacks:RestraintSet
information is lost.IncrementalScoringFunction
is actually slower thanRestraintsScoringFunction
.IMP needs a more efficient mechanism for partial scoring function updates in order to make Monte Carlo usable for larger systems.
The text was updated successfully, but these errors were encountered: