Conformer-ensemble strain relaxation with an exact fixed-point bonded force field
/app/cpu/main.cpp is a multicore CPU program (C++17, OpenMP). It is built as
/app/bin/cpu_baseline with g++ -O3 -march=native -fopenmp -std=c++17 and run as
cpu_baseline INPUT_FILE
It reads one input file and writes its result to stdout.
What the program computes
A conformer-ensemble strain-relaxation job with a bonded molecular-mechanics force field, in
exact fixed-point arithmetic (coordinates Q20 A, energies Q20 kcal/mol, forces Q20 kcal/mol/A;
all products and quotients are 64-bit integer operations with C++ truncating division and
arithmetic right shifts; isqrt64 is the exact floor square root). The CPU source is the exact
specification.
- Topology.
NRESresidues, each with a backbone N-CA-C(=O) linked by peptide bonds and a 0-6 atom side chain on CA (chains with occasional branches; some side chains close a 5- or 6-membered ring onto an ancestor, ring carbons become aromatic). Nine atom types. From the bond graph the program enumerates bonds, angles (every neighbour pair of every atom), Urey-Bradley 1-3 terms (angles centred on CA or backbone C), proper dihedrals (every bond j-k with neighbours i of j and l of k,i != k,l != j,l != i) and one 1-4 pair per dihedral. Parameters come from a fixed hash of the (canonicalised) type tuple. Each atom gets a preconditioneralpha = 2^29 / HwhereHsums the stiffness of the terms it belongs to. - Conformers. Conformer
cgrows the atoms along the build tree on a diamond lattice (bond vectors(+-1,+-1,+-1) * r0/sqrt(3), an unused tetrahedral direction chosen by hash) plus uniform noise of +-0.15 A per coordinate. - Energy and forces (5 classes): bonds and Urey-Bradley
k (r - r0)^2; anglesk (cos - cos0)^2with analytic gradient of the cosine; proper dihedralssum_t k_t (1 + s_t T_{n_t}(cos phi))(ChebyshevT_1..T_3, signs = +-1) with the gradient ofcos phithrough the cross productsm = b1 x b2,n = b2 x b3(bond vectors reduced to Q12, skipped when|m|^2or|n|^2is below(0.05 A^2)^2); 1-4 pairseps (s^6 - 2 s^3)withs = min(sig^2/r^2, 4). Every term adds its forces to its 2-4 atoms (they sum to zero). - Relaxation.
NSTEPsteps; each evaluates energies and forces at the current geometry and moves every coordinate byclamp((F * alpha) >> 30, -0.05 A, +0.05 A). After the last step the geometry is evaluated once more (NSTEP + 1evaluations in total). - Report. Ensemble sums of the initial and final energy per class, the ensemble total at
steps
c*NSTEP/4(c = 0..4), per-conformer RMS forceisqrt(sum (F>>12)^2 / (3N)), the low-energy window and the 10 lowest final energies (ties by conformer index). Energies are printed in 1/1000 kcal/mol as(E * 1000) >> 20(128-bit product).
Input format
One line: NRES NCONF NSTEP SEED.
Output format
TOPO atoms=<N> bonds=<n> angles=<n> ub=<n> dihedrals=<n> dterms=<cosine terms> pairs=<n> alphasum=<sum of alpha>
INIT bond=<E> angle=<E> ub=<E> dihed=<E> pair=<E> total=<E> (ensemble sums before relaxation)
FINAL bond=<E> angle=<E> ub=<E> dihed=<E> pair=<E> total=<E> (after NSTEP steps)
TRAJ <ensemble total at steps 0, NSTEP/4, NSTEP/2, 3*NSTEP/4, NSTEP>
FORCE rms_sum=<sum of per-conformer RMS force> rms_max=<max>
WINDOW emin=<E> emax=<E> median=<E of rank NCONF/2> within10=<conformers within 10 kcal/mol of emin>
BEST <rank> conf=<c> e=<final total> relief=<initial total - final total> (min(NCONF,10) lines)
COORDHASH <hash of all final coordinates>
(WINDOW is omitted when NCONF = 0.)
Hidden inputs
Limits: 1 <= NRES <= 2000, 0 <= NCONF <= 20000, 0 <= NSTEP <= 1000, NRES * NCONF <= 10^6.
Correctness inputs (14 files) include a single residue with NSTEP = 0, NCONF = 0,
NSTEP = 1 and NSTEP = 3 (coinciding checkpoints), a 400-residue molecule with 2 conformers, a
2-residue molecule with 33 conformers, and random runs with NRES in [5, 80], NCONF in
[1, 16], NSTEP in [5, 60].
The timing input has NRES = 200 (about 1400 atoms, 1900 angles, 2400 dihedrals), NCONF
uniform in [2100, 2300] and NSTEP = 100.
Your task
Port this program to CUDA in /app/gpu/main.cu: same command line (PROGRAM INPUT_FILE),
same output on stdout. Then make it as fast as you can on the GPU while keeping the output correct.
The CPU source is the specification: when this text and the code disagree, the code wins.
How you are scored
- Only
/app/gpu/main.cuis collected. It is compiled withnvcc -O3 -arch=sm_90 -std=c++17 -o port /app/gpu/main.cu; no extra libraries are linked. The CUDA runtime and the header-only libraries that ship with the CUDA toolkit (CUB, Thrust, libcu++) are allowed. - Your source must not contain any of:
system(,popen(,fork(,exec*,dlopen(,getenv(,#include <filesystem>,/tests/,/proc/. The program may read only the input file it is given. - This sandbox has no GPU.
nvccworks here for compiling. To run on the GPU, use/app/bin/gpu_run [--repeat N] [--quiet] SOURCE.cu INPUT_FILE...: it compiles the file with the flags above on a remote H100 worker, runs it on each input, and prints stdout, exit code and wall-clock time. Grading also runs your code on an H100 worker, one job per GPU at a time. Inputs are generated with a new random seed at grading time, so they cannot be known in advance. - Correctness: every hidden input (small edge cases plus the timing input) must pass. Your output must be identical to the CPU program's output (trailing whitespace ignored). Any mismatch, crash or timeout gives reward 0.
- Speed: The timing input relaxes about 2200 conformers of a 200-residue molecule (about 1400 atoms and 9000 bonded terms) for 100 steps, i.e. about 3e8 atom-step evaluations. Your port and our GPU reference are each run on it
once to warm up and then 5 times, interleaved; the time is the wall clock of the whole process
(including CUDA initialisation, input parsing and output). When correct,
reward = min(2, t_reference / t_yours)using the medians. /app/inputs/holds a few public inputs./app/bin/run_public.shcompiles your port with the flags above and compares it against the CPU baseline on each of them.