This directory contains ASV-based benchmarks for PhysicsNeMo. Benchmarks are
discovered from the benchmarks/ tree and configured via asv.conf.json in the
repository root.
Resources:
Run all benchmarks from the repo root:
./benchmarks/run_benchmarks.shNote: the first run may take a while because ASV builds its virtual environment.
Run a subset by name or regex:
./benchmarks/run_benchmarks.sh -b knnPublish results to the local HTML report:
asv publishPreview the report in a local web server:
asv previewThe generated site is written to .asv/html/ (open index.html if you prefer).
- Add a new file under
benchmarks/following the package structure (for example,benchmarks/physicsnemo/nn/neighbors/my_benchmark.py). - Define a benchmark class and at least one
time_*method. See documentation for available benchmark types. - Use
setup()to create inputs and keep benchmarks deterministic. See documentation for available benchmark attributes.
Example:
import torch
class MyOpBenchmark:
params = [1024, 4096]
param_names = ["n"]
def setup(self, n: int) -> None:
self.x = torch.randn(n, n, device="cuda")
def time_my_op(self, n: int) -> None:
_ = self.x @ self.x
torch.cuda.synchronize()