From f562fdf708162fd45e74c2be54c8690725d9c4fb Mon Sep 17 00:00:00 2001 From: Arjun Suresh Date: Thu, 30 Jan 2025 04:48:09 +0530 Subject: [PATCH 1/4] Fix typo in clean-nvidia-scratch-space --- script/clean-nvidia-mlperf-inference-scratch-space/customize.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/clean-nvidia-mlperf-inference-scratch-space/customize.py b/script/clean-nvidia-mlperf-inference-scratch-space/customize.py index aeb40f6c0..6724c845e 100644 --- a/script/clean-nvidia-mlperf-inference-scratch-space/customize.py +++ b/script/clean-nvidia-mlperf-inference-scratch-space/customize.py @@ -30,7 +30,7 @@ def preprocess(i): cache_rm_tags = "nvidia-harness,_download_model,_sdxl" cache_rm_tags = cache_rm_tags + extra_cache_rm_tags - mlc = i['automation'].action_target + mlc = i['automation'].action_object if cache_rm_tags: r = mlc.access({'action': 'rm', 'automation': 'cache', From 7865f552ca7e14d938b805c326c3c5f613fa87af Mon Sep 17 00:00:00 2001 From: Arjun Suresh Date: Thu, 30 Jan 2025 19:44:08 +0000 Subject: [PATCH 2/4] Update test-nvidia-mlperf-inference-implementations.yml --- .../workflows/test-nvidia-mlperf-inference-implementations.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-nvidia-mlperf-inference-implementations.yml b/.github/workflows/test-nvidia-mlperf-inference-implementations.yml index 4a6b91c41..e4d780780 100644 --- a/.github/workflows/test-nvidia-mlperf-inference-implementations.yml +++ b/.github/workflows/test-nvidia-mlperf-inference-implementations.yml @@ -17,7 +17,7 @@ jobs: strategy: fail-fast: false matrix: - system: [ "GO-spr", "phoenix", "GO-i9"] + system: [ "GO-spr", "phoenix"] # system: [ "mlc-server" ] python-version: [ "3.12" ] model: [ "resnet50", "retinanet", "bert-99", "bert-99.9", "gptj-99.9", "3d-unet-99.9", "sdxl" ] From cc3ef7383df38c23381405cc3708ecbef2f571ed Mon Sep 17 00:00:00 2001 From: Arjun Suresh Date: Fri, 31 Jan 2025 01:59:26 +0530 Subject: [PATCH 3/4] CacheAction object added inside ScriptAction, fix duplicate cache entries being created for git repos --- automation/script/module.py | 73 ++++++++++--------- .../customize.py | 4 +- 2 files changed, 41 insertions(+), 36 deletions(-) diff --git a/automation/script/module.py b/automation/script/module.py index cbb3bcb58..166741234 100644 --- a/automation/script/module.py +++ b/automation/script/module.py @@ -12,6 +12,7 @@ import logging from mlc.main import Automation +from mlc.main import CacheAction import mlc.utils as utils from utils import * @@ -39,6 +40,7 @@ def __init__(self, action_object, automation_file): self.logger = self.action_object.logger self.logger.propagate = False + self.cache_action = CacheAction(self.action_object.parent) #Create CacheAction using the same parent as the Script self.tmp_file_env = 'tmp-env' self.tmp_file_env_all = 'tmp-env-all' self.tmp_file_run = 'tmp-run' @@ -351,7 +353,6 @@ def _run(self, i): skip_cache = i.get('skip_cache', False) force_cache = i.get('force_cache', False) - fake_run = i.get('fake_run', False) fake_run = i.get( 'fake_run', False) if 'fake_run' in i else i.get( @@ -670,7 +671,7 @@ def _run(self, i): search_cache = {'action': 'search', 'target_name': 'cache', 'tags': cache_tags_without_tmp_string} - rc = self.action_object.access(search_cache) + rc = self.cache_action.access(search_cache) if rc['return'] > 0: return rc @@ -1383,19 +1384,18 @@ def _run(self, i): ' - Creating new "cache" script artifact in the MLC local repository ...') logger.debug(recursion_spaces + ' - Tags: {}'.format(','.join(tmp_tags))) - if version != '': cached_meta['version'] = version ii = {'action': 'update', - 'automation': self.meta['deps']['cache'], + 'target': 'cache', 'search_tags': tmp_tags, 'script_alias': meta['alias'], 'tags': ','.join(tmp_tags), 'meta': cached_meta, 'force': True} - r = self.action_object.access(ii) + r = self.cache_action.access(ii) if r['return'] > 0: return r @@ -1495,8 +1495,9 @@ def _run(self, i): if r['return'] > 0: return r - if 'version-' + version not in cached_tags: - cached_tags.append('version-' + version) + r = get_version_tag_from_version(version, cached_tags) + if r['return'] > 0: + return r if default_version in versions: versions_meta = versions[default_version] @@ -1828,10 +1829,13 @@ def _run(self, i): # If return version if cache: - if r.get('version', '') != '': + version = r.get('version', '') + if version != '': cached_tags = [ x for x in cached_tags if not x.startswith('version-')] - cached_tags.append('version-' + r['version']) + r = get_version_tag_from_version(version, cached_tags) + if r['return'] > 0: + return r if len(r.get('add_extra_cache_tags', [])) > 0: for t in r['add_extra_cache_tags']: @@ -1873,9 +1877,13 @@ def _run(self, i): if r.get('version', '') != '': version = r.get('version') if cache: - cached_tags = [ - x for x in cached_tags if not x.startswith('version-')] - cached_tags.append('version-' + r['version']) + version = r.get('version', '') + if version != '': + cached_tags = [ + x for x in cached_tags if not x.startswith('version-')] + r = get_version_tag_from_version(version, cached_tags) + if r['return'] > 0: + return r if len(r.get('add_extra_cache_tags', [])) > 0 and cache: for t in r['add_extra_cache_tags']: @@ -2034,14 +2042,14 @@ def _run(self, i): cached_meta['dependent_cached_path'] = dependent_cached_path ii = {'action': 'update', - 'automation': self.meta['deps']['cache'], + 'target': 'cache', 'uid': cached_uid, 'meta': cached_meta, 'script_alias': meta['alias'], 'replace_lists': True, # To replace tags 'tags': ','.join(cached_tags)} - r = self.action_object.access(ii) + r = self.cache_action.access(ii) if r['return'] > 0: return r @@ -4756,6 +4764,16 @@ def clean_some_tmp_files(self, i): return {'return': 0} +def get_version_tag_from_version(version, cached_tags): + tags_to_add = [] + if version != '': + if 'version-' + version not in cached_tags: + cached_tags.append('version-' + version) + if '-git-' in version: + version_without_git_commit = version.split("-git-")[0] + if 'version-' + version_without_git_commit not in cached_tags: + cached_tags.append('version-' + version_without_git_commit) + return {'return': 0} ############################################################################## def find_cached_script(i): @@ -4867,11 +4885,12 @@ def find_cached_script(i): recursion_spaces + ' - Prepared variations: {}'.format(variation_tags_string)) - # Add version - if version != '': - if 'version-' + version not in cached_tags: - cached_tags.append('version-' + version) - explicit_cached_tags.append('version-' + version) + r = get_version_tag_from_version(version, cached_tags) + if r['return'] > 0: + return r + get_version_tag_from_version(version, explicit_cached_tags) + if r['return'] > 0: + return r # Add extra cache tags (such as "virtual" for python) if len(extra_cache_tags) > 0: @@ -4905,7 +4924,7 @@ def find_cached_script(i): recursion_spaces + ' - Searching for cached script outputs with the following tags: {}'.format(search_tags)) - r = self_obj.action_object.access({'action': 'search', + r = self_obj.cache_action.access({'action': 'search', 'target_name': 'cache', 'tags': search_tags}) if r['return'] > 0: @@ -4986,20 +5005,6 @@ def find_cached_script(i): if r['return'] > 0: return r - # Check if pre-process and detect - # if 'preprocess' in dir(customize_code): - - # logger.debug(recursion_spaces + ' - Running preprocess ...') - - # ii = copy.deepcopy(customize_common_input) - # ii['env'] = env - # ii['meta'] = meta - # # may need to detect versions in multiple paths - # ii['run_script_input'] = run_script_input - - # r = customize_code.preprocess(ii) - # if r['return'] > 0: - # return r ii = { 'run_script_input': run_script_input, diff --git a/script/clean-nvidia-mlperf-inference-scratch-space/customize.py b/script/clean-nvidia-mlperf-inference-scratch-space/customize.py index 6724c845e..488cea67f 100644 --- a/script/clean-nvidia-mlperf-inference-scratch-space/customize.py +++ b/script/clean-nvidia-mlperf-inference-scratch-space/customize.py @@ -30,10 +30,10 @@ def preprocess(i): cache_rm_tags = "nvidia-harness,_download_model,_sdxl" cache_rm_tags = cache_rm_tags + extra_cache_rm_tags - mlc = i['automation'].action_object + mlc_cache = i['automation'].cache_action if cache_rm_tags: - r = mlc.access({'action': 'rm', 'automation': 'cache', + r = mlc_cache.access({'action': 'rm', 'target': 'cache', 'tags': cache_rm_tags, 'f': True}) print(r) if r['return'] != 0 and r['return'] != 16: # ignore missing ones From 7d9520ebb86b085037e86f2ff2a8ad32695ab8d8 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 30 Jan 2025 20:31:01 +0000 Subject: [PATCH 4/4] [Automated Commit] Format Codebase --- automation/script/module.py | 14 +++++++++----- .../customize.py | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/automation/script/module.py b/automation/script/module.py index 166741234..8e7556eb4 100644 --- a/automation/script/module.py +++ b/automation/script/module.py @@ -40,7 +40,8 @@ def __init__(self, action_object, automation_file): self.logger = self.action_object.logger self.logger.propagate = False - self.cache_action = CacheAction(self.action_object.parent) #Create CacheAction using the same parent as the Script + # Create CacheAction using the same parent as the Script + self.cache_action = CacheAction(self.action_object.parent) self.tmp_file_env = 'tmp-env' self.tmp_file_env_all = 'tmp-env-all' self.tmp_file_run = 'tmp-run' @@ -1881,7 +1882,8 @@ def _run(self, i): if version != '': cached_tags = [ x for x in cached_tags if not x.startswith('version-')] - r = get_version_tag_from_version(version, cached_tags) + r = get_version_tag_from_version( + version, cached_tags) if r['return'] > 0: return r @@ -4764,6 +4766,7 @@ def clean_some_tmp_files(self, i): return {'return': 0} + def get_version_tag_from_version(version, cached_tags): tags_to_add = [] if version != '': @@ -4776,6 +4779,8 @@ def get_version_tag_from_version(version, cached_tags): return {'return': 0} ############################################################################## + + def find_cached_script(i): """ Internal automation function: find cached script @@ -4925,8 +4930,8 @@ def find_cached_script(i): ' - Searching for cached script outputs with the following tags: {}'.format(search_tags)) r = self_obj.cache_action.access({'action': 'search', - 'target_name': 'cache', - 'tags': search_tags}) + 'target_name': 'cache', + 'tags': search_tags}) if r['return'] > 0: return r @@ -5005,7 +5010,6 @@ def find_cached_script(i): if r['return'] > 0: return r - ii = { 'run_script_input': run_script_input, 'env': env, diff --git a/script/clean-nvidia-mlperf-inference-scratch-space/customize.py b/script/clean-nvidia-mlperf-inference-scratch-space/customize.py index 488cea67f..d719c02a6 100644 --- a/script/clean-nvidia-mlperf-inference-scratch-space/customize.py +++ b/script/clean-nvidia-mlperf-inference-scratch-space/customize.py @@ -34,7 +34,7 @@ def preprocess(i): if cache_rm_tags: r = mlc_cache.access({'action': 'rm', 'target': 'cache', - 'tags': cache_rm_tags, 'f': True}) + 'tags': cache_rm_tags, 'f': True}) print(r) if r['return'] != 0 and r['return'] != 16: # ignore missing ones return r