8ace0d790c
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>
40 lines
1.2 KiB
Python
40 lines
1.2 KiB
Python
"""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)
|