TileOPs-Metax/scripts
Cao Ying ef5d248f2f
[Refactor][Benchmark] Extract ManifestBenchmark base class and shared helpers (#915)
## Summary

Extract a generic `ManifestBenchmark` base class and shared helpers
(`roofline_vars`, `workloads_to_params`) into `benchmarks/benchmark.py`,
so manifest-driven bench files only specify the op name and baseline
function per test. This eliminates ~300 lines of duplication across 5
benchmark files.

Closes #904

## Changes

- **benchmarks/benchmark.py** — Add `ManifestBenchmark(op_name)`
subclass of `BenchmarkBase` with `roofline_vars(workload)` and
`workloads_to_params(op_name)` public helpers
-
**benchmarks/ops/bench_{softmax,reduce,argreduce,logical_reduce,vector_norm}.py**
— Refactor to use `ManifestBenchmark`, replacing 19 per-op benchmark
classes
- **scripts/validate_manifest.py** — Teach AST validator to recognize
`ManifestBenchmark` subclasses as satisfying `eval_roofline` requirement
- **tests/test_validate_manifest.py** — Add tests for indirect
bench-validator AST paths and a regression test documenting the subclass
override limitation

## Test plan

- [x] AC-1: All 5 bench files use `ManifestBenchmark` instead of per-op
classes
- [x] AC-2: `_roofline_vars` and `_workloads_to_params` exist only in
`benchmarks/benchmark.py`, not duplicated
- [x] AC-3: `pytest --collect-only` passes for all 5 bench files (63
tests collected)
- [x] AC-4: `validate_manifest.py --check-op` produces zero `[bench]`
warnings for all 19 affected ops
- [x] 89 validator tests pass, lint clean

## Follow-up

- #917 — Add import alias and attribute access support to bench AST
validator
- #918 — Type-narrow roofline_vars parameter from WorkloadBase to typed
Protocol

---------

Co-authored-by: Ibuki 🍃 — a wind born from Claude Opus <Ibuki-wind@users.noreply.github.com>
2026-04-12 12:28:43 +08:00
..
conftest_warmup.py [Fix][Benchmark] Add serial validation to correct noisy autotune configs (#773) 2026-04-03 13:27:42 +08:00
dep_hash.py [Fix][CI] Install external baseline libraries in nightly benchmarks (#673) 2026-03-26 15:06:45 +08:00
gpu_smoke_report.py [CI] Add gpu smoke workflow summary report (#764) 2026-04-02 17:23:37 +08:00
nightly_report.py [Bench] Add FA3/FlashInfer baselines across all attention benchmarks (#734) 2026-04-01 11:40:17 +08:00
test_node_delta.py [Test][Softmax] Add non-aligned edge-case shapes for softmax-family ops (#914) 2026-04-12 11:17:34 +08:00
validate_manifest.py [Refactor][Benchmark] Extract ManifestBenchmark base class and shared helpers (#915) 2026-04-12 12:28:43 +08:00
warmup_kernel_cache.py [Fix][Benchmark] Add serial validation to correct noisy autotune configs (#773) 2026-04-03 13:27:42 +08:00