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

Introduce BENCHMARKING_METHOD for Triton benchmarks #2376

Merged
merged 6 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
16 changes: 11 additions & 5 deletions .github/workflows/triton-benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,21 @@ on:
description: Tag for benchmark results
type: string
default: "test"
install_ipex:
description: Install Intel PyTorch Extension
type: boolean
default: true
benchmarking_method:
description: The method used to obtain performance numbers
type: choice
options:
- PYTORCH_LEGACY_PROFILER_USING_IPEX
- ELAPSED_TIME
default: PYTORCH_LEGACY_PROFILER_USING_IPEX
schedule:
- cron: "5 23 * * *"

permissions: read-all

env:
PYTHON_VERSION: "3.10"
USE_IPEX: ${{ github.event_name == 'schedule' && '1' || inputs.install_ipex && '1' || '0' }}
BENCHMARKING_METHOD: ${{ github.event_name == 'schedule' && 'PYTORCH_LEGACY_PROFILER_USING_IPEX' || inputs.benchmarking_method }}
anmyachev marked this conversation as resolved.
Show resolved Hide resolved

jobs:
build:
Expand Down Expand Up @@ -54,6 +57,9 @@ jobs:
run: |
pip install wheel cmake

- name: Set USE_IPEX environment variable
run: echo "USE_IPEX=$($BENCHMARKING_METHOD == 'PYTORCH_LEGACY_PROFILER_USING_IPEX')" >> $GITHUB_ENV

anmyachev marked this conversation as resolved.
Show resolved Hide resolved
- name: Setup PyTorch with IPEX
if: ${{ env.USE_IPEX == '1' }}
uses: ./.github/actions/setup-pytorch
Expand Down
13 changes: 10 additions & 3 deletions benchmarks/triton_kernels_benchmark/benchmark_testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
from typing import Any, Dict, List

USE_IPEX_OPTION = os.getenv("USE_IPEX", "1") == "1"
if USE_IPEX_OPTION:
BENCHMARKING_METHOD = "PYTORCH_LEGACY_PROFILER_USING_IPEX"
else:
BENCHMARKING_METHOD = os.getenv("BENCHMARKING_METHOD", "ELAPSED_TIME")


def synchronize():
Expand Down Expand Up @@ -122,8 +126,8 @@ def extract_kernels(funcs):
return _summarize_statistics(times, quantiles, return_mode)


def do_bench_no_ipex(fn, warmup=25, rep=100, grad_to_none=None, quantiles=None, fast_flush=True, return_mode="mean",
device="xpu"):
def do_bench_elapsed_time(fn, warmup=25, rep=100, grad_to_none=None, quantiles=None, fast_flush=True,
return_mode="mean", device="xpu"):
"""
Benchmark the runtime of the provided function. By default, return the median runtime of :code:`fn` along with
the 20-th and 80-th performance percentile.
Expand Down Expand Up @@ -151,9 +155,12 @@ def do_bench_no_ipex(fn, warmup=25, rep=100, grad_to_none=None, quantiles=None,
return _summarize_statistics(times, quantiles, return_mode)


do_bench = do_bench_no_ipex
if USE_IPEX_OPTION:
anmyachev marked this conversation as resolved.
Show resolved Hide resolved
do_bench = do_bench_ipex
elif BENCHMARKING_METHOD == "ELAPSED_TIME":
do_bench = do_bench_elapsed_time
else:
raise NotImplementedError(f"BENCHMARKING_METHOD: {BENCHMARKING_METHOD} isn't implemented")


def assert_close(x, y, atol=None, rtol=None, err_msg=""):
Expand Down
2 changes: 1 addition & 1 deletion scripts/capture-hw-details.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ fi
if [[ "${USE_IPEX:-}" == "1" ]]; then
export BENCHMARKING_METHOD="PYTORCH_LEGACY_PROFILER_USING_IPEX"
elif [[ "${USE_IPEX:-}" == "0" ]]; then
export BENCHMARKING_METHOD="ELAPSED_TIME"
export BENCHMARKING_METHOD="${BENCHMARKING_METHOD:ELAPSED_TIME}"
anmyachev marked this conversation as resolved.
Show resolved Hide resolved
fi

if [ "$QUIET" = false ]; then
Expand Down
Loading