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

Enables docker run in inference submission generation #486

Merged
merged 41 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
c59608e
enable docker-submission generation
anandhu-eng Oct 31, 2024
28ce998
real run set to false
anandhu-eng Oct 31, 2024
2b35b79
docker run set to false
anandhu-eng Oct 31, 2024
3309a35
Update results dir env variable
anandhu-eng Oct 31, 2024
8ffa471
updated docker permissions
anandhu-eng Oct 31, 2024
5ced2d2
update docker permissions
anandhu-eng Oct 31, 2024
3cabfa1
Add docker input mapping
anandhu-eng Oct 31, 2024
5149a0b
enabled modifying input mapping env inside docker
anandhu-eng Oct 31, 2024
44be9bd
update the env key to run command
anandhu-eng Oct 31, 2024
dc2d75c
pass uid and gid args to docker run
anandhu-eng Nov 1, 2024
97ccbc9
added docker run args
anandhu-eng Nov 1, 2024
1634d68
Updated build to run args
anandhu-eng Nov 1, 2024
5795ff3
Update module_misc.py
anandhu-eng Nov 1, 2024
7d6ee2b
clean the contents rather than the main submission folder
anandhu-eng Nov 1, 2024
cb81816
update-prevent deletion of entire directory
anandhu-eng Nov 1, 2024
fc4fea3
test commit
anandhu-eng Nov 1, 2024
fd70fcf
bug fix
anandhu-eng Nov 1, 2024
8cf8d56
bug fix
anandhu-eng Nov 1, 2024
941efef
added mount for submission processed
anandhu-eng Nov 1, 2024
893530e
code clean
anandhu-eng Nov 4, 2024
de29f11
code clean
anandhu-eng Nov 4, 2024
324df6c
code clean
anandhu-eng Nov 5, 2024
569dc12
Handle dynamic env variables
anandhu-eng Nov 5, 2024
18c284c
update state from meta
anandhu-eng Nov 5, 2024
659aecc
Added submission base directory
anandhu-eng Nov 5, 2024
536b9ff
seperated inp through cm.access
anandhu-eng Nov 5, 2024
3f521c6
fix typo
anandhu-eng Nov 5, 2024
2377572
Supports submission base dir
anandhu-eng Nov 5, 2024
5fabd94
code clean
anandhu-eng Nov 5, 2024
c95819c
consider base submission dir as output dir
anandhu-eng Nov 5, 2024
4ee3733
fix typo
anandhu-eng Nov 5, 2024
1df3eb1
bug fix
anandhu-eng Nov 5, 2024
a96d211
fix typo
anandhu-eng Nov 5, 2024
90b4094
Merge branch 'mlperf-inference' into anandhu-eng-patch-3
anandhu-eng Nov 5, 2024
87ccbe0
submission base dir -> tar output
anandhu-eng Nov 5, 2024
152712f
revert commit https://github.com/mlcommons/cm4mlops/pull/486/commits/…
anandhu-eng Nov 5, 2024
a89fa43
get submission directory if base dir not specified - docker
anandhu-eng Nov 5, 2024
bfe6cb6
add tar output dir
anandhu-eng Nov 5, 2024
6e48bdd
Update _cm.json
anandhu-eng Nov 5, 2024
ab2f528
code clean
anandhu-eng Nov 5, 2024
e0ea139
Merge branch 'mlperf-inference' into anandhu-eng-patch-3
arjunsuresh Nov 5, 2024
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
23 changes: 22 additions & 1 deletion automation/script/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -4011,6 +4011,19 @@ def update_deps(self, i):

return {'return':0}

##############################################################################
def update_state_from_meta(self, meta, env, state, const, const_state, deps, post_deps, prehook_deps, posthook_deps, new_env_keys, new_state_keys, i):
"""
Updates state and env from meta
Args:
"""

r = update_state_from_meta(meta, env, state, const, const_state, deps, post_deps, prehook_deps, posthook_deps, new_env_keys, new_state_keys, i)
if r['return']>0:
return r

return {'return':0}

##############################################################################
def get_default_path_list(self, i):
default_path_env_key = i.get('default_path_env_key', '')
Expand Down Expand Up @@ -5260,9 +5273,17 @@ def update_state_from_meta(meta, env, state, const, const_state, deps, post_deps
r4 = update_deps(posthook_deps, add_deps_info, True, env)
if r1['return']>0 and r2['return']>0 and r3['return'] > 0 and r4['return'] > 0: return r1

# i would have 'input' when called through cm.access
input_update_env = i.get('input', i)

input_mapping = meta.get('input_mapping', {})
if input_mapping:
update_env_from_input_mapping(env, i['input'], input_mapping)
update_env_from_input_mapping(env, input_update_env, input_mapping)

# handle dynamic env values
r = update_env_with_values(env)
if r['return']>0:
return r

# Possibly restrict this to within docker environment
add_deps_info = meta.get('ad', i.get('ad', {})) #we need to see input here
Expand Down
13 changes: 9 additions & 4 deletions automation/script/module_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1802,6 +1802,10 @@ def docker(i):
state['docker'] = docker_settings
add_deps_recursive = i.get('add_deps_recursive', {})

r = script_automation.update_state_from_meta(meta, env, state, const, const_state, deps = [], post_deps = [], prehook_deps = [], posthook_deps = [], new_env_keys = [], new_state_keys = [], i = i)
if r['return'] > 0:
return r

r = script_automation._update_state_from_variations(i, meta, variation_tags, variations, env, state, const, const_state, deps = [], post_deps = [], prehook_deps = [], posthook_deps = [], new_env_keys_from_meta = [], new_state_keys_from_meta = [], add_deps_recursive = add_deps_recursive, run_state = {}, recursion_spaces='', verbose = False)
if r['return'] > 0:
return r
Expand Down Expand Up @@ -1916,11 +1920,12 @@ def docker(i):
mounts[index] = new_host_mount+":"+new_container_mount
if host_env_key:
container_env_string += " --env.{}={} ".format(host_env_key, container_env_key)
# check if the below lines are needed when inputs are mapped to container paths
'''for v in docker_input_mapping:

for v in docker_input_mapping:
if docker_input_mapping[v] == host_env_key:
i[v] = container_env_key
'''
i[v] = container_env_key
i_run_cmd[v] = container_env_key

mounts = list(filter(lambda item: item is not None, mounts))

mount_string = "" if len(mounts)==0 else ",".join(mounts)
Expand Down
44 changes: 43 additions & 1 deletion script/generate-mlperf-inference-submission/_cm.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"run_style": "CM_MLPERF_RUN_STYLE",
"skip_truncation": "CM_SKIP_TRUNCATE_ACCURACY",
"submission_dir": "CM_MLPERF_INFERENCE_SUBMISSION_DIR",
"submission_base_dir": "CM_MLPERF_INFERENCE_SUBMISSION_BASE_DIR",
"clean": "CM_MLPERF_CLEAN_SUBMISSION_DIR",
"hw_name": "CM_HW_NAME",
"sw_notes_extra": "CM_MLPERF_SUT_SW_NOTES_EXTRA",
Expand Down Expand Up @@ -120,5 +121,46 @@
"mlperf-inference-submission",
"mlcommons-inference-submission"
],
"uid": "5f8ab2d0b5874d53"
"uid": "5f8ab2d0b5874d53",
"docker": {
"use_host_group_id": true,
"use_host_user_id": true,
"real_run": false,
"deps": [
{
"tags": "get,mlperf,inference,results,dir,local",
"names": "get-mlperf-inference-results-dir",
"skip_if_env": {
"CM_MLPERF_INFERENCE_RESULTS_DIR_": [
"on"
]
}
},
{
"tags": "get,mlperf,inference,submission,dir,local",
"names": "get-mlperf-inference-submission-dir",
"skip_if_any_env": {
"CM_MLPERF_INFERENCE_SUBMISSION_BASE_DIR": [
"on"
]
}
}
],
"pre_run_cmds": [
"cm pull repo"
],
"mounts": [
"${{ CM_MLPERF_INFERENCE_SUBMISSION_BASE_DIR }}:${{ CM_MLPERF_INFERENCE_SUBMISSION_BASE_DIR }}",
"${{ CM_MLPERF_INFERENCE_RESULTS_DIR_ }}:${{ CM_MLPERF_INFERENCE_RESULTS_DIR_ }}"
],
"extra_run_args": " --cap-add SYS_ADMIN",
"os": "ubuntu",
"cm_repo": "mlcommons@cm4mlops",
"cm_repo_branch": "mlperf-inference",
"os_version": "22.04",
"docker_input_mapping": {
"submission_base_dir": "CM_MLPERF_INFERENCE_SUBMISSION_BASE_DIR",
"results_dir": "CM_MLPERF_INFERENCE_RESULTS_DIR_"
}
}
}
11 changes: 9 additions & 2 deletions script/generate-mlperf-inference-submission/customize.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,19 @@ def generate_submission(i):
env['CM_MLPERF_INFERENCE_SUBMISSION_DIR'] = os.path.join(user_home, "mlperf_submission")

submission_dir = env.get('CM_MLPERF_INFERENCE_SUBMISSION_DIR', '')
if submission_dir == '':
submission_base_dir = env.get('CM_MLPERF_INFERENCE_SUBMISSION_BASE_DIR', '')
if submission_base_dir == '':
return {'return':1, 'error':f"Both CM_MLPERF_INFERENCE_SUBMISSION_DIR and CM_MLPERF_INFERENCE_SUBMISSION_BASE_DIR can not be empty!"}
else:
submission_dir = os.path.join(submission_base_dir, "mlperf_inference_submission")
env['CM_MLPERF_INFERENCE_SUBMISSION_DIR'] = submission_dir

if env.get('CM_MLPERF_CLEAN_SUBMISSION_DIR','')!='':
print ('=================================================')
print ('Cleaning {} ...'.format(env['CM_MLPERF_INFERENCE_SUBMISSION_DIR']))
if os.path.exists(env['CM_MLPERF_INFERENCE_SUBMISSION_DIR']):
shutil.rmtree(env['CM_MLPERF_INFERENCE_SUBMISSION_DIR'])
if os.path.exists(submission_dir):
shutil.rmtree(submission_dir)
print ('=================================================')

if not os.path.isdir(submission_dir):
Expand Down
3 changes: 3 additions & 0 deletions script/get-mlperf-inference-sut-description/_cm.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
"automation_uid": "5b4e0237da074764",
"cache": false,
"category": "MLPerf benchmark support",
"docker": {
"run": false
},
"deps": [
{
"tags": "detect,os"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ def postprocess(i):
shutil.copytree(submission_dir, submission_backup)
shutil.rmtree(submission_dir)
os.rename(submission_processed, submission_dir)

return {'return':0}
3 changes: 3 additions & 0 deletions script/run-mlperf-inference-submission-checker/customize.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ def postprocess(i):
if x!='':
env['CM_TAR_OUTFILE']=x

if env.get('CM_MLPERF_INFERENCE_SUBMISSION_BASE_DIR', '') != '':
env['CM_TAR_OUTPUT_DIR'] = env['CM_MLPERF_INFERENCE_SUBMISSION_BASE_DIR']

x=env.get('MLPERF_INFERENCE_SUBMISSION_SUMMARY','')
if x!='':
for y in ['.csv', '.json', '.xlsx']:
Expand Down
Loading