CAPSChain Assembly and Packing Suite

Theory · 3 methods

Cluster jobs

What CAPS computes, as it computes it: the equation, its symbols with CAPS's defaults, when to use the method, the source file, the tests that check it, and any departure from the cited method.

Running CAPS on a cluster

CAPS's own engines run as batch jobs on any SLURM or PBS cluster, or in the background on a workstation reached over ssh. Each host has a profile (~/CAPS/host.json on the host): the scheduler, account, partition, the module lines for jobs and for building, the CAPS folder, the scratch kind (a ws_allocate workspace, a folder under a variable such as $SCRATCH, or none), cores, memory per core, time limit and optional mail. caps job new makes a folder ROOT/TITLE/KIND-N with the inputs, cmd.txt, job.sh and caps-job.json, and --submit queues it. The job asks for one node, one task and N cores, because CAPS runs threads and not MPI ranks; CAPS_THREADS comes from the job. The script copies the inputs to scratch, runs the command in the background with its output in run.log, copies the scratch folder back to out/ and releases a workspace only after that copy succeeded. While it runs, caps md, equilibrate and run write thermo.csv, progress.jsonl and traj.lammpstrj line by line. caps job status, tail -f and poll read them from the scratch folder; the Studio's Jobs page reads the same files over one shared ssh connection, every 30 s for the job shown and every 5 min for the others. The ETA comes from the fraction done and the time elapsed.

$$t_\mathrm{left} = t_\mathrm{elapsed}\,\frac{1 - f}{f}$$

f: the fraction of the run done, from the last progress line

SymbolMeaningIn CAPS
ffraction of the run doneprogress.jsonl, written with each thermo row
t_elapsedtime since the job startedsqueue's elapsed time
t_leftthe ETAcaps job status, the Studio's Queue panel

When to use it

Runs longer than a laptop should do: production MD, equilibration protocols, Tg scans, tensile pulls, sweeps (one array job, a task per cell), coarse-graining stages. From the command line on the cluster: caps job profile --preset slurm, then caps job new --title PS --kind md --input cell.data --submit -- caps md cell.data -o out.data …. From the Studio: add the host in Settings › Compute & remote, press Install / update caps once (it builds caps at the Studio's commit as a short job), then choose the host in Run where on any simulation page. Jobs started by hand appear in the Studio with Find my jobs.

Source
core/src/cluster_job.cpp, core/src/live.cpp, cli/main.cpp (caps job), studio/CapsStudio/ViewModels/MainViewModel.Cluster.cs
Tested by
ClusterJob.* (scripts for each scheduler and scratch kind, arrays, the state file, squeue and sacct lines, the poll); tests/test_cli_job.sh (a fake SLURM cluster: submit, follow, copy back, release, arrays, a failure, a cancel); the Studio self-test (a host without a queue and a SLURM stand-in with workspaces)
Departure from the reference
none

Time limits, checkpoints and resume

The job script asks SLURM for USR1 ten minutes before the time limit (--signal=B:USR1@600) and passes it on to caps. On USR1 or TERM the MD loop finishes its step, writes a checkpoint and stops; the command writes resume.txt, the command that continues it, and exits with code 75. The script then copies the results back and records the job as timeout. caps md continues from its checkpoint (--resume). caps equilibrate continues in the stage and at the step it reached (--resume-at STAGE:STEP), with a temperature ramp picking up from where it was. caps tg skips the temperatures already done (--resume-points). caps tensile continues the pull from the strain reached, measured from the original box length (--resume-curve). Recipes skip the stages already done (--resume); a stage stopped part-way runs again from its start. Logs and trajectories are appended to, not restarted. caps job resume DIR --submit, or Resume from checkpoint on the Jobs page, makes a new job of the same title and kind from the stopped one's results.

$$\begin{gathered}L = L_0\,(1 + e_0 + \dot{\varepsilon}\,t) \\ T = T_\mathrm{start} + (T_\mathrm{end} - T_\mathrm{start})\,\frac{s}{S}\end{gathered}$$

a resumed pull keeps its engineering strain rate; a resumed ramp keeps its slope

SymbolMeaningIn CAPS
L₀box length along the pull before any strainsaved with the curve
e₀engineering strain at the checkpointthe curve's last point
ε̇engineering strain rate--rate, 1/ps
s, Ssteps done in the stage, steps in the stage--resume-at STAGE:s

When to use it

Any run that may outlast its queue's time limit. Nothing has to be switched on: in a job, caps md, equilibrate, run, tg and tensile all catch the signal. caps md can also write checkpoints at intervals (--checkpoint-every N).

Source
core/src/dynamics.cpp (DynamicsInterrupted), core/src/equilibrate.cpp, core/src/mechanics.cpp, core/src/recipe.cpp, cli/main.cpp
Tested by
Resume.* (MD, an equilibration stopped in its second stage, a cooling scan, a tensile pull, a recipe: each continued to the end an unstopped run reaches); tests/test_cli_job.sh case 5 (USR1 to a fake SLURM job, caps job resume to the full step count)
Departure from the reference
a recipe stage stopped part-way runs again from its start, so its first frames appear twice in the trajectory

How many cores a run should use

caps job scaling runs the same short MD on one structure at several thread counts, as one array job: powers of two up to the node, half the node and the whole node (from the node size the host test found). Each task has the whole node to itself, so the measurement is not crowded by its neighbours, and writes bench.json: the commit, the node, the threads, the setup and loop times, steps per second and ns/day. caps job collect-bench gives the speedup over the fewest threads and the parallel efficiency, and suggests the fastest thread count that still runs at 70 % efficiency or more. Where the curve flattens depends on the cell's size and the machine; the suggestion marks where more cores stop paying for themselves.

$$S_n = \frac{r_n}{r_1}, \qquad E_n = \frac{S_n}{n / n_1}$$

n_1: the fewest threads measured

SymbolMeaningIn CAPS
r_nns/day with n threadsbench.json
S_nspeedup over the fewest threads
E_nparallel efficiencythe suggestion: the fastest run with E ≥ 0.7

When to use it

Once per cluster and system size, before a long campaign: Settings › Compute & remote › Scaling test, or caps job scaling --input cell.data --submit, then caps job collect-bench DIR. Use a cell of the size you will run; small cells stop scaling sooner.

Source
core/src/cluster_job.cpp (scaling_threads, scaling_table), cli/main.cpp (caps md --bench-json, caps job scaling, collect-bench)
Tested by
ClusterJob.ScalingThreadsAndTable; tests/test_cli_job.sh case 6; the Studio self-test's scaling check
Departure from the reference
none