Skip to content

Commit

Permalink
[MLIR][TPP] Enable --lower-pack-unpack-without-transpose on LoRA benc…
Browse files Browse the repository at this point in the history
…hmark

Only gets applied to MANUAL MLIR runs as for these the constant weights
will remain packed (applying it to OV-derived IR would undo all packing,
also on the weights that are passed as an argument).

Additionally, adds more sizes to test on.
  • Loading branch information
rolfmorel committed Sep 24, 2024
1 parent 2063c7f commit c97e28f
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions tools/mlir_bench/lora-runner.xsh
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ import re
from os import environ


LORA_DIMS = [2, 4, 8]
CONFIGS = [
[8], [16], [32], [64], [128], [256], [512], [1024]
[8], [16], [32], [64], [128], [256], [512], [1024],
[2048], [4096], [8192]
]
ITERATIONS = 100

Expand Down Expand Up @@ -84,15 +86,15 @@ func.func @entry(%arg0: !loraAlphaType, %arg1: !inputType) -> !inputType {{\n\
return mlir_model


def main():
def full_run(lora_dim):
no_mlir_averages = []
mlir_averages = []
no_ov_averages = []
manual_mlir_averages = []
for config in CONFIGS:
model_desc = '.'.join(str(x) for x in config)
model_xml = f"lora.{model_desc}.xml"
model = build_ov_lora_model(*config)
model = build_ov_lora_model(*config, lora_dim=lora_dim)
ov.save_model(model, model_xml)

BENCH_FLAGS=f"-m {model_xml} -d CPU -ip f32 -infer_precision f32 -hint none -nstreams 1 -nthreads 1".split()
Expand All @@ -113,15 +115,21 @@ def main():
mlir_model = build_mlir_lora_model(*config)
if DEBUG:
print(mlir_model)
raw_kernel_secs = $(echo @(mlir_model) | tpp-run @(RUNNER_FLAGS))
raw_kernel_secs = $(@(lambda: print(mlir_model)) | tpp-run @(RUNNER_FLAGS) --lower-pack-unpack-folding-transpose)
return float(raw_kernel_secs) * 1000
manual_mlir_averages.append(run_manual_mlir(""))

print("CONFIGS", CONFIGS)
print("OV NO-MLIR", no_mlir_averages)
print("OV MLIR", mlir_averages)
print("NO-OV MLIR", no_ov_averages)
print("MANUAL MLIR", manual_mlir_averages)
print("NO-OV MLIR", list(round(x, 2) for x in no_ov_averages))
print("MANUAL MLIR", list(round(x, 2) for x in manual_mlir_averages))


def main():
for lora_dim in LORA_DIMS:
print("lora_dim =", lora_dim)
full_run(lora_dim)


if __name__ == "__main__":
Expand Down

0 comments on commit c97e28f

Please sign in to comment.