interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / gpu / amd / gfx942 / fp8gemv / bench.sh

78 lines · 3558 bytes Raw Blame History
1#!/bin/sh
2# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3# Correctness first. Then, only when /dev/kfd exists, one process times two
4# arms at the same shapes, each in a hot mode and a cold mode:
5# hipblasLtMatmul, FP8 x FP8 into f32 (the library has no FP8 x FP32 GEMM)
6# fp8gemv_stream, FP8 weights x FP32 activations plus a per-row scale,
7# with the row-remap bit clear and with it set
8# Hot is 10 calls on the buffers being timed, then 21 samples, in that process.
9# Cold reads a 512 MiB device buffer in that process and then times the next
10# call on the same operands. hipblaslt-bench is not invoked: its --flush is
11# s_icache_inv, and its --rotating copies are initialized before one averaged
12# interval. The kernel's y is compared to the CPU plain reference before any
13# sample. A mismatch prints FAIL and exits non-zero. No device: exit non-zero.
14# 5.3 TB/s is the published MI300X HBM peak, not a measurement.
15set -eu
16HERE=$(CDPATH= cd -- "$(dirname "$0")" && pwd)
17ROOT=$(CDPATH= cd -- "$HERE/../../../.." && pwd)
18OMC=$ROOT/seed/out/omc
19QEMU=/usr/bin/qemu-aarch64-static
20
21"$HERE/check.sh"
22
23echo "shapes M in 4096 8192 14336 28672, K in 4096 8192, batch 1"
24echo "kernel flags: bit0 row remap, bit1 residual+rmsnorm scale, bit2 bf16 store"
25echo "peak denominator 5.3 TB/s (published MI300X HBM peak, not a measurement)"
26echo "hipBLASLt is f8_fnuz_r x f8_fnuz_r into f32 (compute f32, D f32, scalar scales 1)."
27echo "That is HIP_R_8F_E4M3_FNUZ. The type table has no FP8 x FP32 matmul."
28echo "The kernel is FP8 weights x FP32 activations plus a per-row scale."
29echo "kernel bytes are M*K+4*K+8*M. library bytes are M*K+K+4*M. Each GB/s uses its own count."
30echo "Non-weight bytes are at most 0.293% of the kernel weight bytes and 0.122% of the library weight bytes at these shapes (both maxima at M=K=4096)."
31echo "The library GB/s is the median of this process's hipblasLtMatmul samples and M*K+K+4*M. hipblaslt-bench is not the timer, so there is no bench_GB/s column."
32echo "kernel_swizzle is flags bit 0. Same byte count either way. It is not --swizzleA."
33echo "5.3 TB/s is the published peak, not a measurement."
34echo "mode hot: 10 warmups then 21 samples, one process, no extra read. mode cold: a 512 MiB device read, then the next call on the same operands, 21 times."
35
36if [ ! -e /dev/kfd ]; then
37 echo "BLOCKED_HARDWARE no /dev/kfd"
38 exit 1
39fi
40
41HIPCC=$(command -v hipcc || true)
42if [ -z "$HIPCC" ] && [ -x /opt/rocm/bin/hipcc ]; then
43 HIPCC=/opt/rocm/bin/hipcc
44fi
45if [ -z "$HIPCC" ]; then
46 echo "BLOCKED_HARDWARE /dev/kfd is present but hipcc is not on PATH" >&2
47 exit 1
48fi
49
50work=$(mktemp -d)
51trap 'rm -rf "$work"' EXIT
52
53echo "compile hsaco.om"
54env -i "$QEMU" "$OMC" < "$ROOT/gpu/amd/gfx942/hsaco.om" > "$work/hsaco" 2>"$work/hsaco.err"
55if [ -s "$work/hsaco.err" ]; then
56 cat "$work/hsaco.err" >&2
57 exit 1
58fi
59chmod +x "$work/hsaco"
60env -i "$QEMU" "$work/hsaco" "$HERE/fp8gemv_stream.isa" > "$work/fp8gemv_stream.hsaco" 2>"$work/herr"
61if [ -s "$work/herr" ]; then
62 cat "$work/herr" >&2
63 exit 1
64fi
65
66echo "compile time_fp8gemv"
67if ! "$HIPCC" -O2 -std=c++17 -ffp-contract=off -o "$work/time_fp8gemv" \
68 "$HERE/time_fp8gemv.cpp" -lhipblaslt; then
69 echo "BLOCKED_HARDWARE hipcc could not link hipblaslt" >&2
70 exit 1
71fi
72"$work/time_fp8gemv" "$work/fp8gemv_stream.hsaco"
73
74echo "profiler commands this script does not run:"
75echo "rocprof --stats --kernel fp8gemv_stream $work/time_fp8gemv $work/fp8gemv_stream.hsaco"
76echo "omniperf profile -n fp8gemv -- $work/time_fp8gemv $work/fp8gemv_stream.hsaco"
77
78echo "bench.sh pass"