Add FlagGems single-op perf benchmark harness

pytest plugin set + driver script for compiler A/B perf comparison:
- reproducible runs: fixed seed, yaml-driven shapes, autotune record/replay
- per-shape ttgir dump of actually-used variants with readable naming
- cudagraph-based timing with documented fallback semantics

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-16 03:52:07 +00:00
parent 242d74af0e
commit 8ace0d790c
11 changed files with 1562 additions and 1 deletions
+39
View File
@@ -0,0 +1,39 @@
"""pytest plugin: seed random/numpy/torch RNG for reproducible benchmark inputs.
Data-dependent kernels (sort, topk, nonzero, ...) have value-dependent latency;
a fixed seed makes every run generate byte-identical inputs, so the latency
delta between two runs reflects the change under test, not the input data.
"""
from __future__ import annotations
import sys
_SEED = 0
def pytest_configure(config):
seed = _SEED
# random.seed too: some kits (cutlass_scaled_mm) pick cases via random.shuffle.
import random
random.seed(seed)
seeded = ["random"]
try:
import numpy as _np
_np.random.seed(seed)
seeded.append("numpy")
except Exception:
pass
try:
import torch
except Exception as exc: # torch missing should never happen here, stay safe
print(f"[seed-plugin] torch unavailable, seeded {'+'.join(seeded)} only: {exc}",
file=sys.stderr)
return
torch.manual_seed(seed)
if torch.cuda.is_available():
torch.cuda.manual_seed_all(seed)
seeded.append("torch")
print(f"[seed-plugin] manual_seed({seed}) for {'+'.join(seeded)} "
"— reproducible benchmark inputs/cases",
file=sys.stderr, flush=True)