Skip to content

Commit

Permalink
Added optional HBM results
Browse files Browse the repository at this point in the history
  • Loading branch information
Egor-Krivov committed Jun 18, 2024
1 parent 8b95a58 commit 9b5f008
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 35 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/triton-benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ jobs:
source /home/runner/intel/oneapi/mkl/2024.1/env/vars.sh
cd benchmarks/xetla_benchmark
python fused_softmax.py --reports $REPORTS
python build_report.py $REPORTS/softmax-performance.csv $REPORTS/softmax-report.csv --param_cols "N" --result_cols "Triton-TFlops-max,XeTLA-TFlops-max" --name softmax
source ../../scripts/capture-hw-details.sh
python ../../scripts/build_report.py $REPORTS/softmax-performance.csv $REPORTS/softmax-report.csv --benchmark softmax --compiler triton --param_cols "N" --tflops_col Triton-TFlops-max --hbm_col "Triton-GB/s-max"
python ../../scripts/build_report.py $REPORTS/softmax-performance.csv $REPORTS/softmax-report.csv --benchmark softmax --compiler xetla --param_cols "N" --tflops_col XeTLA-TFlops-max --hbm_col "XeTLA-GB/s-max"
- name: Run micro benchmark
Expand Down
55 changes: 21 additions & 34 deletions scripts/build_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@

def parse_args():
parser = argparse.ArgumentParser(description="Build report based on triton-benchmark run")
parser.add_argument("source", help="Path to source csv file with benchmark results", required=True)
parser.add_argument("source", help="Path to source csv file with benchmark results")
parser.add_argument(
"target",
required=True,
help="Path to result csv file with benchmark results including host info and dates",
)
parser.add_argument("--param_cols", help="Names of parameter columns, separated by commas.", required=True)
parser.add_argument("--name", help="Name of the benchmark.", required=True)
parser.add_argument("--result_cols", help="Names of the result columns, separated by commas.", required=True)
parser.add_argument("--benchmark", help="Name of the benchmark.", required=True)
parser.add_argument("--compiler", help="Name of the compiler, like `triton`.", required=True)
parser.add_argument("--tflops_col", help="Column name with tflops.", required=True)
parser.add_argument("--hbm_col", help="Column name with HBM results.", required=False, default=None)
return parser.parse_args()


Expand All @@ -26,54 +27,40 @@ def check_cols(target_cols, all_cols):
assert (len(diff) == 0), f"Couldn't find required columns: '{diff}' among available '{all_cols}'"


def parse_result(name):
name = name.lower()
if "triton" in name:
return "triton"
elif "xetla" in name:
return "xetla"
else:
return name


def transform_df(df, param_cols, result_cols, bench_name):

def transform_df(df, param_cols, tflops_col, hbm_col, benchmark, compiler):
check_cols(param_cols, df.columns)
check_cols(result_cols, df.columns)
check_cols([tflops_col] + [] if hbm_col is None else [hbm_col], df.columns)
# Build json with parameters
df_results = df[result_cols].copy()
df_results = pd.DataFrame()
df_results["params"] = [json.dumps(j) for j in df[param_cols].astype(int).to_dict("records")]
df_results['tflops'] = df[tflops_col]
if hbm_col is not None:
df_results['hbm_gbs'] = df[hbm_col]

df = pd.melt(
df_results,
id_vars=["params"],
value_vars=result_cols,
value_name="tflops",
var_name="comment",
)

df["compiler"] = df["comment"].apply(parse_result)
df["run_uuid"] = uuid.uuid4().hex
df["datetime"] = datetime.datetime.now()
df["benchmark"] = bench_name
df_results["run_uuid"] = uuid.uuid4().hex
df_results["datetime"] = datetime.datetime.now()
df_results["benchmark"] = benchmark
df_results["compiler"] = compiler

host_info = {
n: os.getenv(n.upper(), default="")
for n in ["libigc1_version", "level_zero_version", "gpu_device", "agama_version"]
}
assert host_info['gpu_device'], "Could not find GPU device description, was capture_device.sh called?"
for name, val in host_info.items():
df[name] = val
df_results[name] = val

return df
return df_results


def main():
args = parse_args()
param_cols = args.param_cols.split(",")
result_cols = args.result_cols.split(",")
df = pd.read_csv(args.source)
result_df = transform_df(df, param_cols=param_cols, result_cols=result_cols, bench_name=args.name)
result_df = transform_df(
df, param_cols=param_cols, tflops_col=args.tflops_col,
hbm_col=args.hbm_col, benchmark=args.benchmark, compiler=args.compiler
)
result_df.to_csv(args.target, index=False)


Expand Down

0 comments on commit 9b5f008

Please sign in to comment.