Repository navigation
Secondary structure - #1644
Open
carlocamilloni wants to merge 4 commits into
Open
Secondary structure#1644carlocamilloni wants to merge 4 commits into
carlocamilloni wants to merge 4 commits into
Conversation
…ngle actions, on the CPU and on the GPU ALPHARMSD, ANTIBETARMSD and PARABETARMSD compute the number of segments that are similar to a helix or a sheet with ALPHARMSD_SCALAR, ANTIBETARMSD_SCALAR and PARABETARMSD_SCALAR (SecondaryStructureCount), instead of the sum of the chain of vector actions. The segments are built from the lengths of the chains (for the sheets as pairs of strands, with the rules of the shortcuts, see getSheetPairs), the pairs further apart than STRANDS_CUTOFF cost one distance, and the derivatives are added to the atoms while the segments are computed: there is no backward pass and no vector with an element per segment. With two references the derivatives are computed only for the lowest one and only when the switching function is not constant. OpenMP with per-thread buffers, MPI split of the segments. The shortcuts keep the vectors of the expanded input with the same labels: they are computed only when another action uses them. The results are the same as the sums of the vectors (regtests rt-sheet-scalar, rt-alpha-scalar). With USEGPU and TYPE=DRMSD the openaccPTM plugin computes the same with *_SCALAR_ACC: a kernel lists the pairs within STRANDS_CUTOFF, one GPU thread per segment computes it with the same functions as the CPU (SecondaryStructureCount.h) and adds the derivatives with atomics, a last kernel sums the values and the virial (regtest rt-GPU-sheet-scalar). With USEGPU and the RMSD types the vectors are used as before. 144 peptides, the three variables: 298 -> 41 ms per step on one core, 100 -> 7.8 ms on 32 cores, 152 -> 2.3 ms on one A100. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016vwxtV46v5FLckcMEcJrbt
…pairs whose switching function is zero
Behaviour change, listed in CHANGES and in the migration guide:
- ANTIBETARMSD and PARABETARMSD use STRANDS_CUTOFF=1 (nm, converted with
UNITS) by default; STRANDS_CUTOFF=0 uses all the pairs of strands.
- With R_0, NN, MM and D_0 (no LESS_THAN) the switching function of
ALPHARMSD, ANTIBETARMSD and PARABETARMSD gets the D_MAX that
SwitchingFunction::set(nn,mm,r0,d0) uses for the other actions (where the
function is 1e-5) and is stretched to zero there. LESS_THAN={RATIONAL
R_0=0.08 NN=8 MM=12} gives the previous function (the number of segments
is then the lessthan component).
Checked against the previous build with explicit STRANDS_CUTOFF=1 and
LESS_THAN={... D_MAX=...}: identical values and forces.
When the switching function is zero beyond a finite distance, the single
action (CPU and GPU) also skips the pairs of strands whose central CA atoms
are further apart than a distance computed from the references plus the
radii of the two strands: a lower bound of the distance of the segment from
every reference is then above D_MAX (DRMSD: the distances between the
strands; RMSD: the radii of gyration). The result does not change (equal to
the sum of the vectors, which compute every pair): ANTIBETARMSD with
STRANDS_CUTOFF=0 on 144 peptides 930 -> 160 ms per step on one core.
D_MAX is written in the log of the single action.
Documentation: "Strands cutoff" section, D_MAX in the LESS_THAN examples and
in the keywords. Regtest references updated (only the columns of the three
variables change); rt-sheet-scalar and rt-GPU-sheet-scalar have pairs with
STRANDS_CUTOFF=0.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016vwxtV46v5FLckcMEcJrbt
…parallel The derivative buffers of the nt threads (3 natoms+9 each) were cleared and summed by one thread, so that 32 threads were slower than 8 for ALPHARMSD on 432 segments (0.91 vs 0.47 ms). The buffers are now cleared with a loop over the nt buffers and summed with a loop over the derivatives, both shared between the threads (correct also when fewer than nt threads run, same order of the sums), and the radii of the strands are computed in the same parallel region: 0.51 ms on 32 threads; the three variables on 144 peptides 7.5 -> 6.1 ms. Timings in CHANGES and README. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016vwxtV46v5FLckcMEcJrbt
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #1644 +/- ##
==========================================
+ Coverage 88.96% 88.98% +0.01%
==========================================
Files 652 655 +3
Lines 81934 82131 +197
==========================================
+ Hits 72890 73081 +191
- Misses 9044 9050 +6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…CUTOFF=0 They were measured with the default STRANDS_CUTOFF (1 nm): the inputs of the benchmark did not set STRANDS_CUTOFF=0. With STRANDS_CUTOFF=0 the exact skipping of the pairs whose switching function is zero leaves about 10 times more segments than the cutoff: ANTIBETARMSD on 144 peptides takes 160 ms per step on one core, 13 ms with the default cutoff. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016vwxtV46v5FLckcMEcJrbt
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
[ALPHARMSD], [ANTIBETARMSD] and [PARABETARMSD] now compute the number of segments that are similar to a helix or a sheet with
a single action, on the CPU and (with
USEGPU) on the GPU, instead of the chain of vector actions created by the shortcuts.For large systems this is up to 16 times faster on 32 CPU cores and about 85 times faster on the GPU than master.
ANTIBETARMSD and PARABETARMSD also get new defaults:
STRANDS_CUTOFF=1(nm), and aD_MAXfor the default switching function(also for ALPHARMSD). These defaults change the results of inputs that do not set these keywords; how to get the previous
behaviour is explained below.
The branch is based on master. The GPU actions (
*_SCALAR_ACCin the openaccPTM plugin) use only the device utilities that are alreadyon master and do not depend on the task manager, so this PR is independent of the openaccPTM-multigpu PR.
Secondary structure
Single actions
ALPHARMSD_SCALAR,ANTIBETARMSD_SCALAR,PARABETARMSD_SCALAR(src/secondarystructure/SecondaryStructureCount.h/.cpp).They build the segments from the lengths of the chains (for the sheets, as pairs of strands, with the same rules as the shortcuts),
compute the distance of each segment from the references, the lowest one (PARABETARMSD) and the switching function, and add the
derivatives to the atoms in the same pass: there is no backward pass and no vector with an element per segment.
With two references the derivatives are computed only for the lowest one, and only when the switching function is not constant.
label_rmsd,label_lt,label_cut, ...).They are computed only if another action uses them (e.g. a PRINT of the vector with LESS_THAN, or LOWEST); the value of the shortcut,
or its
lessthancomponent, comes from the single action. The results are the same as the sum of the vectors (checked in theregtests
rt-alpha-scalarandrt-sheet-scalar, which print both).USEGPUandTYPE=DRMSD, the same calculation runs on the GPU (*_SCALAR_ACCin the openaccPTM plugin), with the sameper-segment code (shared functions in
SecondaryStructureCount.h). WithUSEGPUand the RMSD types the vectors are used, as before.New defaults (results change)
STRANDS_CUTOFF=1(nm) by default: the segments whose strands (CA atoms of the central residues)are further apart do not contribute. The value is converted to the units of UNITS.
R_0,NN,MM,D_0) of the three variables has aD_MAX, where it is 1e-5(1.42 nm with the defaults), and is stretched to be zero there, as
SwitchingFunction::set(nn,mm,r0,d0)does for the other actionsthat take these keywords. Each segment within the cutoff changes by at most 1e-5.
rt33(18 peptides) the number of antiparallel segments changes by about 1.2 (out of5-58) because of the cutoff; with 144 peptides by about 10 (out of 40-460). ALPHARMSD changes by about 1e-4.
D_MAXis in the expanded input (SWITCHof the_ltand_SCALARactions) and in the log of the_SCALARaction.How to get the previous behaviour
b: ANTIBETARMSD RESIDUES=all(all pairs, function without D_MAX), usingbb: ANTIBETARMSD RESIDUES=all STRANDS_CUTOFF=0 LESS_THAN={RATIONAL R_0=0.08 NN=8 MM=12}, usingb.lessthanb: ANTIBETARMSD RESIDUES=all STRANDS_CUTOFF=1 R_0=0.1b: ANTIBETARMSD RESIDUES=all LESS_THAN={RATIONAL R_0=0.1 NN=8 MM=12}, usingb.lessthana: ALPHARMSD RESIDUES=all R_0=0.1a: ALPHARMSD RESIDUES=all LESS_THAN={RATIONAL R_0=0.1 NN=8 MM=12}, usinga.lessthanSTRANDS_CUTOFF=0uses all the pairs of strands.R_0,D_0,NN,MMused before) gives the function withoutD_MAX;with LESS_THAN the number of segments is the
lessthancomponent (the value of the action is then the vector of the distances).R_0in LESS_THAN is in the length units of UNITS (0.8 withUNITS LENGTH=A).developer-doc/Migration211.md).STRANDS_CUTOFF=1andLESS_THAN={... D_MAX=...}:identical values and forces, for the sheets and the helix.
Exact skipping of the distant pairs
When the switching function is zero beyond a finite distance (the new default, or
D_MAXin LESS_THAN), the single action alsoskips the pairs of strands that are so far apart that their segment certainly has a distance from every reference larger than
D_MAX. The bound uses the distance between the central CA atoms and the radii of the two strands (DRMSD: the distances betweenthe strands in the reference; RMSD: the radii of gyration). The result does not change (equal, to the last digit, to the sum of
the vectors, which compute every pair), and
STRANDS_CUTOFF=0becomes cheap: ANTIBETARMSD on 144 peptides (370800 pairs) takes2.4 ms per step on 32 cores (63 ms on master, with every pair computed).
Documentation
D_MAXare explained in the three shortcuts and in the LESS_THAN and R_0 keywords; the LESS_THAN examples giveD_MAX.Performance with respect to master
Leonardo Booster node (32-core Intel Xeon + one A100), nvc++ 24.5,
plumed benchmarkwith a RESTRAINT on the variables (so the forcesare computed), average time per step in ms without the slowest step. GPU runs use 8 CPU threads. Systems: the amyloid of
regtest/secondarystructure/rt33(18 peptides of 8 residues, 2520 atoms: amy1) and the same replicated 2x2x2 (144 peptides, 20160 atoms: amy2).STRANDS_CUTOFF=1, DRMSD (about 5500 / 370800 pairs of strands for each sheet);STRANDS_CUTOFF=0).cases but nocut-amy2; now it is 3.4 times faster than 32 cores (7 times faster than 8 cores) on the large system.
STRANDS_CUTOFFover the 370800 pairs (about 85 ms) and did notscale with the threads.
transfers (about 0.3 ms per step for ALPHARMSD).
D_MAX(needed for the skipping).USEGPUto the DISTANCE and LESS_THAN of the shortcuts(not part of this PR; it gave no measurable difference on the GPU and does not touch the CPU path). The PR columns were measured with
this work on top of openaccPTM-multigpu; the
*_SCALAR_ACCkernels do not use its task manager.Validation
OPTIMAL and OPTIMAL-FAST, with and without NOPBC, STYLE all/inter/intra, LESS_THAN, one and two references;
--debug-forces;MPI (
rt33-mpi, and 2 ranks on the GPU); 1 to 4 threads, also with fewer OpenMP threads than requested and without OpenMP (CI).rt-GPU-sheet-scalar(references from the CPU); compute-sanitizermemcheck and racecheck clean.
secondarystructure/rt-alpha-scalar,secondarystructure/rt-sheet-scalar,targetGPU/rt-GPU-sheet-scalar.The references of the regtests that use the defaults were updated; only the columns of the three variables change.
Related
The openaccPTM-multigpu PR also keeps the data of the actions of the task manager on the GPU between the steps instead of copying it
at every call. That speeds up the vector chain of these shortcuts on the GPU (ss-amy2 152 -> 118 ms) and the other GPU actions with large
inputs, but it is not needed by this PR. The two PRs merge without conflicts, in either order.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_016vwxtV46v5FLckcMEcJrbt