Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/user-tutorial/benchmarks/micro-benchmarks.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ Large scale matmul operation using `torch.matmul` with one GPU.

Measure the GEMM performance of [`cublasLtMatmul`](https://docs.nvidia.com/cuda/cublas/#cublasltmatmul) or [`hipblasLt-bench`](https://github.com/ROCm/hipBLASLt/blob/develop/clients/benchmarks/README.md).

If `hipblaslt-gemm` receives a non-finite or non-positive `hipblaslt-Gflops` value,
it reports a result-parsing error and does not emit a TFLOPS metric for that command.

The CUDA benchmark accepts FP64, FP32, FP16, BF16, FP8 E4M3/E5M2, FP4 E2M1,
explicit MXFP8 block-scaled modes, explicit NVFP4 block-scaled mode, and INT8 inputs. The
supported `--in_types` names are `fp64`, `fp32`, `fp16`, `bf16`, `fp8e4m3`, `fp8e5m2`,
Expand Down
14 changes: 11 additions & 3 deletions superbench/benchmarks/micro_benchmarks/hipblaslt_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

"""Module of the hipBlasLt GEMM benchmark."""

import math
import os
import re

Expand Down Expand Up @@ -162,11 +163,10 @@ def _process_raw_result(self, cmd_idx, raw_output):
m_val = fields[col_idx_by_name['m']].strip()
n_val = fields[col_idx_by_name['n']].strip()
k_val = fields[col_idx_by_name['k']].strip()
gflops_col = col_idx_by_name['hipblaslt-Gflops']
gflops = self._parse_gflops(fields[col_idx_by_name['hipblaslt-Gflops']])

self._result.add_result(
f'{self._precision_in_commands[cmd_idx]}_{batch_count}_{m_val}_{n_val}_{k_val}_flops',
float(fields[gflops_col]) / 1000
f'{self._precision_in_commands[cmd_idx]}_{batch_count}_{m_val}_{n_val}_{k_val}_flops', gflops / 1000
)
except BaseException as e:
self._result.set_return_code(ReturnCode.MICROBENCHMARK_RESULT_PARSING_FAILURE)
Expand All @@ -179,5 +179,13 @@ def _process_raw_result(self, cmd_idx, raw_output):

return True

@staticmethod
def _parse_gflops(value: str) -> float:
"""Read client throughput without accepting a failed measurement as performance data."""
gflops = float(value)
if not math.isfinite(gflops) or gflops <= 0:
raise ValueError('hipblaslt-Gflops must be finite and positive.')
return gflops


BenchmarkRegistry.register_benchmark('hipblaslt-gemm', HipBlasLtBenchmark, platform=Platform.ROCM)
15 changes: 15 additions & 0 deletions tests/benchmarks/micro_benchmarks/test_hipblaslt_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,18 @@ def test_hipblaslt_gemm_result_parsing_missing_required_column(self):
"""
self.assertFalse(benchmark._process_raw_result(0, example_raw_output_missing_col))
self.assertEqual(ReturnCode.MICROBENCHMARK_RESULT_PARSING_FAILURE, benchmark.return_code)

def test_invalid_throughput(self):
"""Reject invalid client throughput without publishing a TFLOPS metric."""
benchmark_cls, _ = BenchmarkRegistry._BenchmarkRegistry__select_benchmark(self.benchmark_name, Platform.ROCM)
for precision in ['fp32', 'fp16', 'bf16', 'fp8']:
for value in ['0', '-1', 'nan', 'inf', '-inf']:
with self.subTest(precision=precision, value=value):
benchmark = benchmark_cls(
self.benchmark_name, parameters=f'--in_types {precision} --shapes 128,128,128'
)
self.assertTrue(benchmark._preprocess())
csv = f'[0]:batch_count,m,n,k,hipblaslt-Gflops\n1,128,128,128,{value}'
self.assertFalse(benchmark._process_raw_result(0, csv))
self.assertEqual(benchmark.return_code, ReturnCode.MICROBENCHMARK_RESULT_PARSING_FAILURE)
self.assertEqual(set(benchmark.result), {'return_code'})
Loading