Skip to content

About

Benchmarking and validation tool for hipDNN graphs.

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

dnn-benchmarking

Benchmarking and validation tool for hipDNN graphs.

Caution: This tool is in early development and can change. Do not use it in build workflows or CI gating.

dnn-benchmarking loads serialized hipDNN graphs (JSON). It runs each graph through the installed hipDNN engine plugins, through PyTorch with --runtime pytorch, through rocKE SDPA kernels with --runtime rocke, or through AITER SDPA kernels with --runtime aiter. A comma list such as --runtime hipdnn,rocke puts the rows of each runtime in the same run. For each engine it measures the device time of one launch and, if you ask, compares the output with a PyTorch reference.

  • One timed loop for all runtimes. The headline number is the median device time per launch (kernel_med), measured with a stall-gated event span.
  • Each result records how it was measured: timing mode, cache mode, warmup, sample count, seed and first-call cost.
  • Results go to stdout as tables, progress goes to stderr, and -o writes a versioned JSON or CSV file.
  • dnn-benchmark compare compares two result files, for example two builds or a ROCm host and a CUDA host.

Requirements

  • Python 3.12 or newer.
  • hipDNN backend: an AMD GPU with ROCm, the hipDNN Python bindings (hipdnn_frontend) and the engine plugins. setup_env.py builds them.
  • PyTorch runtime: a ROCm or CUDA build of PyTorch. hipDNN is not necessary.
  • rocKE runtime: a ROCm build of PyTorch and the rocKE Python packages (setup_env.py installs them on Linux). See docs/usage.md.
  • AITER runtime: a ROCm build of PyTorch and AITER from the aiter submodule (setup_env.py installs it on Linux). See docs/usage.md.
  • --validate pytorch: any PyTorch build. A CPU build is sufficient.
  • Optional: amdsmi for GPU clocks and throttle status; rocprofv3, perf and rocprof-compute for the profiling flags.

With ROCm torch and a separate --rocm-prefix, two hipDNN backends can be visible in one process. Read the mixed-prefix guidance before using --validate pytorch with that setup.

Quick start

  1. Set up the environment (ROCm host). See docs/setup.md for CUDA hosts, CPU-only PyTorch and Docker.

    python3 setup_env.py --workspace .workspace
    source .workspace/.venv/bin/activate
  2. Benchmark one graph with all engines that support it:

    dnn-benchmark -g graphs/sample_conv_fwd.json
    sample_conv_fwd (sample_conv_fwd_16x16x16x16_k16_3x3)  [c6ab89a41cb4]
      engine                       verdict    kernel_med  iqr%    submit  tflops  gbps  vs_best
      MIOPEN_ENGINE                unchecked   25.44 µs    1.9  11.55 µs    0.74  21.0    1.00x
      MIOPEN_ENGINE_DETERMINISTIC  unchecked   25.60 µs    1.3  11.47 µs    0.74  20.8    0.99x
    
  3. Run the same graph through PyTorch:

    dnn-benchmark -g graphs/sample_conv_fwd.json --runtime pytorch
  4. Benchmark a set of graphs, validate the outputs and write the results:

    dnn-benchmark -g 'graphs/*.json' --validate pytorch -o results.json
    dnn-benchmark -g 'graphs/*.json' -o results.csv
  5. Compare two result files. speedup = A / B; more than 1 means B is faster:

    dnn-benchmark compare base.json results.json

More examples:

# Select engines by name, hex ID or decimal ID, in order
dnn-benchmark -g graphs/sample_conv_fwd.json -e MIOPEN_ENGINE -v

# Cold cache, at least 200 iterations and 100 ms of kernel time
dnn-benchmark -g graphs/sample_conv_fwd.json -i 200 --min-time-ms 100 --cache-mode cold

# rocKE block timing: each of 100 samples times 50 back-to-back launches
dnn-benchmark -g 'graphs/*.json' --iters 100 --timing-block 50

# Run every headline convolution of the public graph store (see docs/graph-store.md)
dnn-benchmark -g s3://therock-dvc/dnn-benchmarking-graphs/ \
  --tag workload=headline --tag operation=convolution -o conv.json

# Repeatable recipe; CLI flags override the file
dnn-benchmark --config sample_configs/basic.toml.example -g graphs/sample_conv_fwd.json

Exit codes

Code Meaning
0 Success.
1 Engine row error, graph error, failed final result write, no graph files, or runtime not available.
2 Usage or config error.
3 An engine row failed validation.
130 / 143 Interrupted by SIGINT / SIGTERM. A partial result file has run.complete = false.

Documentation

Document Content
docs/setup.md setup_env.py: torch modes, CMake defines, rocm-libraries source, CUDA hosts, Docker.
docs/usage.md All CLI options, engine selection, config files, console output, exit codes, compare, profiling.
docs/graph-store.md The graph store: object keys, the tag vocabulary, --tag queries, the upload procedure.
docs/methodology.md What kernel_med measures, warmup, cache modes, stop rule, statistics, parity with rocKE and PyTorch, known limits.
docs/results-schema.md Result file schema version 3 (JSON and CSV).
docs/troubleshooting.md ROCm library paths, profiler requirements, profiling artefacts.
AGENTS.md Architecture and development rules.

dnn-benchmark --help is the authoritative option list.

Graph store

The benchmark graphs are in a public graph store, one JSON object for each graph. The tags in each graph select it. Anyone can read the store without credentials:

# Every headline graph; the first run copies the store into the work directory
dnn-benchmark -g s3://therock-dvc/dnn-benchmarking-graphs/ --tag workload=headline

The workload tag groups the graphs:

  • workload=headline: the small, curated set for regression monitoring. operation splits it into convolution, batchnorm, sdpa, matmul, moe and norm. No ROCm engine implements RMSNorm or LayerNorm yet, so the operation=norm graphs have no applicable engines today.
  • workload=microbench: larger shape sweeps and per-source collections (source=aiter, source=rocke, ...).
  • workload=model: workloads for each model (model=...).
  • workload=corpus: reference collections across models with minimal graph overlap inside each collection: convolution, SDPA forward and SDPA backward.

docs/graph-store.md gives the tag vocabulary, the query for each old Workloads/ set, and the upload procedure.

Tests

pytest -m "not gpu"        # unit tests, any host
pytest                     # GPU host (ROCm or CUDA): unit + GPU tests

See AGENTS.md for the test tiers and markers.

Validating graphs

tools/check_deserialize.py checks that graph JSON files deserialize and validate without building a plan or running a kernel. It has two validation levels:

# Pure-Python loader only (no hipDNN build required)
python tools/check_deserialize.py --level json --src src graphs

# Full deserialize + build/finalize the backend operation graph (needs a built hipDNN)
python tools/check_deserialize.py --level opgraph graphs

# The local copy of the graph store (after one dnn-benchmark -g s3://... run)
python tools/check_deserialize.py --level json --src src \
  <work>/graph-store/therock-dvc/dnn-benchmarking-graphs

Run this before you upload new graphs to the store, to confirm hipDNN can load them. Paths may be globs, directories, or tarball-extracted trees; the script exits non-zero on any failure and prints the first failures with their error messages.

Both levels also report an SDPA node (forward or backward) that sets neither attn_scale_value nor scale_tensor_uid. hipDNN reads an absent scale as 1.0, the same as cuDNN, so the graph is valid; it just measures 1.0 instead of the scale its source used, usually 1/sqrt(head_dim). Such nodes print as NOSCALE and still exit 0; pass --strict-scale to make them failures. A causal SDPA node with Sq = 1 whose effective diagonal is top-left attends only to key 0, which no decode step means (a decode step is unmasked or bottom-right). 131 graphs of the graph store are written that way (57 of them workload=corpus direction=bwd), so the check prints them as DECODE and still exits 0; pass --strict-decode-mask to make them failures once those graphs are regenerated. Other effective top-left causal nodes with Sq != Skv print a warning, because decode and chunked prefill workloads almost always use bottom-right alignment.

"Effective" is the mask hipDNN resolves, which is not always the one the JSON names. A deprecated causal flag acts as right_bound = 0 when right_bound is unset, and the stored left_bound and diagonal_alignment still apply (hipDNN's resolveDiagonalBand). Thus causal_mask: true with BOTTOM_RIGHT runs bottom-right, and causal_mask_bottom_right: true forces bottom-right. Setting both causal flags fails the check, as hipDNN rejects that pair. Only right_bound >= 0 masks the right side, so a node carrying a left_bound alone is a window that stays open on the right, which is never causal.

Related tools

For the MIOpen shape conversion tool, see dnn-convert-shapes.

About

Benchmarking and validation tool for hipDNN graphs.

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages