Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CI][microbenchmarks] Add onednn backend to GEMM with transposed matrices #2445

Merged
merged 15 commits into from
Oct 10, 2024
Merged
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
2 changes: 2 additions & 0 deletions .github/workflows/triton-benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ jobs:
source ../../scripts/capture-hw-details.sh

python ../../scripts/build_report.py $REPORTS/matmul-performance-bt.csv $REPORTS/gemm-bt-triton-report.csv --benchmark gemm-bt --compiler triton --param_cols "B,M,K,N" --tflops_col Triton-TFlops --hbm_col "Triton-GB/s" --tag $TAG
python ../../scripts/build_report.py $REPORTS/matmul-performance-bt.csv $REPORTS/gemm-bt-triton-report.csv --benchmark gemm-bt --compiler onednn --param_cols "B,M,K,N" --tflops_col onednn-TFlops --hbm_col "onednn-GB/s" --tag $TAG

- name: Run Triton GEMM (A^t@B) kernel benchmark
if: ${{ steps.install.outcome == 'success' && !cancelled() }}
Expand All @@ -177,6 +178,7 @@ jobs:
source ../../scripts/capture-hw-details.sh

python ../../scripts/build_report.py $REPORTS/matmul-performance-at.csv $REPORTS/gemm-at-triton-report.csv --benchmark gemm-at --compiler triton --param_cols "B,M,K,N" --tflops_col Triton-TFlops --hbm_col "Triton-GB/s" --tag $TAG
python ../../scripts/build_report.py $REPORTS/matmul-performance-at.csv $REPORTS/gemm-at-triton-report.csv --benchmark gemm-at --compiler onednn --param_cols "B,M,K,N" --tflops_col onednn-TFlops --hbm_col "onednn-GB/s" --tag $TAG

- name: Run Triton GEMM (stream-k) kernel benchmark
if: ${{ steps.install.outcome == 'success' && !cancelled() }}
Expand Down
14 changes: 10 additions & 4 deletions benchmarks/triton_kernels_benchmark/gemm_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import triton.language as tl

import triton_kernels_benchmark as benchmark_suit
from triton_kernels_benchmark.benchmark_testing import do_bench_elapsed_time, BENCHMARKING_METHOD

import xetla_kernel

if benchmark_suit.USE_IPEX_OPTION:
Expand Down Expand Up @@ -250,9 +252,9 @@ def get_shapes(B, M, N, K, transpose_a, transpose_b):
line_arg='provider',
# argument name whose value corresponds to a different line in the plot
# possible values for `line_arg``
line_vals=['triton'] + (['xetla'] if use_xetla else []),
line_vals=['triton'] + (['xetla'] if use_xetla else ['onednn']),
# label name for the lines
line_names=['Triton'] + (['XeTLA'] if use_xetla else []),
line_names=['Triton'] + (['XeTLA'] if use_xetla else ['onednn']),
# line styles
styles=[('green', '-'), ('green', '--'), ('blue', '-'), ('blue', '--')],
ylabel=['GB/s', 'TFlops'], # label name for the y-axis
Expand All @@ -277,8 +279,12 @@ def benchmark(B, M, N, K, provider):
torch_b = torch.transpose(torch_b, -2, -1)

if provider == 'onednn':
_, min_ms, max_ms, mean_ms, cv = benchmark_suit.do_bench(lambda: torch.matmul(torch_a, torch_b), warmup=10,
rep=10, quantiles=quantiles)
do_bench = benchmark_suit.do_bench
if BENCHMARKING_METHOD == 'PYTORCH_LEGACY_PROFILER_USING_IPEX':
# Legacy profiler shows ~6000TFLOPS GeoMean for onednn measurements, so use more reliable method
do_bench = do_bench_elapsed_time
Egor-Krivov marked this conversation as resolved.
Show resolved Hide resolved
_, min_ms, max_ms, mean_ms, cv = do_bench(lambda: torch.matmul(torch_a, torch_b), warmup=10, rep=10,
quantiles=quantiles, kernel_name='gemm_kernel')
elif provider == 'triton':
assert len(a.shape) == len(b.shape), 'Incompatible sizes'
if len(a.shape) == 3:
Expand Down