Repository navigation
Description
#8 landed a host launcher and gemm now runs exact against a CPU reference. The
next thing it should do is say how fast it is.
Shape
A modal run modal_app.py::bench (B200) that runs each runnable example at
several problem sizes and reports achieved throughput. Separate from the
correctness path so modal_app.py::examples stays fast.
Requirements that matter more than the numbers
Correctness gates the number. Never print a throughput figure for a run
whose output was not checked. A fast wrong kernel is worth less than a slow
right one, and a benchmark harness that will happily report GFLOP/s for garbage
is a trap we would fall into exactly once. Run the existing exact check, and
only then time it.
Report the metric the kernel is actually bound by. GEMM is compute-bound, so
2*M*N*K / seconds is meaningful. Softmax and layernorm are memory-bound —
their FLOP counts are small and a FLOP/s figure for them is close to
meaningless. Those should report achieved GB/s (bytes read + written / seconds).
Reporting FLOP/s for a normalization kernel would be actively misleading, so the
harness should carry a per-example notion of which metric applies rather than
assuming one.
Time the kernel, not the harness. Use CUDA events around the launch, not
wall clock around the whole call — the build script already probes for
cuEventElapsedTime_v2, so events are reachable. Warm up before timing (the
first launch pays module load) and take the minimum over several iterations,
which is the standard choice for kernel timing because it is the least
noise-contaminated estimate of the achievable time. Report the spread too: if
min and median diverge a lot, that is itself a finding.
Sizes should span a regime change, not just be big. A few sizes chosen so
the small end is launch- or occupancy-bound and the large end is
compute-bound — the interesting output of this exercise is the shape of the
curve, not a single headline number. State the sizes and why they were picked.
On comparing to peak
Achieved TFLOP/s is the primary number. A percentage of peak is more useful
still, but only if the peak figure is defensible — cite where it came from and
whether it is dense or sparse, and do not invent one. If a trustworthy figure
is not to hand, report the achieved throughput alone and say why the ratio is
absent. An unsourced "% of peak" is worse than no ratio.
Notes
Only gemm runs today. softmax is close (#9). The harness should make adding
the next kernel cheap, and should say clearly which examples it skipped and why,
so a reader is never left guessing whether a missing row means "slow" or "not
runnable yet".
Activity
gemm: let the cluster's TMEM allocator survive a second launch
Benchmark the examples: checked, then timed, at six sizes (#45)
TMEM: relinquish the allocation permit, and lift alloc_cluster into t…