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

[mpact][benchmark] add regression benchmark to gh page #52

Closed
wants to merge 10 commits into from
Closed
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
90 changes: 90 additions & 0 deletions .github/workflows/regression-benchmark.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Regression benchmark

on:
# workflow_run:
# workflows:
# - Check code formatting
# types:
# - completed
# branches:
# - regression_bench
pull_request:
branches: [ "main" ]

permissions:
contents: write
deployments: write
pull-requests: write
repository-projects: write

jobs:
benchmark:
name: Performance regression check
runs-on: ubuntu-latest
env:
CACHE_DIR: ${{ github.workspace }}/.ccache
PYTHONPATH: ${{ github.workspace }}/build/tools/mpact/python_packages/mpact
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
token: ${{ secrets.GITHUB_TOKEN }}

- name: Setup Python Version
uses: actions/setup-python@v5
with:
python-version: 3.11 # Install the python version needed

- name: Set up ccache
uses: hendrikmuhs/[email protected]

- name: Install requirements
run: |
export CCACHE_DIR=${{ env.CACHE_DIR }}
python -m pip install --upgrade pip
python -m pip install --upgrade pip
python -m pip install pytest pytest-benchmark
python -m pip install -r externals/torch-mlir/requirements.txt
python -m pip install -r externals/torch-mlir/torchvision-requirements.txt

- name: Create build directory
run: mkdir build

- name: Configure CMake
run: >
cmake -GNinja -Bbuild
-DCMAKE_BUILD_TYPE=Release
-DLLVM_ENABLE_PROJECTS=mlir
-DLLVM_ENABLE_ASSERTIONS=ON
-DLLVM_EXTERNAL_PROJECTS="torch-mlir;mpact"
-DLLVM_EXTERNAL_TORCH_MLIR_SOURCE_DIR="${PWD}/externals/torch-mlir"
-DLLVM_EXTERNAL_MPACT_SOURCE_DIR="${PWD}"
-DLLVM_TARGETS_TO_BUILD=host
-DMLIR_ENABLE_BINDINGS_PYTHON=ON
-DCMAKE_C_COMPILER_LAUNCHER=ccache
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
-DCMAKE_C_COMPILER=clang
-DCMAKE_CXX_COMPILER=clang++
"externals/torch-mlir/externals/llvm-project/llvm"

- name: Build
run: cmake --build build --target build-benchmark-mpact

- name: Run benchmark
run: pytest benchmark/python/benchmarks/regression_benchmark.py --benchmark-json output.json

- name: Store benchmark result
uses: benchmark-action/github-action-benchmark@v1
with:
tool: 'pytest'
output-file-path: output.json
fail-on-alert: true
# GitHub API token to make a commit comment
github-token: ${{ secrets.GITHUB_TOKEN }}
# Enable alert commit comment
comment-on-alert: true
# Mention @yinying-lisa-li in the commit comment
alert-comment-cc-users: '@yinying-lisa-li'
# Push and deploy GitHub pages branch automatically
auto-push: true
alert-threshold: 120%
65 changes: 65 additions & 0 deletions benchmark/python/benchmarks/regression_benchmark.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import pytest
from mpact.models.kernels import *
from mpact_benchmark.utils.tensor_generator import generate_tensor

SHAPE = (1024, 1024)
SPARSITY = 0.8

dense_tensor1 = generate_tensor(0, SHAPE, SPARSITY)
dense_tensor2 = generate_tensor(1, SHAPE, SPARSITY)
dense_tensor3 = generate_tensor(2, SHAPE, SPARSITY)
dense_vector = generate_tensor(1, (SHAPE[0],), SPARSITY)

temp = generate_tensor(0, (2046, 2046), 0.5)

sparse_tensor1 = dense_tensor1.to_sparse_csr()
sparse_tensor2 = dense_tensor2.to_sparse_csr()
sparse_tensor3 = dense_tensor3.to_sparse_csr()


def test_mv_dense(benchmark):
benchmark(MVNet(), dense_tensor1, dense_vector)


def test_mm_dense(benchmark):
benchmark(MMNet(), dense_tensor1, dense_tensor2)


def test_add_dense(benchmark):
benchmark(AddNet(), dense_tensor1, dense_tensor2)


def test_mul_dense(benchmark):
benchmark(MulNet(), dense_tensor1, dense_tensor2)


def test_nop_dense(benchmark):
benchmark(SelfNet(), dense_tensor1)


def test_sddmm_dense(benchmark):
benchmark(SDDMMNet(), temp, temp, temp)


def test_mv_sparse(benchmark):
benchmark(MVNet(), sparse_tensor1, dense_vector)


def test_mm_sparse(benchmark):
benchmark(MMNet(), sparse_tensor1, sparse_tensor2)


def test_add_sparse(benchmark):
benchmark(AddNet(), sparse_tensor1, sparse_tensor2)


def test_mul_sparse(benchmark):
benchmark(MulNet(), sparse_tensor1, sparse_tensor2)


def test_nop_sparse(benchmark):
benchmark(SelfNet(), sparse_tensor1)


def test_sddmm_sparse(benchmark):
benchmark(SDDMMNet(), temp, temp, temp)
2 changes: 1 addition & 1 deletion externals/torch-mlir
Submodule torch-mlir updated 56 files
+0 −14 docs/development.md
+1 −1 externals/llvm-project
+0 −10 include/torch-mlir/Conversion/TorchOnnxToTorch/Patterns.h
+0 −303 include/torch-mlir/Dialect/Torch/IR/GeneratedTorchOps.td
+1 −31 include/torch-mlir/Dialect/Torch/IR/TorchOps.h
+0 −2 include/torch-mlir/Dialect/Torch/Utils/Utils.h
+20 −269 lib/Conversion/TorchOnnxToTorch/DefaultDomainAtoF.cpp
+14 −206 lib/Conversion/TorchOnnxToTorch/DefaultDomainGtoP.cpp
+52 −436 lib/Conversion/TorchOnnxToTorch/DefaultDomainQtoZ.cpp
+15 −57 lib/Conversion/TorchToLinalg/DataMovement.cpp
+3 −8 lib/Conversion/TorchToLinalg/Linear.cpp
+0 −10 lib/Conversion/TorchToLinalg/Pooling.cpp
+1 −3 lib/Conversion/TorchToLinalg/TorchToLinalg.cpp
+0 −215 lib/Conversion/TorchToLinalg/Uncategorized.cpp
+21 −15 lib/Conversion/TorchToLinalg/Utils.cpp
+13 −50 lib/Conversion/TorchToTMTensor/TorchToTMTensor.cpp
+0 −189 lib/Conversion/TorchToTosa/TorchToTosa.cpp
+2 −2 lib/Conversion/Utils/Utils.cpp
+6 −7 lib/Dialect/TMTensor/IR/TMTensorOps.cpp
+4 −42 lib/Dialect/Torch/IR/TorchOps.cpp
+0 −553 lib/Dialect/Torch/Transforms/AbstractInterpLibrary.cpp
+0 −391 lib/Dialect/Torch/Transforms/DecomposeComplexOps.cpp
+0 −6 lib/Dialect/Torch/Transforms/LowerToBackendContract.cpp
+7 −6 lib/Dialect/Torch/Utils/Utils.cpp
+1 −1 lib/Dialect/TorchConversion/Transforms/BackendTypeConversion.cpp
+0 −4 projects/pt1/e2e_testing/main.py
+21 −39 projects/pt1/e2e_testing/xfail_sets.py
+0 −190 projects/pt1/python/torch_mlir/jit_ir_importer/build_tools/abstract_interp_lib_gen.py
+0 −33 projects/pt1/python/torch_mlir/jit_ir_importer/build_tools/torch_ods_gen.py
+1 −7 projects/pt1/python/torch_mlir_e2e_test/configs/onnx_backend.py
+1 −13 projects/pt1/python/torch_mlir_e2e_test/framework.py
+0 −1 projects/pt1/python/torch_mlir_e2e_test/test_suite/__init__.py
+0 −87 projects/pt1/python/torch_mlir_e2e_test/test_suite/conv.py
+0 −118 projects/pt1/python/torch_mlir_e2e_test/test_suite/elementwise.py
+0 −51 projects/pt1/python/torch_mlir_e2e_test/test_suite/linalg_algorithms.py
+0 −25 projects/pt1/python/torch_mlir_e2e_test/test_suite/quantized_models.py
+0 −33 projects/pt1/python/torch_mlir_e2e_test/test_suite/scatter.py
+0 −3 python/torch_mlir/compiler_utils.py
+0 −1 python/torch_mlir/extras/fx_decomp_util.py
+12 −30 python/torch_mlir/extras/fx_importer.py
+0 −61 test/Conversion/TorchOnnxToTorch/simple_ops_a_to_f.mlir
+16 −187 test/Conversion/TorchOnnxToTorch/simple_ops_g_to_p.mlir
+0 −234 test/Conversion/TorchOnnxToTorch/simple_ops_q_to_z.mlir
+0 −38 test/Conversion/TorchToLinalg/convolution.mlir
+1 −1 test/Conversion/TorchToLinalg/elementwise.mlir
+11 −11 test/Conversion/TorchToLinalg/pooling.mlir
+0 −27 test/Conversion/TorchToLinalg/view.mlir
+9 −6 test/Conversion/TorchToLinalg/view_strict.mlir
+5 −5 test/Conversion/TorchToSCF/basic.mlir
+24 −12 test/Conversion/TorchToStablehlo/elementwise.mlir
+14 −13 test/Conversion/TorchToStablehlo/linear.mlir
+34 −20 test/Conversion/TorchToStablehlo/view_like.mlir
+0 −56 test/Conversion/TorchToTosa/basic.mlir
+0 −10 test/Dialect/Torch/canonicalize.mlir
+0 −3 test/Dialect/Torch/ops.mlir
+7 −18 test/python/fx_importer/sparse_test.py
Loading