049e3d8bb3
Move benches/ -> src/kernbench/benches/ and src/kernbench/cli/probe.py -> src/kernbench/probes/probe.py. Each bench self-registers via @bench(name=..., description=...); kernbench list enumerates benches with auto-assigned indices, --bench accepts kebab-case name or numeric index. Audit at package-import time fails if any non-underscore module forgets the decorator. ADR-0010 (EN + KO) updated to reflect the new resolver path, list subcommand, and probes package separation. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
45 lines
1.4 KiB
Python
45 lines
1.4 KiB
Python
"""Single-PE GEMM benchmark via scheduler_v2 (pe_accel).
|
|
|
|
Full host-to-PE pipeline:
|
|
Host → PCIE_EP → IO_CPU → M_CPU → PE_CPU → SchedulerV2 → PE_DMA → HBM
|
|
|
|
Single PE: num_cubes=1, num_pes=1 via DPPolicy override.
|
|
Both operands use tl.ref (HBM-resident); scheduler_v2 tiles and streams
|
|
per-tile DMA internally.
|
|
|
|
Run:
|
|
kernbench run gemm_single_pe
|
|
"""
|
|
from kernbench.benches.registry import bench
|
|
from kernbench.policy.placement.dp import DPPolicy
|
|
|
|
# GEMM dimensions: (M, K) x (K, N) → (M, N)
|
|
M, K, N = 32, 128, 32
|
|
DTYPE = "f16"
|
|
|
|
|
|
def _gemm_kernel(a_ptr, b_ptr, out_ptr, M, K, N, tl, DTYPE="f16"):
|
|
"""Single-PE GEMM: out = a @ b. Both operands streamed from HBM by scheduler."""
|
|
M, K, N = int(M), int(K), int(N)
|
|
|
|
a = tl.ref(int(a_ptr), shape=(M, K), dtype=DTYPE)
|
|
b = tl.ref(int(b_ptr), shape=(K, N), dtype=DTYPE)
|
|
h = tl.composite(op="gemm", a=a, b=b, out_ptr=int(out_ptr))
|
|
tl.wait(h)
|
|
|
|
|
|
@bench(
|
|
name="gemm-single-pe",
|
|
description="Single-PE GEMM via scheduler_v2 (pe_accel).",
|
|
)
|
|
def run(torch):
|
|
"""Run the single-PE GEMM benchmark."""
|
|
dp = DPPolicy(cube="replicate", pe="replicate",
|
|
num_cubes=1, num_pes=1)
|
|
|
|
a = torch.empty((M, K), dtype=DTYPE, dp=dp, name="a")
|
|
b = torch.empty((K, N), dtype=DTYPE, dp=dp, name="b")
|
|
out = torch.empty((M, N), dtype=DTYPE, dp=dp, name="out")
|
|
|
|
torch.launch("gemm_single_pe", _gemm_kernel, a, b, out, M, K, N)
|