Skip to content

Commit

Permalink
Benchmarking via pytest (#316)
Browse files Browse the repository at this point in the history
Added benchmark function and results to doc
  • Loading branch information
whitead committed Jul 15, 2021
1 parent 1de4870 commit e3bdc41
Show file tree
Hide file tree
Showing 11 changed files with 343 additions and 89 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,230 @@
{
"machine_info": {
"node": "bhd0038",
"processor": "x86_64",
"machine": "x86_64",
"python_compiler": "GCC 7.3.0",
"python_implementation": "CPython",
"python_implementation_version": "3.8.8",
"python_version": "3.8.8",
"python_build": [
"default",
"Feb 24 2021 21:46:12"
],
"release": "3.10.0-1160.31.1.el7.x86_64",
"system": "Linux",
"cpu": {
"python_version": "3.8.8.final.0 (64 bit)",
"cpuinfo_version": [
8,
0,
0
],
"cpuinfo_version_string": "8.0.0",
"arch": "X86_64",
"bits": 64,
"count": 36,
"arch_string_raw": "x86_64",
"vendor_id_raw": "GenuineIntel",
"brand_raw": "Intel(R) Xeon(R) Gold 6140 CPU @ 2.30GHz",
"hz_advertised_friendly": "2.3000 GHz",
"hz_actual_friendly": "1.7326 GHz",
"hz_advertised": [
2300000000,
0
],
"hz_actual": [
1732580000,
0
],
"stepping": 4,
"model": 85,
"family": 6,
"flags": [
"3dnowprefetch",
"abm",
"acpi",
"adx",
"aes",
"aperfmperf",
"apic",
"arat",
"arch_perfmon",
"art",
"avx",
"avx2",
"avx512bw",
"avx512cd",
"avx512dq",
"avx512f",
"avx512vl",
"bmi1",
"bmi2",
"bts",
"cat_l3",
"cdp_l3",
"clflush",
"clflushopt",
"clwb",
"cmov",
"constant_tsc",
"cqm",
"cqm_llc",
"cqm_mbm_local",
"cqm_mbm_total",
"cqm_occup_llc",
"cx16",
"cx8",
"dca",
"de",
"ds_cpl",
"dtes64",
"dtherm",
"dts",
"eagerfpu",
"epb",
"ept",
"erms",
"est",
"f16c",
"flexpriority",
"flush_l1d",
"fma",
"fpu",
"fsgsbase",
"fxsr",
"hle",
"ht",
"ibpb",
"ibrs",
"ida",
"intel_ppin",
"intel_pt",
"intel_stibp",
"invpcid",
"invpcid_single",
"lahf_lm",
"lm",
"mba",
"mca",
"mce",
"md_clear",
"mmx",
"monitor",
"movbe",
"mpx",
"msr",
"mtrr",
"nonstop_tsc",
"nopl",
"nx",
"ospke",
"pae",
"pat",
"pbe",
"pcid",
"pclmulqdq",
"pdcm",
"pdpe1gb",
"pebs",
"pge",
"pku",
"pln",
"pni",
"popcnt",
"pse",
"pse36",
"pts",
"rdrand",
"rdseed",
"rdt_a",
"rdtscp",
"rep_good",
"rtm",
"sdbg",
"sep",
"smap",
"smep",
"smx",
"spec_ctrl",
"ss",
"ssbd",
"sse",
"sse2",
"sse4_1",
"sse4_2",
"ssse3",
"stibp",
"syscall",
"tm",
"tm2",
"tpr_shadow",
"tsc",
"tsc_adjust",
"tsc_deadline_timer",
"vme",
"vmx",
"vnmi",
"vpid",
"x2apic",
"xgetbv1",
"xsave",
"xsavec",
"xsaveopt",
"xtopology",
"xtpr"
],
"l3_cache_size": 25952256,
"l2_cache_size": 1048576,
"l1_data_cache_size": 32768,
"l1_instruction_cache_size": 32768
}
},
"commit_info": {
"id": "4db3fce6f8c51aa6bd15d627b6ec6693725b806d",
"time": "2021-07-09T15:19:26-04:00",
"author_time": "2021-07-09T15:19:26-04:00",
"dirty": true,
"project": "hoomd-tf",
"branch": "issue-279"
},
"benchmarks": [
{
"group": null,
"name": "test_lj_benchmark",
"fullname": "htf/test-py/benchmark.py::test_lj_benchmark",
"params": null,
"param": null,
"extra_info": {},
"options": {
"disable_gc": false,
"timer": "perf_counter",
"min_rounds": 5,
"max_time": 1.0,
"min_time": 5e-06,
"warmup": false
},
"stats": {
"min": 1.9830403740052134,
"max": 3.0145940768998116,
"mean": 2.2169361331500115,
"stddev": 0.448255204004423,
"rounds": 5,
"median": 2.0034955348819494,
"iqr": 0.33898555068299174,
"q1": 1.986543036007788,
"q3": 2.3255285866907798,
"iqr_outliers": 1,
"stddev_outliers": 1,
"outliers": "1;1",
"ld15iqr": 1.9830403740052134,
"hd15iqr": 3.0145940768998116,
"ops": 0.45107298539047896,
"total": 11.084680665750057,
"iterations": 1
}
}
],
"datetime": "2021-07-10T02:21:23.047649",
"version": "3.4.1"
}
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
- name: Install dependencies
run: |
# Install testing dependencies
pip install pytest-cov pytest-xdist jupyter notebook matplotlib gsd scipy
pip install pytest-cov pytest-xdist jupyter notebook matplotlib gsd scipy pytest-benchmark
# Install software dependencies
pip install tensorflow==${{ matrix.tensorflow }}
Expand All @@ -61,7 +61,7 @@ jobs:
cd ..
- name: Run tests
run: |
pytest -v --forked
pytest
- name: Run notebooks with MDAnalysis
if: matrix.md-analysis == 'true'
run: |
Expand Down
3 changes: 2 additions & 1 deletion Release.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ Release Process

1. Update changelog
2. Make sure changelog is ISO dates
3. Modify `version.py` file
3. Modify `version.py` file
4. Update benchmarks
79 changes: 0 additions & 79 deletions htf/benchmarking/benchmark.py

This file was deleted.

48 changes: 48 additions & 0 deletions htf/test-py/benchmark.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
def test_lj_benchmark(benchmark):

import hoomd.htf as htf
from hoomd.htf import tfcompute
import hoomd
import hoomd.md
import hoomd.dump
import hoomd.group
import numpy as np
import tensorflow as tf

class LJModel(htf.SimModel):
def compute(self, nlist, positions, box):
# get r
rinv = htf.nlist_rinv(nlist)
inv_r6 = rinv**6
# pairwise energy. Double count -> divide by 2
p_energy = 4.0 / 2.0 * (inv_r6 * inv_r6 - inv_r6)
# sum over pairwise energy
energy = tf.reduce_sum(input_tensor=p_energy, axis=1)
forces = htf.compute_nlist_forces(nlist, energy)

return forces

N = 256
NN = 64
model = LJModel(NN)
tfcompute = htf.tfcompute(model)
hoomd.context.initialize('')
rcut = 3.0
sqrt_N = int(np.sqrt(N))

system = hoomd.init.create_lattice(unitcell=hoomd.lattice.sq(a=2.0),
n=[sqrt_N, sqrt_N])
nlist = hoomd.md.nlist.cell(check_period=1)
# basic LJ forces from Hoomd
lj = hoomd.md.pair.lj(rcut, nlist)
lj.pair_coeff.set('A', 'A', epsilon=1.0, sigma=1.0)
hoomd.md.integrate.mode_standard(dt=0.005)
hoomd.md.integrate.langevin(group=hoomd.group.all(), kT=1.0, seed=42)
# equilibrate for 4k steps first
hoomd.run(4000)
# now attach the LJ force model
tfcompute.attach(nlist,
r_cut=rcut)

# train on 1k timesteps
benchmark.pedantic(hoomd.run, (1000,), rounds=5, iterations=1)
6 changes: 6 additions & 0 deletions pytest-benchmark.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# pytest-benchmark.ini
[pytest]
minversion = 6.0
addopts = -v --durations=0 --benchmark-autosave
python_files = htf/test-py/benchmark.py
required_plugins = pytest-cov pytest-xdist pytest-benchmark
4 changes: 4 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# pytest.ini
[pytest]
minversion = 6.0
addopts = -v --durations=0 --forked

0 comments on commit e3bdc41

Please sign in to comment.