Skip to content

[MLIR][TPP] Enable --lower-pack-unpack-without-transpose on LoRA benchmark #173

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

Merged
merged 2 commits into from
Sep 25, 2024
Merged
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
24 changes: 16 additions & 8 deletions tools/mlir_bench/lora-runner.xsh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env xonsh

Check failure on line 1 in tools/mlir_bench/lora-runner.xsh

View workflow job for this annotation

GitHub Actions / ShellCheck

[shellcheck] reported by reviewdog 🐶 This shebang was unrecognized. ShellCheck only supports sh/bash/dash/ksh/'busybox sh'. Add a 'shell' directive to specify. [SC1008](https://github.com/koalaman/shellcheck/wiki/SC1008) Raw Output: ./tools/mlir_bench/lora-runner.xsh:1:1:error:This shebang was unrecognized. ShellCheck only supports sh/bash/dash/ksh/'busybox sh'. Add a 'shell' directive to specify. [SC1008](https://github.com/koalaman/shellcheck/wiki/SC1008)

# xonsh can be installed with `pip install xonsh`
# xonsh can then be run by invoking `python -m xonsh`
# this script in particular can be invoked with `python -m xonsh lora-benchmark.xsh`
# this script in particular can be invoked with `python -m xonsh lora-runner.xsh`

import openvino as ov
from openvino.runtime.op import Constant
Expand All @@ -13,8 +13,10 @@
from os import environ


LORA_DIMS = [8, 16, 32, 64, 128]
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 @@
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 @@ -110,18 +112,24 @@
no_ov_averages.append(run_no_ov_mlir("OV_MLIR=1 OV_MLIR_TPP=1 OV_MLIR_DEBUG=1"))

def run_manual_mlir(env_str):
mlir_model = build_mlir_lora_model(*config)
mlir_model = build_mlir_lora_model(*config, lora_dim=lora_dim)
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-without-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
Loading