Skip to content

Commit

Permalink
Merge from CTuning (#1032)
Browse files Browse the repository at this point in the history
  • Loading branch information
gfursin authored Dec 2, 2023
2 parents 27c5c13 + 05c4899 commit 2e2ffff
Show file tree
Hide file tree
Showing 23 changed files with 1,169 additions and 75 deletions.
4 changes: 4 additions & 0 deletions cm-mlops/script/app-mlperf-inference-reference/_cm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ input_mapping:
max_batchsize: CM_MLPERF_LOADGEN_MAX_BATCHSIZE
mode: CM_MLPERF_LOADGEN_MODE
num_threads: CM_NUM_THREADS
threads: CM_NUM_THREADS
dataset: CM_MLPERF_VISION_DATASET_OPTION
model: CM_MLPERF_CUSTOM_MODEL_PATH
output_dir: OUTPUT_BASE_DIR
Expand Down Expand Up @@ -769,6 +770,9 @@ variations:
- tags: get,generic-python-lib,_package.torchmetrics
names:
- torchmetrics
- tags: get,generic-python-lib,_package.torch-fidelity
names:
- torch-fidelity
adr:
mlperf-implementation:
tags: _repo.https://github.com/pgmpablo157321/inference
Expand Down
12 changes: 8 additions & 4 deletions cm-mlops/script/app-mlperf-inference-reference/customize.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ def preprocess(i):

env['CM_MLPERF_LOADGEN_EXTRA_OPTIONS'] += " --mlperf_conf '" + env['CM_MLPERF_CONF'] + "'"

env['MODEL_DIR'] = env.get('CM_ML_MODEL_PATH', os.path.dirname(env.get('CM_MLPERF_CUSTOM_MODEL_PATH', env.get('CM_ML_MODEL_FILE_WITH_PATH'))))
env['MODEL_DIR'] = env.get('CM_ML_MODEL_PATH')
if not env['MODEL_DIR']:
env['MODEL_DIR'] = os.path.dirname(env.get('CM_MLPERF_CUSTOM_MODEL_PATH', env.get('CM_ML_MODEL_FILE_WITH_PATH')))

RUN_CMD = ""
state['RUN'] = {}
Expand All @@ -84,7 +86,7 @@ def preprocess(i):
if int(NUM_THREADS) > 2 and env['CM_MLPERF_DEVICE'] == "gpu":
NUM_THREADS = "2" # Don't use more than 2 threads when run on GPU

if env['CM_MODEL'] in [ 'resnet50', 'retinanet'] :
if env['CM_MODEL'] in [ 'resnet50', 'retinanet', 'sdxl' ] :
scenario_extra_options += " --threads " + NUM_THREADS

ml_model_name = env['CM_MODEL']
Expand Down Expand Up @@ -250,10 +252,12 @@ def get_run_cmd_reference(env, scenario_extra_options, mode_extra_options, datas
" --profile " + 'stable-diffusion-xl-pytorch ' + \
" --dataset " + 'coco-1024' + \
" --dataset-path " + env['CM_DATASET_PATH_ROOT'] + \
' --dtype ' + env['CM_MLPERF_MODEL_PRECISION'].replace("float", "fp") + \
' --dtype ' + env['CM_MLPERF_MODEL_PRECISION'].replace("bfloat", "bf").replace("float", "fp") + \
" --device " + device + \
env['CM_MLPERF_LOADGEN_EXTRA_OPTIONS'] + \
" --model-path " + env['MODEL_DIR']
scenario_extra_options + mode_extra_options + \
" --output " + env['CM_MLPERF_OUTPUT_DIR'] + \
" "#--model-path " + env['MODEL_DIR']

elif "3d-unet" in env['CM_MODEL']:

Expand Down
47 changes: 47 additions & 0 deletions cm-mlops/script/get-dataset-imagenet-calibration/_cm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
alias: get-dataset-imagenet-calibration
automation_alias: script
automation_uid: 5b4e0237da074764
cache: true
deps:
- tags: download,file
force_cache: true
extra_cache_tags: imagenet-calibration,imagenet,calibration
names:
- calibration-file-downloader
env:
CM_DOWNLOAD_FINAL_ENV_NAME: CM_MLPERF_IMAGENET_CALIBRATION_LIST_FILE_WITH_PATH
CM_DOWNLOAD_LOCAL_FILE_PATH: <<<CM_MLPERF_IMAGENET_CALIBRATION_LIST_LOCAL_PATH>>>

docker_input_mapping: {}
input_description: {}
input_mapping: {}
new_env_keys:
- CM_MLPERF_IMAGENET_CALIBRATION_LIST_FILE_WITH_PATH
new_state_keys: []
post_deps: []
posthook_deps: []
prehook_deps: []
tags:
- get
- dataset
- imagenet
- calibration
uid: 30361fad3dff49ff
variations:
mlperf.option1:
group: calibration-option
default: true
env:
CM_MLPERF_IMAGENET_CALIBRATION_OPTION: one
CM_DOWNLOAD_CHECKSUM: f09719174af3553119e2c621157773a6
adr:
calibration-file-downloader:
tags: _url.https://github.com/mlcommons/inference/raw/master/calibration/ImageNet/cal_image_list_option_1.txt
mlperf.option2:
group: calibration-option
env:
CM_MLPERF_IMAGENET_CALIBRATION_OPTION: two
CM_DOWNLOAD_CHECKSUM: e44582af00e3b4fc3fac30efd6bdd05f
adr:
calibration-file-downloader:
tags: _url.https://github.com/mlcommons/inference/raw/master/calibration/ImageNet/cal_image_list_option_2.txt
22 changes: 22 additions & 0 deletions cm-mlops/script/get-dataset-imagenet-calibration/customize.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from cmind import utils
import os

def preprocess(i):

os_info = i['os_info']

env = i['env']

meta = i['meta']

automation = i['automation']

quiet = (env.get('CM_QUIET', False) == 'yes')

return {'return':0}

def postprocess(i):

env = i['env']

return {'return':0}
1 change: 1 addition & 0 deletions cm-mlops/script/get-dataset-imagenet-calibration/run.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rem native script
27 changes: 27 additions & 0 deletions cm-mlops/script/get-dataset-imagenet-calibration/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

#CM Script location: ${CM_TMP_CURRENT_SCRIPT_PATH}

#To export any variable
#echo "VARIABLE_NAME=VARIABLE_VALUE" >>tmp-run-env.out

#${CM_PYTHON_BIN_WITH_PATH} contains the path to python binary if "get,python" is added as a dependency



function exit_if_error() {
test $? -eq 0 || exit $?
}

function run() {
echo "Running: "
echo "$1"
echo ""
if [[ ${CM_FAKE_RUN} != 'yes' ]]; then
eval "$1"
exit_if_error
fi
}

#Add your run commands here...
# run "$CM_RUN_CMD"
38 changes: 38 additions & 0 deletions cm-mlops/script/get-lib-qaic-api/_cm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"alias": "get-lib-qaic-api",
"automation_alias": "script",
"automation_uid": "5b4e0237da074764",
"cache": true,
"category": "Detection or installation of tools and artifacts",
"default_version": "master",
"deps": [
{
"tags": "detect,os"
}
],
"env": {
},
"new_env_keys": [
"CM_LIB_QAIC_*",
"+C_INCLUDE_PATH",
"+CPLUS_INCLUDE_PATH",
"+LD_LIBRARY_PATH"
],
"prehook_deps": [
],
"tags": [
"get",
"api",
"lib-qaic-api",
"lib",
"qaic"
],
"uid": "1e253ae184e44f23",
"versions": {
"master": {
"env": {
"CM_LIB_QAIC_VERSION": "master"
}
}
}
}
39 changes: 39 additions & 0 deletions cm-mlops/script/get-lib-qaic-api/customize.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from cmind import utils
import os

def preprocess(i):
os_info = i['os_info']
if os_info['platform'] == 'windows':
return {'return':1, 'error': 'Windows is not supported in this script yet'}

env = i['env']

#env['CM_GIT_CHECKOUT'] = env['CM_TMP_GIT_BRANCH_NAME']

return {'return':0}

def postprocess(i):

env = i['env']

paths = [
"+C_INCLUDE_PATH",
"+CPLUS_INCLUDE_PATH",
"+LD_LIBRARY_PATH",
"+DYLD_FALLBACK_LIBRARY_PATH"
]

for key in paths:
env[key] = []

include_paths = [ env['CM_TMP_CURRENT_SCRIPT_PATH'] ]

for inc_path in include_paths:
env['+C_INCLUDE_PATH'].append(inc_path)
env['+CPLUS_INCLUDE_PATH'].append(inc_path)

version = "master"
env['CM_QAIC_API_SRC_FILE'] = os.path.join(env['CM_TMP_CURRENT_SCRIPT_PATH'], version, "QAicInfApi.cpp")
env['CM_QAIC_API_INC_FILE'] = os.path.join(env['CM_TMP_CURRENT_SCRIPT_PATH'], version, "QAicInfApi.h")

return {'return':0}
Loading

0 comments on commit 2e2ffff

Please sign in to comment.