Testing, Verification & Benchmarking
This guide documents the test suite architecture, first-principles physics verification protocols, chunked compute-sanitizer workflows, and reproducible GPU benchmarking practices for ParticleDynamics.
1. CPU vs GPU Test Architecture
The test entrypoint is test/runtests.jl, which sets CUDA.allowscalar(false) globally so any accidental scalar GPU indexing fails immediately.
Host-Only (CPU) Tests (.github/workflows/ci-cpu.yml)
Without a CUDA device, test/runtests.jl validates 54,947 checks across 13 CPU test files covering host mathematics, B2ProlateWindow / fewest-PSWF quadrature, configuration/API invariants, public exports, and static source audits:
test/test_neighbor_reference.jl(againsttest/neighbor_reference.jl)test/test_rigid_water_math.jl(SETTLE/RATTLE algebra & double-float math)test/test_periodic_displacement_math.jl(minimum-image displacement identities)test/test_w1_recip_octant_math.jl(orthorhombic octantG_oct/Vc_oct& even-preferring smooth mesh snapping)test/test_w1_runtime_cpu.jl(graph scheduling, runtime config & Philox MUFU math)test/test_w2_autotune_dualrc_cpu.jl(verlet_buffer_skin,tune_pme_parameters,P = 5stencil math & static LOC/hygiene audit)test/test_w3_respa_cpu.jl(check_respa_stability,respa_engine_config, symplectic impulse-RESPA algebra & static audit)test/test_friction_rate_cpu.jl(uniformfriction_rate/tauLangevin & barostat API validation)test/test_public_exports_cpu.jl,test/test_static_hygiene_cpu.jl,test/test_coverage_gaps_cpu.jl,test/test_v105_quadrature_cpu.jl,test/test_pme_kernels_cpu.jl
When gpu_required() is false, the GPU @testset skips cleanly so hosted CPU CI validates package loading, host algebra, and documentation builds (docs/make.jl).
Full GPU Suite (.github/workflows/ci-gpu-selfhosted.yml)
On a CUDA-capable machine, run:
julia --project --startup-file=no test/runtests.jlOr run targeted subsystem test files directly during development:
julia --project --startup-file=no test/test_p1e2_direct_pairs_gpu.jl
julia --project --startup-file=no test/test_p1e2_scatter_prune_gpu.jl
julia --project --startup-file=no test/test_p1e2_general_constr_gpu.jlThe GPU suite combines:
First-principles physics & analytic oracle checks:
Independent Float64 CPU Ewald oracle (
test/ewald_reference.jl) and dispersion Ewald oracle (test/dispersion_reference.jl) with finite-difference cell-strain virial checks.Independent GPU all-pairs pair-force oracles (
test/gpu_force_reference.jl,test/pair_reference_gpu.jl,test/test_force_precision_gpu.jl).NVE energy drift, NVT kinetic temperature & equipartition, NPT target pressure & compressibility/density equilibrium, constraint bond-length drift (
< 1e-6in Float32:df64,< 1e-13in Float64), and Newton-3 momentum conservation (||Σ F|| / ||F||).
External golden regression fixtures (
test/golden_fixtures.jl,test/README.md):Checksum-verified historical records (
SHA256SUMS) for deterministic trajectories (v1-20261009T122031), engine regression states (v3-engine-tests), and 2D/3D equilibrium ensembles (v2-eq-*).Controlled via environment variables:
PD_GOLDEN_ROOT=/path/to/golden-staged— root directory holding the 4 dataset folders (or per-datasetPD_GOLDEN_DIR,PD_ENGINE_GOLDEN_DIR,PD_GOLDEN_EQ2D,PD_GOLDEN_EQ3D).PD_REQUIRE_GOLDEN=1— fail instead of skipping if any golden dataset is missing (required for release validation).PD_GOLDEN_DOWNLOAD=yes|no|askandPD_GOLDEN_URL— unattended download control.
GPU residency & kernel-hygiene assertions:
test/test_gpu_residency.jlconfirms zero host copies for state/thermostat buffers.Direct-pair, bonded, constraint, and fusion suites assert
CUDA.memory(k).local == 0and absence of.localin PTX.
Chunked compute-sanitizer Runs
Running compute-sanitizer --tool memcheck --error-exitcode=99 slows GPU kernels by ~10-50x. Heavy verification suites expose subset environment variables so sanitizer checks stay fast and CI-friendly:
| Test File | Environment Variable | Example Values |
|---|---|---|
test/test_p1de_custom_potentials_gpu.jl | PD_P1DE_SAN_PART | all, individual part selectors |
test/test_p1de_solute_dry_fuse_gpu.jl | P1DE_SAN_PART | all, 2B, 4, etc. |
test/test_p1de_workflow_npt_gpu.jl | PD_P1DE_SUBSET | all, subset selectors |
# Example: chunked memcheck pass with strict non-zero exit code on any hazard
P1DE_SAN_PART=2B compute-sanitizer --tool memcheck --error-exitcode=99 \
julia --project --startup-file=no test/test_p1de_solute_dry_fuse_gpu.jl2. Single-Frame Force Accuracy Parity Protocol
Whenever optimizing direct-space kernels (ClusterPairs), reciprocal-space meshes (Electrostatics), CompactFFT, or constraint/bonded force paths, validate single-frame force accuracy against a converged 128^3 Float64 reference (or exact CPU Ewald test/ewald_reference.jl for small boxes) on identical atomic coordinates before running throughput benchmarks:
Freeze one representative condensed-phase frame (e.g., solvated biomolecule, neat water box, or molten salt) in
Float64coordinatesR_refand boxbox_ref.Compute the reference forces
F_ref, energyU_ref, and virialW_ref:For small
N <= 1000: direct CPU Ewald (EwaldReference.ewald_referenceintest/ewald_reference.jl,digits=16) andDispersionReference.dispersion_reference(test/dispersion_reference.jl,digits=15).For large production systems (
N >= 10^4): evaluate the exact same coordinates inFloat64precision with a converged128 x 128 x 128smooth PME /C²-ESPmesh (order=6, tightreal_space_tolerance=1e-7,force_accumulation=:float64) viaevaluate_configuration!.
Evaluate the candidate Float32 / optimized configuration on the exact same frozen coordinates (
evaluate_configuration!, testing bothforce_accumulation=:float32and:fixed64, and bothenergy=falseforce-only andenergy=truepaths).Verify parity metrics:
Relative RMS force error:
norm(F - F_ref) / norm(F_ref)— must match the target splitting/mesh tolerance (typically~1e-4to5e-4for production Float32C²-ESP/PME,< 1e-5for pure Float32 LJ, and< 1e-11for Float64).Net-force momentum neutrality:
norm(sum(F; dims=2)) / norm(F_ref)(< 1e-6for Float32,< 1e-13for Float64).Potential energy & virial agreement:
|U - U_ref| / max(|U_ref|, 1)andnorm(W - W_ref) / max(norm(W_ref), 1).Exact equivalence against unfused baseline: When validating pure algorithmic optimizations (e.g.,
SLJP2, scatter-into-BAOAB fusion,CompactFFT, SMEM general constraints), compare Float32 candidate vs Float32 reference directly — expect ULP-level agreement (0to a few ULPs, or bitwise identical under:fixed64).
3. Reproducible GPU Benchmarking Protocol
Standard Throughput Metric & Harness Rules
Primary Metric: Report wall-clock
steps/s(n_steps / elapsed_s, andms/step = 1000 / steps_per_s). Never report single-step timings or un-synchronized launch times.Mandatory Warm-Up: Run at least 200-500 warm-up steps before timing so that:
All CUDA kernels compile (
@cuda),StateEnginecaptures single-step, batch, and NPT super-batch graphs (e.batches),MeshTunecompletes its 40-step warm-up + 64-step alternating priority calibration (MESH_TUNE_WARM + 2 * MESH_TUNE_BLOCK * MESH_TUNE_ROUNDS = 104fast launches), andGPU clocks stabilize at steady-state boost frequency.
Median of 3 Repeats: Measure 3 independent timed windows (e.g.,
2,000-10,000steps each viastep_many!orrun!(sim, Stage(...))) bracketed byCUDA.synchronize()beforetime_ns()start and stop. Report the median of the 3 repeats (and note min/max spread if> 1%).Equilibrium Sanity Gate: Every benchmark configuration MUST also pass a short physics sanity check confirming it did not drift or explode:
Mean kinetic temperature
<T>within statistical error ofT_target(checkingkinetic_dof(st)accounts for allRigidWaterandConstraintClustersDOF),Mean volume
<V>and mass density<ρ>stable under NPT (DeviceCRescaleorMonteCarloBarostatSpec),Maximum constraint bond-length error (
max |r_ij - d_ij|) within tolerance,Zero latched errors (
NL.device_neighbor_status(st.engine.run.neighbors).error == 0) and zero unexpectedst.engine.recoveriesin steady state.
# Minimal reproducible timing skeleton
function benchmark_steps_per_sec(st, spec, dt; warmup=500, nsteps=5000, repeats=3)
step_many!(st, spec, dt, warmup; compute_energy=false)
CUDA.synchronize()
rates = Float64[]
for _ in 1:repeats
CUDA.synchronize()
t0 = time_ns()
step_many!(st, spec, dt, nsteps; compute_energy=false)
CUDA.synchronize()
elapsed = (time_ns() - t0) * 1e-9
push!(rates, nsteps / elapsed)
end
sort!(rates)
return (median=rates[2], min=rates[1], max=rates[3])
endNsight Systems Graph Profiling (nsys)
Because DeviceEngine executes inside captured CUDA graphs and super-batches, always pass --cuda-graph-trace=node to NVIDIA Nsight Systems so individual kernel nodes inside each graph appear in the timeline and summary stats (instead of a single opaque cudaGraphLaunch bar):
nsys profile \
--trace=cuda,nvtx \
--cuda-graph-trace=node \
--force-overwrite=true \
-o pd_profile \
julia --project --startup-file=no my_benchmark.jl
# Inspect per-kernel GPU time breakdown from the captured trace:
nsys stats --report cuda_gpu_kern_sum pd_profile.nsys-repUse NVTX ranges around the timed window (CUDA.@profile or NVTX.@range "production") and set DeviceEngine.with_engine_config(batch_graph=...) to compare single-step vs K-step super-batch launch overhead directly in the timeline.
4. Verified v1.2.0 Benchmarks & Numerical Accuracy (NVIDIA GeForce RTX 3090)
Measured on an isolated NVIDIA GeForce RTX 3090 (Float32, :fixed64 force accumulation, :df64 rigid-water and solute constraints, Julia 1.13.4, clock-locked warmup, median of 3 replicates, reported in steps/s):
| System | Atoms | Configuration | Mesh | Throughput (steps/s) | |
|---|---|---|---|---|---|
| DHFR | 23,558 | LJPME 0.70 nm 5e-4, BAOAB (4 fs HMR) | 5 | 36³ | 8,886 |
| DHFR | 23,558 | LJPME 0.70 nm 5e-4, RESPA M=2 (4 fs HMR) | 5 | 36³ | 9,640 |
| DHFR | 23,558 | LJPME 0.70 nm 1e-4, BAOAB (4 fs HMR) | 6 | 36³ | 8,157 |
| DHFR | 23,558 | ESP 0.90 nm 5e-4, CSVR (4 fs HMR) | 5 | 27³ | 9,147 |
| BACE | 69,983 | LJPME 0.70 nm 5e-4, NPT-MC M=1 / M=2 | 5 | 48³ | 3,536 / 3,872 |
| BACE | 69,983 | LJPME 0.70 nm 5e-4, NPT-CR M=1 / M=2 | 5 | 48³ | 3,686 / 3,997 |
| ApoA1 | 92,224 | LJPME 0.70 nm 5e-4, BAOAB / RESPA M=2 | 5 | 60³ | 2,718 / 3,002 |
| ApoA1 | 92,224 | ESP 0.90 nm 5e-4, CSVR (4 fs HMR) | 5 | 48³ | 2,842 |
| Water 100k | 100,002 | LJPME 0.70 nm 5e-4, BAOAB / NPT-CR (4 fs) | 5 | 54³ | 3,175 / 3,122 |
| Water Slab | 8,100 | LJPME 1.00 nm 1e-4 (2 fs, 4.5×4.5×16 nm) | 5 | 24×24×84 | 15,184 |
| Water 24k | 24,000 | LJPME 0.90 nm 1e-4, BAOAB / CSVR (2 fs) | 5 | 36³ | 8,706 / 8,612 |
Rank-1 SVD Lorentz–Berthelot dispersion charges cut heterogeneous 36.53% → 2.35%) and Float64 unwrapped coordinates hold displacement drift at 4.75e-8 nm.
5. Cross-Engine Comparison (v1.2.0 vs. OPcuPO & GROMACS 2026.2, NVIDIA GeForce RTX 3090)
All throughput results below were measured on an isolated NVIDIA GeForce RTX 3090 (Float32, deterministic :fixed64 force accumulation, default B2ProlateWindow P=5 electrostatics, default :df64 SETTLE and ConstraintClusters, median of 5 repeats, steps/s, higher is faster) following the public NVIDIA/cuPotential (nv-openmm-plugin 0.3.5, denoted OPcuPO) biomolecular protocol (4 fs HMR 1.5 amu, rigid TIP3P SETTLE, HBonds ConstraintClusters, AMBER 1–4 scaling, barostat interval = 25) and the general-purpose 2 fs SPC/E water and 5 M NaCl protocol (298 K).
A. Truncated-LJ PME 0.90 nm — Biomolecular & 100k-Water Suite (M=1 Zero-MTS & M=2 RESPA)
| System (Atoms, Mesh) | Mode | ParticleDynamics v1.2.0 (steps/s) | OPcuPO (M=1, steps/s) | Ratio vs OPcuPO |
|---|---|---|---|---|
dhfr (23,558, 27³) | NVT (M=1) / NPT-MC (M=1) / NPT-CR (M=1) | 8,733 / 7,970 / 8,475 | 9,219 / 8,346 / 8,346 (MC) | 0.95× / 0.95× / 1.02× |
NVT (M=2 RESPA) | 9,123 | 9,219 | 0.99× | |
tyk2 (48,940, 36³) | NVT (M=1) / NPT-MC (M=1) / NPT-CR (M=1) | 5,016 / 4,613 / 4,942 | 5,502 / 4,800 / 4,800 (MC) | 0.91× / 0.96× / 1.03× |
NVT (M=2 RESPA) | 5,247 | 5,502 | 0.95× | |
bace (69,983, 40³) | NVT (M=1) / NPT-MC (M=1) / NPT-CR (M=1) | 3,744 / 3,479 / 3,734 | 4,143 / 3,677 / 3,677 (MC) | 0.90× / 0.95× / 1.02× |
NVT (M=2 RESPA) | 3,937 | 4,143 | 0.95× | |
apoa1 (92,224, 48³) | NVT (M=1) / NPT-MC (M=1) / NPT-CR (M=1) | 2,818 / 2,632 / 2,762 | 2,878 / 2,607 / 2,607 (MC) | 0.98× / 1.01× / 1.06× |
NVT (M=2 RESPA) | 2,990 | 2,878 | 1.04× | |
water_100k (100,002, 42³) | NVT (M=1) / NPT-MC (M=1) / NPT-CR (M=1) | 3,065 / 2,779 / 3,042 | 3,219 / 2,837 / 2,837 (MC) | 0.95× / 0.98× / 1.07× |
NVT (M=2 RESPA) | 3,262 | 3,219 | 1.01× |
B. Full Lattice Dispersion LJPME 0.70 nm Suite (15 / 15 Faster than OPcuPO)
| System (Atoms, Mesh) | PD v1.2.0 NVT (M=1 / M=2, steps/s) | PD v1.2.0 NPT-MC / NPT-CR (steps/s) | OPcuPO NVT / NPT-MC (steps/s) | Speedup vs OPcuPO (M=1 NVT / NPT-MC / NPT-CR) |
|---|---|---|---|---|
dhfr (23,558, 36³) | 8,847 / 9,557 | 7,999 / 8,395 | 7,519 / 6,034 | 1.18× / 1.33× / 1.39× (1.27× M2) |
tyk2 (48,940, 42³) | 5,028 / 5,528 | 4,696 / 4,869 | 4,253 / 3,193 | 1.18× / 1.47× / 1.52× (1.30× M2) |
bace (69,983, 48³) | 3,744 / 4,121 | 3,503 / 3,682 | 3,385 / 2,850 | 1.11× / 1.23× / 1.29× (1.22× M2) |
apoa1 (92,224, 60³) | 2,718 / 3,017 | 2,547 / 2,645 | 2,313 / 1,953 | 1.18× / 1.30× / 1.35× (1.30× M2) |
water_100k (100,002, 54³) | 3,158 / 3,596 | 2,907 / 3,111 | 2,567 / 2,043 | 1.23× / 1.42× / 1.52× (1.40× M2) |
C. General-Purpose Liquids, Electrolytes & Pure LJ Suite (M=1, steps/s)
| System & Mode | ParticleDynamics v1.2.0 | OPcuPO | GROMACS 2026.2 GPU | Speedup vs OPcuPO / GROMACS |
|---|---|---|---|---|
spce_water (30k, 0.90 nm) NVT BAOAB / CSVR | 8,596 / 8,615 | 9,134 / — | — / 5,080 | 0.94× / 1.70× |
spce_water (30k, 0.90 nm) NPT-MC / NPT-CR | 7,813 / 8,451 | 7,930 | — / 4,834 | 0.99× (1.07× CR) / 1.75× |
spce_water (30k, 1.00 nm) NVT BAOAB / CSVR | 7,523 / 7,519 | 6,549 / — | — / 4,754 | 1.15× / 1.58× |
spce_water (30k, 1.00 nm) NPT-MC / NPT-CR | 6,826 / 7,392 | 5,907 | — / 4,547 | 1.16× (1.25× CR) / 1.63× |
nacl_5m (31.8k, 0.90 nm) NVT BAOAB / CSVR | 8,017 / 8,023 | 8,841 / — | — / 4,617 | 0.91× / 1.74× |
nacl_5m (31.8k, 0.90 nm) NPT-MC / NPT-CR | 7,298 / 7,883 | 7,785 | — / 4,416 | 0.94× (1.01× CR) / 1.79× |
nacl_5m (31.8k, 1.00 nm) NVT BAOAB / CSVR | 6,991 / 6,973 | 6,393 / — | — / 4,353 | 1.09× / 1.60× |
nacl_5m (31.8k, 1.00 nm) NPT-MC / NPT-CR | 6,337 / 6,844 | 5,848 | — / 4,180 | 1.08× (1.17× CR) / 1.64× |
argon_10k NVE / NVT CSVR (:ell) | 45,832 / 33,851 | 31,283 / — | 34,387 / 18,885 | 1.47× / 1.33–1.79× |
argon_100k NVE / NVT CSVR (:ell) | 8,215 / 7,374 | 5,302 / — | 6,752 / 3,420 | 1.55× / 1.22–2.16× |
D. Single-Frame Force Accuracy vs. Exact 128³ Float64 Ewald (#1 on 6 / 6)
| System | ParticleDynamics v1.2.0 rel_dF | rel_dE | OPcuPO rel_dF | GROMACS 2026.2 rel_dF | Rank |
|---|---|---|---|---|---|
argon_10k | 5.08e-6 | 2.25e-8 | 1.22e-5 | 9.84e-6 | #1 |
argon_100k | 1.34e-5 | 5.77e-8 | 2.61e-5 | 2.31e-5 | #1 |
spce_090 | 1.98e-4 | 1.69e-6 | 3.23e-4 | 6.08e-4 | #1 |
spce_100 | 1.53e-4 | 1.87e-6 | 3.52e-4 | 4.17e-4 | #1 |
nacl_090 | 2.69e-4 | 1.75e-6 | 4.38e-4 | 6.74e-4 | #1 |
nacl_100 | 2.03e-4 | 5.15e-8 | 4.18e-4 | 4.91e-4 | #1 |