Skip to content

Commit

Permalink
Merge pull request #84 from mlcommons/mlperf-inference
Browse files Browse the repository at this point in the history
MLPerf inference regular update to dev
  • Loading branch information
gfursin authored Jun 25, 2024
2 parents 123c029 + 788c7c0 commit be5892c
Show file tree
Hide file tree
Showing 91 changed files with 1,129 additions and 1,822 deletions.
1 change: 0 additions & 1 deletion .github/workflows/test-cm-script-features.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: CM script automation features test
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/test-cm-tutorial-retinanet.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: CM tutorial retinanet
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-image-classification-onnx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ name: image classification with ONNX

on:
pull_request:
branches: [ "main", "dev", "mlperf-inference" ]
branches: [ "main", "dev" ]
paths:
- '.github/workflows/test-image-classification-onnx.yml'
- '**'
Expand Down
69 changes: 69 additions & 0 deletions .github/workflows/test-mlperf-inference-abtf-poc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: MLPerf inference ABTF POC Test

on:
pull_request_target:
branches: [ "main", "mlperf-inference" ]
paths:
- '.github/workflows/test-mlperf-inference-abtf-poc.yml'
- '**'
- '!**.md'

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, ubuntu-20.04, ubuntu-24.04]
python-version: [ "3.8", "3.12" ]
backend: [ "pytorch" ]
implementation: [ "python" ]
exclude:
- os: ubuntu-24.04
python-version: "3.8"

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install cmind
cm pull repo --url=${{ github.event.pull_request.head.repo.html_url }} --checkout=${{ github.event.pull_request.head.ref }}
cm pull repo mlcommons@cm4abtf --branch=poc
- name: Test MLPerf Inference ABTF POC using ${{ matrix.backend }} on docker
run: |
cm run script --tags=run-abtf,inference,_poc-demo --adr.compiler.tags=gcc --quiet --docker --docker_it=no -v --gh_token=${{ secrets.ABTF_ACCESS_TOKEN }}
build2:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, macos-13]
python-version: [ "3.8", "3.12" ]
backend: [ "pytorch" ]
implementation: [ "python" ]
exclude:
- os: ubuntu-24.04
python-version: "3.8"

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python3 -m pip install cmind
cm pull repo --url=${{ github.event.pull_request.head.repo.html_url }} --checkout=${{ github.event.pull_request.head.ref }}
cm pull repo mlcommons@cm4abtf --branch=poc
- name: Test MLPerf Inference ABTF POC using ${{ matrix.backend }} on ${{ matrix.os }}
run: |
cm run script --tags=run-abtf,inference,_poc-demo --adr.compiler.tags=gcc --quiet -v --gh_token=${{ secrets.ABTF_ACCESS_TOKEN }}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ name: MLPerf loadgen with HuggingFace bert onnx fp32 squad model

on:
pull_request:
branches: [ "main", "dev", "mlperf-inference" ]
branches: [ "main", "dev" ]
paths:
- '.github/workflows/test-mlperf-loadgen-onnx-huggingface-bert-fp32-squad.yml'
- '**'
Expand Down
2 changes: 1 addition & 1 deletion automation/script/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -4429,7 +4429,7 @@ def update_env_with_values(env, fail_on_not_found=False):

if not tmp_values:
if key == 'CM_GIT_URL' and env.get('CM_GIT_AUTH', "no") == "yes":
if 'CM_GH_TOKEN' in env and '@' not in env['CM_GIT_URL']:
if env.get('CM_GH_TOKEN','') != '' and '@' not in env['CM_GIT_URL']:
params = {}
params["token"] = env['CM_GH_TOKEN']
value = get_git_url("token", value, params)
Expand Down
8 changes: 6 additions & 2 deletions automation/script/module_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1899,8 +1899,12 @@ def docker(i):
env['+ CM_DOCKER_BUILD_ARGS'].append("{}={}".format(key, value))

docker_use_host_group_id = i.get('docker_use_host_group_id', docker_settings.get('use_host_group_id'))
if docker_use_host_group_id in [True, 'True', 'yes'] and os.name != 'nt':
env['+ CM_DOCKER_BUILD_ARGS'].append("{}={}".format('CM_ADD_DOCKER_GROUP_ID', '\\"-g $(id -g $USER) -o\\"'))
if str(docker_use_host_group_id).lower() not in ['false', 'no', '0'] and os.name != 'nt':
env['+ CM_DOCKER_BUILD_ARGS'].append("{}={}".format('GID', '\\" $(id -g $USER) \\"'))

docker_use_host_user_id = i.get('docker_use_host_user_id', docker_settings.get('use_host_user_id'))
if str(docker_use_host_user_id).lower() not in ['false', 'no', '0'] and os.name != 'nt':
env['+ CM_DOCKER_BUILD_ARGS'].append("{}={}".format('UID', '\\" $(id -u $USER) \\"'))

docker_base_image = i.get('docker_base_image', docker_settings.get('base_image'))
docker_os = i.get('docker_os', docker_settings.get('os', 'ubuntu'))
Expand Down
142 changes: 124 additions & 18 deletions script/app-mlperf-inference-intel/_cm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,22 +97,15 @@ deps:
names:
- resnet50-model
- ml-model
tags: get,ml-model,resnet50,_fp32,_onnx,_from-tf
tags: get,ml-model,resnet50,_fp32,_pytorch

- enable_if_env:
CM_MODEL:
- resnet50
tags: compile,intel,model,_resnet50
names:
- resnet50-compiler

- enable_if_env:
CM_MODEL:
- resnet50
names:
- imagenet-preprocessed
- dataset-preprocessed
tags: get,dataset,imagenet,preprocessed,_for.resnet50,_NHWC,_full
- imagenet-original
- dataset-original
tags: get,dataset,imagenet,original,_full



Expand Down Expand Up @@ -164,27 +157,37 @@ variations:
default: true
env:
CM_MLPERF_INFERENCE_CODE_VERSION: "v4.0"
adr:
pytorch:
tags: _for-intel-mlperf-inference-v4.0
deps:
- tags: get,mlperf,inference,results,_go
names:
inference-results
version: v4.0
v4.0,gptj_:
adr:
pytorch:
tags: _for-intel-mlperf-inference-v4.0
v4.0,bert_:
adr:
pytorch:
tags: _for-intel-mlperf-inference-v4.0
v3.1:
group: version
env:
CM_MLPERF_INFERENCE_CODE_VERSION: "v3.1"
adr:
pytorch:
tags: _for-intel-mlperf-inference-v3.1
deps:
- tags: get,mlperf,inference,results,_ctuning
names:
inference-results
version: v3.1

v3.1,gptj_:
adr:
pytorch:
tags: _for-intel-mlperf-inference-v3.1
v3.1,bert_:
adr:
pytorch:
tags: _for-intel-mlperf-inference-v3.1

# Target devices
cpu:
Expand Down Expand Up @@ -218,7 +221,7 @@ variations:
loadgen_dataset_size: 50000
CM_BENCHMARK: STANDALONE_CLASSIFICATION

resnet50,uint8:
resnet50,int8:
env:
CM_IMAGENET_ACCURACY_DTYPE: int8

Expand Down Expand Up @@ -310,6 +313,104 @@ variations:
- pip-package
- optimum

resnet50,pytorch:
adr:
conda-package:
tags: _name.resnet50-pt
deps:
- tags: get,conda,_name.resnet50-pt
- tags: get,python,_conda.resnet50-pt
adr:
conda-python:
version: "3.9"
- names:
- conda-package
- mkl
tags: get,generic,conda-package,_package.mkl,_source.conda-forge
enable_if_env:
CM_MLPERF_INFERENCE_CODE_VERSION:
- v4.0
- names:
- conda-package
- mkl-include
tags: get,generic,conda-package,_package.mkl-include,_source.intel
- names:
- conda-package
- llvm-openmp
tags: get,generic,conda-package,_package.llvm-openmp,_source.conda-forge
- names:
- conda-package
- ncurses
tags: get,generic,conda-package,_package.ncurses,_source.conda-forge
- names:
- conda-package
- ncurses
tags: get,generic,conda-package,_package.ncurses,_source.conda-forge
- tags: get,generic-sys-util,_numactl
- tags: get,generic,conda-package,_package.jemalloc,_source.conda-forge
names:
- conda-package
- jemalloc
- tags: get,generic-python-lib,_package.torchvision,_no-deps
names:
- pip-package
- torchvision
version: "0.13.0"
- tags: get,pytorch,from.src,_for-intel-mlperf-inference-resnet50
- tags: install,opencv,from.src,_branch.4.x
names:
- opencv-from-src
- tags: get,git,repo,_repo.https://github.com/Tencent/rapidjson.git,_sha.e4bde977
names:
- rapidjson-src
env:
CM_GIT_CHECKOUT_PATH_ENV_NAME: CM_RAPIDJSON_SRC_REPO_PATH
- tags: install,gflags,from.src
names:
- gflags-from-src
- tags: install,onednn,from.src,_branch.rls-v2.6
names:
- onednn-from-src
- tags: get,generic-python-lib,_package.scikit-learn
names:
- pip-package
- scikit-learn
- tags: install,ipex,from.src,_for-intel-mlperf-inference-v3.1-resnet50
names:
- ipex-from-src
- tags: get,generic,conda-package,_package.ninja
names:
- conda-package
- ninja
- tags: get,mlcommons,inference,src
names:
- inference-src
- tags: get,mlcommons,inference,loadgen,_custom-python,_keep-build
names:
- inference-loadgen
env:
CM_PYTHON_BIN_WITH_PATH: "<<<CM_CONDA_BIN_PATH>>>/python3"


resnet50,build-harness:
deps:
- tags: reproduce,mlperf,inference,intel,_compile-model
inherit_variation_tags: true
force_cache: true
skip_inherit_variation_groups:
- run-mode
- loadgen-scenario

resnet50,compile-model:
deps:
- tags: reproduce,mlperf,inference,intel,_calibration
inherit_variation_tags: true
force_cache: true
skip_inherit_variation_groups:
- run-mode
- loadgen-scenario


gptj_,pytorch:
adr:
conda-package:
Expand Down Expand Up @@ -513,6 +614,11 @@ variations:
- CM_ML_MODEL_*
- DATA_PATH

compile-model:
group: run-mode
env:
CM_LOCAL_MLPERF_INFERENCE_INTEL_RUN_MODE: compilation

calibration:
group: run-mode
env:
Expand Down
58 changes: 58 additions & 0 deletions script/app-mlperf-inference-intel/build_resnet50_harness.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
export PATH=${CM_CONDA_BIN_PATH}:$PATH
echo $PWD


export DATA_CAL_DIR=calibration_dataset
export CHECKPOINT=${CM_ML_MODEL_FILE_WITH_PATH}

cd ${CM_HARNESS_CODE_ROOT}

cd src/ckernels/ && mkdir -p 3rdparty && \
cd 3rdparty && \
(test -e onednn || git clone https://github.com/oneapi-src/oneDNN.git onednn) && \
cd onednn && \
git checkout v2.6 && cd ../../../../


export CMAKE_PREFIX_PATH=${CONDA_PREFIX:-"$(dirname $(which conda))/../"}

export IPEX_PATH=${CM_IPEX_INSTALLED_PATH}
export TORCH_PATH=`python -c 'import torch;print(torch.utils.cmake_prefix_path)'`

if [[ -z ${TORCH_PATH} ]]; then
echo "Torch not found"
exit 1
fi

export LOADGEN_DIR="${CM_MLPERF_INFERENCE_LOADGEN_INSTALL_PATH}/../"
export OPENCV_DIR=${CM_OPENCV_BUILD_PATH}
export RAPIDJSON_INCLUDE_DIR=${CM_RAPIDJSON_SRC_REPO_PATH}/include
export GFLAGS_DIR=${CM_GFLAGS_BUILD_PATH}
export ONEDNN_DIR=${CM_ONEDNN_INSTALLED_PATH}
export USE_CUDA=0

BUILD_DIR=${PWD}/build
rm -rf "$BUILD_DIR"

SRC_DIR=${PWD}/src

export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${OPENCV_DIR}/lib:${ONEDNN_DIR}/build/src:${CONDA_PREFIX}/lib
export LIBRARY_PATH=${LIBRARY_PATH}:${CONDA_PREFIX}/lib


cmd="cmake -DCMAKE_PREFIX_PATH=${TORCH_PATH} \
-DLOADGEN_DIR=${LOADGEN_DIR} \
-DOpenCV_DIR=${OPENCV_DIR} \
-DRapidJSON_INCLUDE_DIR=${RAPIDJSON_INCLUDE_DIR} \
-Dgflags_DIR=${GFLAGS_DIR} \
-DINTEL_EXTENSION_FOR_PYTORCH_PATH=${IPEX_PATH} \
-DONEDNN_DIR=${ONEDNN_DIR} \
-DCMAKE_BUILD_TYPE=Release \
-B${BUILD_DIR} \
-H${SRC_DIR}"
echo "$cmd"
eval "$cmd"
test "$?" -eq 0 || exit "$?"

cmake --build ${BUILD_DIR} --config Release -j$(nproc)
test "$?" -eq 0 || exit "$?"
12 changes: 12 additions & 0 deletions script/app-mlperf-inference-intel/compile_resnet50.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export PATH=${CM_CONDA_BIN_PATH}:$PATH
echo $PWD


export DATA_CAL_DIR=calibration_dataset
export CHECKPOINT=${CM_ML_MODEL_FILE_WITH_PATH}

cd ${CM_HARNESS_CODE_ROOT}
#mkdir -p
#cp src/ckernels/scripts/resnet50-int8-scales.json
bash generate_torch_model.sh
test "$?" -eq 0 || exit "$?"
Loading

0 comments on commit be5892c

Please sign in to comment.