diff --git a/script/app-abinit/customize.py b/script/app-abinit/customize.py index 80e2a8254..d496ae588 100644 --- a/script/app-abinit/customize.py +++ b/script/app-abinit/customize.py @@ -14,7 +14,8 @@ def postprocess(i): install_dir = os.path.join(src_path, 'install') env['MLC_ABINIT_INSTALL_PATH'] = install_dir bin_dir = os.path.join(install_dir, 'bin') - env['MLC_ABINIT_BIN_PATH'] = bin_dir if os.path.isdir(bin_dir) else src_path + env['MLC_ABINIT_BIN_PATH'] = bin_dir if os.path.isdir( + bin_dir) else src_path if os.path.isdir(bin_dir): env['+PATH'] = [bin_dir] return {'return': 0} diff --git a/script/app-alphafold/customize.py b/script/app-alphafold/customize.py index ce06f6bf2..9ea46dbeb 100644 --- a/script/app-alphafold/customize.py +++ b/script/app-alphafold/customize.py @@ -14,7 +14,8 @@ def postprocess(i): install_dir = os.path.join(src_path, 'install') env['MLC_ALPHAFOLD_INSTALL_PATH'] = install_dir bin_dir = os.path.join(install_dir, 'bin') - env['MLC_ALPHAFOLD_BIN_PATH'] = bin_dir if os.path.isdir(bin_dir) else src_path + env['MLC_ALPHAFOLD_BIN_PATH'] = bin_dir if os.path.isdir( + bin_dir) else src_path if os.path.isdir(bin_dir): env['+PATH'] = [bin_dir] return {'return': 0} diff --git a/script/app-ansys-fluent/customize.py b/script/app-ansys-fluent/customize.py index df6a59212..0cb9a7cdc 100644 --- a/script/app-ansys-fluent/customize.py +++ b/script/app-ansys-fluent/customize.py @@ -4,7 +4,8 @@ def preprocess(i): if i['os_info']['platform'] == 'windows': - return {'return': 1, 'error': 'Windows is not supported for Ansys Fluent builds'} + return {'return': 1, + 'error': 'Windows is not supported for Ansys Fluent builds'} return {'return': 0} @@ -14,7 +15,8 @@ def postprocess(i): install_dir = os.path.join(src_path, 'install') env['MLC_ANSYS_FLUENT_INSTALL_PATH'] = install_dir bin_dir = os.path.join(install_dir, 'bin') - env['MLC_ANSYS_FLUENT_BIN_PATH'] = bin_dir if os.path.isdir(bin_dir) else src_path + env['MLC_ANSYS_FLUENT_BIN_PATH'] = bin_dir if os.path.isdir( + bin_dir) else src_path if os.path.isdir(bin_dir): env['+PATH'] = [bin_dir] return {'return': 0} diff --git a/script/app-berkeleygw/customize.py b/script/app-berkeleygw/customize.py index 0b6024be8..7fbacc887 100644 --- a/script/app-berkeleygw/customize.py +++ b/script/app-berkeleygw/customize.py @@ -4,7 +4,8 @@ def preprocess(i): if i['os_info']['platform'] == 'windows': - return {'return': 1, 'error': 'Windows is not supported for BerkeleyGW builds'} + return {'return': 1, + 'error': 'Windows is not supported for BerkeleyGW builds'} return {'return': 0} @@ -14,7 +15,8 @@ def postprocess(i): install_dir = os.path.join(src_path, 'install') env['MLC_BERKELEYGW_INSTALL_PATH'] = install_dir bin_dir = os.path.join(install_dir, 'bin') - env['MLC_BERKELEYGW_BIN_PATH'] = bin_dir if os.path.isdir(bin_dir) else src_path + env['MLC_BERKELEYGW_BIN_PATH'] = bin_dir if os.path.isdir( + bin_dir) else src_path if os.path.isdir(bin_dir): env['+PATH'] = [bin_dir] return {'return': 0} diff --git a/script/app-blast/customize.py b/script/app-blast/customize.py index 5091febae..dc022ef2a 100644 --- a/script/app-blast/customize.py +++ b/script/app-blast/customize.py @@ -21,7 +21,8 @@ def postprocess(i): binary = os.path.join(bin_dir, 'blastn') if not os.path.isfile(binary): - return {'return': 1, 'error': f'BLAST+ binary (blastn) not found in {bin_dir}'} + return {'return': 1, + 'error': f'BLAST+ binary (blastn) not found in {bin_dir}'} env['MLC_BLAST_INSTALL_PATH'] = install_dir env['MLC_BLAST_BIN_PATH'] = bin_dir diff --git a/script/app-calculix/customize.py b/script/app-calculix/customize.py index 23ee31ba9..36058e566 100644 --- a/script/app-calculix/customize.py +++ b/script/app-calculix/customize.py @@ -14,7 +14,8 @@ def postprocess(i): install_dir = os.path.join(src_path, 'install') env['MLC_CALCULIX_INSTALL_PATH'] = install_dir bin_dir = os.path.join(install_dir, 'bin') - env['MLC_CALCULIX_BIN_PATH'] = bin_dir if os.path.isdir(bin_dir) else src_path + env['MLC_CALCULIX_BIN_PATH'] = bin_dir if os.path.isdir( + bin_dir) else src_path if os.path.isdir(bin_dir): env['+PATH'] = [bin_dir] return {'return': 0} diff --git a/script/app-castep/customize.py b/script/app-castep/customize.py index 8e9f248f1..35191b8db 100644 --- a/script/app-castep/customize.py +++ b/script/app-castep/customize.py @@ -14,7 +14,8 @@ def postprocess(i): install_dir = os.path.join(src_path, 'install') env['MLC_CASTEP_INSTALL_PATH'] = install_dir bin_dir = os.path.join(install_dir, 'bin') - env['MLC_CASTEP_BIN_PATH'] = bin_dir if os.path.isdir(bin_dir) else src_path + env['MLC_CASTEP_BIN_PATH'] = bin_dir if os.path.isdir( + bin_dir) else src_path if os.path.isdir(bin_dir): env['+PATH'] = [bin_dir] return {'return': 0} diff --git a/script/app-castro/customize.py b/script/app-castro/customize.py index d40dfef26..b90fdf524 100644 --- a/script/app-castro/customize.py +++ b/script/app-castro/customize.py @@ -13,7 +13,13 @@ def postprocess(i): env = i['env'] src_path = env.get('MLC_CASTRO_SRC_PATH', '') compiler_tag = env.get('MLC_COMPILER_FAMILY', '') or 'default' - hits = glob.glob(os.path.join(src_path, 'install-' + compiler_tag, 'bin', '*.ex')) + hits = glob.glob( + os.path.join( + src_path, + 'install-' + + compiler_tag, + 'bin', + '*.ex')) if not hits: return {'return': 1, 'error': f'Castro executable not found under {src_path}'} bin_dir = os.path.dirname(hits[0]) diff --git a/script/app-chroma/customize.py b/script/app-chroma/customize.py index 6032dfb36..d87479976 100644 --- a/script/app-chroma/customize.py +++ b/script/app-chroma/customize.py @@ -14,7 +14,8 @@ def postprocess(i): install_dir = os.path.join(src_path, 'install') env['MLC_CHROMA_INSTALL_PATH'] = install_dir bin_dir = os.path.join(install_dir, 'bin') - env['MLC_CHROMA_BIN_PATH'] = bin_dir if os.path.isdir(bin_dir) else src_path + env['MLC_CHROMA_BIN_PATH'] = bin_dir if os.path.isdir( + bin_dir) else src_path if os.path.isdir(bin_dir): env['+PATH'] = [bin_dir] return {'return': 0} diff --git a/script/app-cloverleaf/customize.py b/script/app-cloverleaf/customize.py index 72ec5b72d..097457909 100644 --- a/script/app-cloverleaf/customize.py +++ b/script/app-cloverleaf/customize.py @@ -6,7 +6,8 @@ def preprocess(i): os_info = i['os_info'] if os_info['platform'] == 'windows': - return {'return': 1, 'error': 'Windows is not supported for CloverLeaf builds'} + return {'return': 1, + 'error': 'Windows is not supported for CloverLeaf builds'} return {'return': 0} @@ -25,7 +26,8 @@ def postprocess(i): # Try source directory clover_bin = os.path.join(src_path, 'clover_leaf') if not os.path.isfile(clover_bin): - return {'return': 1, 'error': f'CloverLeaf binary not found in {bin_dir} or {src_path}'} + return { + 'return': 1, 'error': f'CloverLeaf binary not found in {bin_dir} or {src_path}'} bin_dir = src_path env['MLC_CLOVERLEAF_BIN_PATH'] = bin_dir diff --git a/script/app-code-aster/customize.py b/script/app-code-aster/customize.py index 5c35af3a1..05d4bc745 100644 --- a/script/app-code-aster/customize.py +++ b/script/app-code-aster/customize.py @@ -5,7 +5,8 @@ def preprocess(i): if i['os_info']['platform'] == 'windows': - return {'return': 1, 'error': 'Windows is not supported for Code_Aster builds'} + return {'return': 1, + 'error': 'Windows is not supported for Code_Aster builds'} return {'return': 0} diff --git a/script/app-code-saturne/customize.py b/script/app-code-saturne/customize.py index 500f028fd..fcde15b04 100644 --- a/script/app-code-saturne/customize.py +++ b/script/app-code-saturne/customize.py @@ -4,7 +4,8 @@ def preprocess(i): if i['os_info']['platform'] == 'windows': - return {'return': 1, 'error': 'Windows is not supported for code_saturne builds'} + return {'return': 1, + 'error': 'Windows is not supported for code_saturne builds'} return {'return': 0} diff --git a/script/app-dalton/customize.py b/script/app-dalton/customize.py index ae4187991..d5db9448d 100644 --- a/script/app-dalton/customize.py +++ b/script/app-dalton/customize.py @@ -16,7 +16,8 @@ def postprocess(i): if not os.path.isfile(binary): return {'return': 1, 'error': f'DALTON binary not found at {binary}'} bin_dir = os.path.dirname(binary) - env['MLC_DALTON_INSTALL_PATH'] = os.path.join(src_path, 'build-' + compiler_tag) + env['MLC_DALTON_INSTALL_PATH'] = os.path.join( + src_path, 'build-' + compiler_tag) env['MLC_DALTON_BIN_PATH'] = bin_dir env['+PATH'] = [bin_dir] return {'return': 0} diff --git a/script/app-enzo/customize.py b/script/app-enzo/customize.py index 4de53732c..315897a3a 100644 --- a/script/app-enzo/customize.py +++ b/script/app-enzo/customize.py @@ -21,7 +21,8 @@ def postprocess(i): binary = os.path.join(bin_dir, 'enzo.exe') if not os.path.isfile(binary): - return {'return': 1, 'error': f'Enzo binary (enzo.exe) not found in {bin_dir}'} + return {'return': 1, + 'error': f'Enzo binary (enzo.exe) not found in {bin_dir}'} env['MLC_ENZO_INSTALL_PATH'] = src_path env['MLC_ENZO_BIN_PATH'] = bin_dir diff --git a/script/app-epoch/customize.py b/script/app-epoch/customize.py index 07b841a0a..5c4e9e74f 100644 --- a/script/app-epoch/customize.py +++ b/script/app-epoch/customize.py @@ -13,7 +13,14 @@ def postprocess(i): env = i['env'] src_path = env.get('MLC_EPOCH_SRC_PATH', '') compiler_tag = env.get('MLC_COMPILER_FAMILY', '') or 'default' - hits = glob.glob(os.path.join(src_path, 'install-' + compiler_tag, 'bin', 'epoch2d'), recursive=True) + hits = glob.glob( + os.path.join( + src_path, + 'install-' + + compiler_tag, + 'bin', + 'epoch2d'), + recursive=True) if not hits: return {'return': 1, 'error': f'EPOCH artifact not found under {src_path}'} bin_dir = os.path.dirname(hits[0]) diff --git a/script/app-gadget4/customize.py b/script/app-gadget4/customize.py index 24594839a..0b8dc2e0a 100644 --- a/script/app-gadget4/customize.py +++ b/script/app-gadget4/customize.py @@ -19,7 +19,8 @@ def postprocess(i): binary = os.path.join(src_path, 'Gadget4') if not os.path.isfile(binary): - return {'return': 1, 'error': f'GADGET-4 binary (Gadget4) not found in {src_path}'} + return {'return': 1, + 'error': f'GADGET-4 binary (Gadget4) not found in {src_path}'} env['MLC_GADGET4_INSTALL_PATH'] = src_path env['MLC_GADGET4_BIN_PATH'] = src_path diff --git a/script/app-gaia-benchmark/customize.py b/script/app-gaia-benchmark/customize.py index 1e87d46f0..6cb12c1f9 100644 --- a/script/app-gaia-benchmark/customize.py +++ b/script/app-gaia-benchmark/customize.py @@ -6,13 +6,17 @@ def preprocess(i): env = i['env'] backend = str(env.get('MLC_GAIA_BACKEND', 'mock')).lower() - if backend == 'endpoint' and not env.get('MLC_GAIA_ENDPOINT_URL', '').strip(): + if backend == 'endpoint' and not env.get( + 'MLC_GAIA_ENDPOINT_URL', '').strip(): return {'return': 1, 'error': 'endpoint backend requires --endpoint (MLC_GAIA_ENDPOINT_URL)'} # The workload is executed by the benchmark-program posthook dependency. python_bin = env.get('MLC_PYTHON_BIN_WITH_PATH', 'python3') - script = os.path.join(env['MLC_TMP_CURRENT_SCRIPT_PATH'], 'src', 'run_gaia.py') + script = os.path.join( + env['MLC_TMP_CURRENT_SCRIPT_PATH'], + 'src', + 'run_gaia.py') env['MLC_RUN_CMD'] = f'{python_bin} "{script}"' if not env.get('MLC_RUN_DIR', ''): env['MLC_RUN_DIR'] = os.getcwd() @@ -39,5 +43,6 @@ def postprocess(i): env['MLC_GAIA_ACCURACY'] = str(data.get('accuracy', '')) state['mlc_gaia'] = data - logger.info(f"GAIA accuracy ({data.get('trace_type')}): {data.get('accuracy')}") + logger.info( + f"GAIA accuracy ({data.get('trace_type')}): {data.get('accuracy')}") return {'return': 0} diff --git a/script/app-gaia-benchmark/src/run_gaia.py b/script/app-gaia-benchmark/src/run_gaia.py index 676b95a2f..c579568cf 100644 --- a/script/app-gaia-benchmark/src/run_gaia.py +++ b/script/app-gaia-benchmark/src/run_gaia.py @@ -89,7 +89,9 @@ def gen(system, user, max_tokens=512): if backend == "hf": import torch from transformers import AutoModelForCausalLM, AutoTokenizer - model_id = _env("MLC_GAIA_HF_MODEL", "HuggingFaceTB/SmolLM2-135M-Instruct") + model_id = _env( + "MLC_GAIA_HF_MODEL", + "HuggingFaceTB/SmolLM2-135M-Instruct") tok = AutoTokenizer.from_pretrained(model_id) model = AutoModelForCausalLM.from_pretrained(model_id) model.eval() diff --git a/script/app-gamess/customize.py b/script/app-gamess/customize.py index d5ebd96cc..2bf60fb27 100644 --- a/script/app-gamess/customize.py +++ b/script/app-gamess/customize.py @@ -4,7 +4,8 @@ def preprocess(i): if i['os_info']['platform'] == 'windows': - return {'return': 1, 'error': 'Windows is not supported for GAMESS (US) builds'} + return {'return': 1, + 'error': 'Windows is not supported for GAMESS (US) builds'} return {'return': 0} @@ -14,7 +15,8 @@ def postprocess(i): install_dir = os.path.join(src_path, 'install') env['MLC_GAMESS_INSTALL_PATH'] = install_dir bin_dir = os.path.join(install_dir, 'bin') - env['MLC_GAMESS_BIN_PATH'] = bin_dir if os.path.isdir(bin_dir) else src_path + env['MLC_GAMESS_BIN_PATH'] = bin_dir if os.path.isdir( + bin_dir) else src_path if os.path.isdir(bin_dir): env['+PATH'] = [bin_dir] return {'return': 0} diff --git a/script/app-gaussian/customize.py b/script/app-gaussian/customize.py index ad041f4f1..c5340377f 100644 --- a/script/app-gaussian/customize.py +++ b/script/app-gaussian/customize.py @@ -14,7 +14,8 @@ def postprocess(i): install_dir = os.path.join(src_path, 'install') env['MLC_GAUSSIAN_INSTALL_PATH'] = install_dir bin_dir = os.path.join(install_dir, 'bin') - env['MLC_GAUSSIAN_BIN_PATH'] = bin_dir if os.path.isdir(bin_dir) else src_path + env['MLC_GAUSSIAN_BIN_PATH'] = bin_dir if os.path.isdir( + bin_dir) else src_path if os.path.isdir(bin_dir): env['+PATH'] = [bin_dir] return {'return': 0} diff --git a/script/app-geant4/customize.py b/script/app-geant4/customize.py index f94334c6b..b2b61719c 100644 --- a/script/app-geant4/customize.py +++ b/script/app-geant4/customize.py @@ -12,7 +12,13 @@ def preprocess(i): def postprocess(i): env = i['env'] src_path = env.get('MLC_GEANT4_SRC_PATH', '') - hits = glob.glob(os.path.join(src_path, 'build', 'BuildProducts', 'lib', 'libG4global*')) + hits = glob.glob( + os.path.join( + src_path, + 'build', + 'BuildProducts', + 'lib', + 'libG4global*')) if not hits: return {'return': 1, 'error': f'Geant4 library not found under {src_path}'} bin_dir = os.path.dirname(hits[0]) diff --git a/script/app-genesis/customize.py b/script/app-genesis/customize.py index 439aa9dfe..39605f985 100644 --- a/script/app-genesis/customize.py +++ b/script/app-genesis/customize.py @@ -16,7 +16,8 @@ def postprocess(i): if not os.path.isfile(binary): return {'return': 1, 'error': f'GENESIS binary not found at {binary}'} bin_dir = os.path.dirname(binary) - env['MLC_GENESIS_INSTALL_PATH'] = os.path.join(src_path, 'install-' + compiler_tag) + env['MLC_GENESIS_INSTALL_PATH'] = os.path.join( + src_path, 'install-' + compiler_tag) env['MLC_GENESIS_BIN_PATH'] = bin_dir env['+PATH'] = [bin_dir] return {'return': 0} diff --git a/script/app-gromacs/customize.py b/script/app-gromacs/customize.py index af26192cf..19ac915f2 100644 --- a/script/app-gromacs/customize.py +++ b/script/app-gromacs/customize.py @@ -22,7 +22,8 @@ def postprocess(i): gmx_bin = os.path.join(bin_dir, 'gmx_mpi') if not os.path.isfile(gmx_bin): - return {'return': 1, 'error': f'GROMACS binary (gmx_mpi) not found in {bin_dir}'} + return {'return': 1, + 'error': f'GROMACS binary (gmx_mpi) not found in {bin_dir}'} env['MLC_GROMACS_BIN_PATH'] = bin_dir env['MLC_GROMACS_INSTALL_PATH'] = install_dir diff --git a/script/app-hmmer/customize.py b/script/app-hmmer/customize.py index c00fb8cf4..4c7a10aed 100644 --- a/script/app-hmmer/customize.py +++ b/script/app-hmmer/customize.py @@ -22,7 +22,8 @@ def postprocess(i): hmmsearch_bin = os.path.join(bin_dir, 'hmmsearch') if not os.path.isfile(hmmsearch_bin): - return {'return': 1, 'error': f'HMMER binary (hmmsearch) not found in {bin_dir}'} + return {'return': 1, + 'error': f'HMMER binary (hmmsearch) not found in {bin_dir}'} env['MLC_HMMER_BIN_PATH'] = bin_dir env['MLC_HMMER_INSTALL_PATH'] = install_dir diff --git a/script/app-hoomd-blue/customize.py b/script/app-hoomd-blue/customize.py index 5d1225a2f..7674082b9 100644 --- a/script/app-hoomd-blue/customize.py +++ b/script/app-hoomd-blue/customize.py @@ -4,7 +4,8 @@ def preprocess(i): if i['os_info']['platform'] == 'windows': - return {'return': 1, 'error': 'Windows is not supported for HOOMD-blue builds'} + return {'return': 1, + 'error': 'Windows is not supported for HOOMD-blue builds'} return {'return': 0} diff --git a/script/app-hotpotqa/customize.py b/script/app-hotpotqa/customize.py index 73fb059cb..c999c6332 100644 --- a/script/app-hotpotqa/customize.py +++ b/script/app-hotpotqa/customize.py @@ -6,13 +6,17 @@ def preprocess(i): env = i['env'] backend = str(env.get('MLC_HOTPOTQA_BACKEND', 'mock')).lower() - if backend == 'endpoint' and not env.get('MLC_HOTPOTQA_ENDPOINT_URL', '').strip(): + if backend == 'endpoint' and not env.get( + 'MLC_HOTPOTQA_ENDPOINT_URL', '').strip(): return {'return': 1, 'error': 'endpoint backend requires --endpoint (MLC_HOTPOTQA_ENDPOINT_URL)'} # The workload is executed by the benchmark-program posthook dependency. python_bin = env.get('MLC_PYTHON_BIN_WITH_PATH', 'python3') - script = os.path.join(env['MLC_TMP_CURRENT_SCRIPT_PATH'], 'src', 'run_hotpotqa.py') + script = os.path.join( + env['MLC_TMP_CURRENT_SCRIPT_PATH'], + 'src', + 'run_hotpotqa.py') env['MLC_RUN_CMD'] = f'{python_bin} "{script}"' if not env.get('MLC_RUN_DIR', ''): env['MLC_RUN_DIR'] = os.getcwd() @@ -40,5 +44,6 @@ def postprocess(i): env['MLC_HOTPOTQA_F1'] = str(data.get('f1', '')) state['mlc_hotpotqa'] = data - logger.info(f"HotpotQA EM: {data.get('exact_match')}, F1: {data.get('f1')}") + logger.info( + f"HotpotQA EM: {data.get('exact_match')}, F1: {data.get('f1')}") return {'return': 0} diff --git a/script/app-kratos/customize.py b/script/app-kratos/customize.py index 22b778e20..5fd25502b 100644 --- a/script/app-kratos/customize.py +++ b/script/app-kratos/customize.py @@ -12,9 +12,16 @@ def preprocess(i): def postprocess(i): env = i['env'] src_path = env.get('MLC_KRATOS_SRC_PATH', '') - hits = glob.glob(os.path.join(src_path, 'build', '**', 'libKratosCore*'), recursive=True) + hits = glob.glob( + os.path.join( + src_path, + 'build', + '**', + 'libKratosCore*'), + recursive=True) if not hits: - return {'return': 1, 'error': f'Kratos core library not found under {src_path}'} + return {'return': 1, + 'error': f'Kratos core library not found under {src_path}'} bin_dir = os.path.dirname(hits[0]) env['MLC_KRATOS_INSTALL_PATH'] = os.path.join(src_path, 'build') env['MLC_KRATOS_BIN_PATH'] = bin_dir diff --git a/script/app-lammps/customize.py b/script/app-lammps/customize.py index 25dcdbaf9..e118b438a 100644 --- a/script/app-lammps/customize.py +++ b/script/app-lammps/customize.py @@ -22,7 +22,8 @@ def postprocess(i): lmp_bin = os.path.join(bin_dir, 'lmp') if not os.path.isfile(lmp_bin): - return {'return': 1, 'error': f'LAMMPS binary (lmp) not found in {bin_dir}'} + return {'return': 1, + 'error': f'LAMMPS binary (lmp) not found in {bin_dir}'} env['MLC_LAMMPS_BIN_PATH'] = bin_dir env['MLC_LAMMPS_INSTALL_PATH'] = install_dir diff --git a/script/app-ls-dyna/customize.py b/script/app-ls-dyna/customize.py index 7fd946beb..4bb0cfab0 100644 --- a/script/app-ls-dyna/customize.py +++ b/script/app-ls-dyna/customize.py @@ -14,7 +14,8 @@ def postprocess(i): install_dir = os.path.join(src_path, 'install') env['MLC_LS_DYNA_INSTALL_PATH'] = install_dir bin_dir = os.path.join(install_dir, 'bin') - env['MLC_LS_DYNA_BIN_PATH'] = bin_dir if os.path.isdir(bin_dir) else src_path + env['MLC_LS_DYNA_BIN_PATH'] = bin_dir if os.path.isdir( + bin_dir) else src_path if os.path.isdir(bin_dir): env['+PATH'] = [bin_dir] return {'return': 0} diff --git a/script/app-madgraph/customize.py b/script/app-madgraph/customize.py index 63b2a0595..4762064f5 100644 --- a/script/app-madgraph/customize.py +++ b/script/app-madgraph/customize.py @@ -5,7 +5,8 @@ def preprocess(i): if i['os_info']['platform'] == 'windows': - return {'return': 1, 'error': 'Windows is not supported for MadGraph5_aMC@NLO builds'} + return { + 'return': 1, 'error': 'Windows is not supported for MadGraph5_aMC@NLO builds'} return {'return': 0} diff --git a/script/app-milc/customize.py b/script/app-milc/customize.py index 9bb9ab0f8..da4f5cbad 100644 --- a/script/app-milc/customize.py +++ b/script/app-milc/customize.py @@ -21,7 +21,8 @@ def postprocess(i): binary = os.path.join(bin_dir, 'su3_rmd') if not os.path.isfile(binary): - return {'return': 1, 'error': f'MILC binary (su3_rmd) not found in {bin_dir}'} + return {'return': 1, + 'error': f'MILC binary (su3_rmd) not found in {bin_dir}'} env['MLC_MILC_INSTALL_PATH'] = src_path env['MLC_MILC_BIN_PATH'] = bin_dir diff --git a/script/app-mitgcm/customize.py b/script/app-mitgcm/customize.py index 4c8ecedea..d0518df34 100644 --- a/script/app-mitgcm/customize.py +++ b/script/app-mitgcm/customize.py @@ -12,7 +12,11 @@ def postprocess(i): env = i['env'] src_path = env.get('MLC_MITGCM_SRC_PATH', '') compiler_tag = env.get('MLC_COMPILER_FAMILY', '') or 'default' - binary = os.path.join(src_path, 'verification/tutorial_barotropic_gyre', 'build-' + compiler_tag, 'mitgcmuv') + binary = os.path.join( + src_path, + 'verification/tutorial_barotropic_gyre', + 'build-' + compiler_tag, + 'mitgcmuv') if not os.path.isfile(binary): return {'return': 1, 'error': f'MITgcm binary not found at {binary}'} bin_dir = os.path.dirname(binary) diff --git a/script/app-namd/customize.py b/script/app-namd/customize.py index a0f3982af..222b7daee 100644 --- a/script/app-namd/customize.py +++ b/script/app-namd/customize.py @@ -40,7 +40,8 @@ def postprocess(i): break if namd_bin is None: - return {'return': 1, 'error': f'NAMD binary not found in {bin_dir} or build directory'} + return { + 'return': 1, 'error': f'NAMD binary not found in {bin_dir} or build directory'} env['MLC_NAMD_BIN_PATH'] = bin_dir env['MLC_NAMD_INSTALL_PATH'] = install_dir diff --git a/script/app-nek5000/customize.py b/script/app-nek5000/customize.py index b3e0ef53b..cf246697c 100644 --- a/script/app-nek5000/customize.py +++ b/script/app-nek5000/customize.py @@ -20,7 +20,8 @@ def postprocess(i): binary = os.path.join(bin_dir, 'genmap') if not os.path.isfile(binary): - return {'return': 1, 'error': f'Nek5000 tool (genmap) not found in {bin_dir}'} + return {'return': 1, + 'error': f'Nek5000 tool (genmap) not found in {bin_dir}'} env['MLC_NEK5000_INSTALL_PATH'] = src_path env['MLC_NEK5000_BIN_PATH'] = bin_dir diff --git a/script/app-nektar/customize.py b/script/app-nektar/customize.py index f5c2c691e..0ca54ca4a 100644 --- a/script/app-nektar/customize.py +++ b/script/app-nektar/customize.py @@ -12,7 +12,10 @@ def preprocess(i): def postprocess(i): env = i['env'] src_path = env.get('MLC_NEKTAR_SRC_PATH', '') - libs = glob.glob(os.path.join(src_path, 'build/library/LibUtilities/libLibUtilities.so*')) + libs = glob.glob( + os.path.join( + src_path, + 'build/library/LibUtilities/libLibUtilities.so*')) if not libs: return {'return': 1, 'error': f'Nektar++ artifact not found under {src_path}'} bin_dir = os.path.dirname(libs[0]) diff --git a/script/app-nyx/customize.py b/script/app-nyx/customize.py index c835cb072..e19414d6b 100644 --- a/script/app-nyx/customize.py +++ b/script/app-nyx/customize.py @@ -13,7 +13,13 @@ def postprocess(i): env = i['env'] src_path = env.get('MLC_NYX_SRC_PATH', '') compiler_tag = env.get('MLC_COMPILER_FAMILY', '') or 'default' - hits = glob.glob(os.path.join(src_path, 'build-' + compiler_tag, '**/nyx*'), recursive=True) + hits = glob.glob( + os.path.join( + src_path, + 'build-' + + compiler_tag, + '**/nyx*'), + recursive=True) if not hits: return {'return': 1, 'error': f'Nyx artifact not found under {src_path}'} bin_dir = os.path.dirname(hits[0]) diff --git a/script/app-octopus/customize.py b/script/app-octopus/customize.py index 468a426f9..8c806a7d5 100644 --- a/script/app-octopus/customize.py +++ b/script/app-octopus/customize.py @@ -14,7 +14,8 @@ def postprocess(i): install_dir = os.path.join(src_path, 'install') env['MLC_OCTOPUS_INSTALL_PATH'] = install_dir bin_dir = os.path.join(install_dir, 'bin') - env['MLC_OCTOPUS_BIN_PATH'] = bin_dir if os.path.isdir(bin_dir) else src_path + env['MLC_OCTOPUS_BIN_PATH'] = bin_dir if os.path.isdir( + bin_dir) else src_path if os.path.isdir(bin_dir): env['+PATH'] = [bin_dir] return {'return': 0} diff --git a/script/app-openmc/customize.py b/script/app-openmc/customize.py index 66e5b76b1..d91d6fa4a 100644 --- a/script/app-openmc/customize.py +++ b/script/app-openmc/customize.py @@ -16,7 +16,8 @@ def postprocess(i): if not os.path.isfile(binary): return {'return': 1, 'error': f'OpenMC binary not found at {binary}'} bin_dir = os.path.dirname(binary) - env['MLC_OPENMC_INSTALL_PATH'] = os.path.join(src_path, 'build-' + compiler_tag) + env['MLC_OPENMC_INSTALL_PATH'] = os.path.join( + src_path, 'build-' + compiler_tag) env['MLC_OPENMC_BIN_PATH'] = bin_dir env['+PATH'] = [bin_dir] return {'return': 0} diff --git a/script/app-openmolcas/customize.py b/script/app-openmolcas/customize.py index a1c7f7015..a2f42308e 100644 --- a/script/app-openmolcas/customize.py +++ b/script/app-openmolcas/customize.py @@ -5,7 +5,8 @@ def preprocess(i): if i['os_info']['platform'] == 'windows': - return {'return': 1, 'error': 'Windows is not supported for OpenMolcas builds'} + return {'return': 1, + 'error': 'Windows is not supported for OpenMolcas builds'} return {'return': 0} diff --git a/script/app-palabos/customize.py b/script/app-palabos/customize.py index e2bc4187e..55c0f11d6 100644 --- a/script/app-palabos/customize.py +++ b/script/app-palabos/customize.py @@ -11,7 +11,12 @@ def preprocess(i): def postprocess(i): env = i['env'] src_path = env.get('MLC_PALABOS_SRC_PATH', '') - binary = os.path.join(src_path, 'examples', 'showCases', 'cavity3d', 'cavity3d') + binary = os.path.join( + src_path, + 'examples', + 'showCases', + 'cavity3d', + 'cavity3d') if not os.path.isfile(binary): return {'return': 1, 'error': f'Palabos binary not found at {binary}'} bin_dir = os.path.dirname(binary) diff --git a/script/app-pelec/customize.py b/script/app-pelec/customize.py index e71f46c02..57e22a732 100644 --- a/script/app-pelec/customize.py +++ b/script/app-pelec/customize.py @@ -13,7 +13,13 @@ def postprocess(i): env = i['env'] src_path = env.get('MLC_PELEC_SRC_PATH', '') compiler_tag = env.get('MLC_COMPILER_FAMILY', '') or 'default' - hits = glob.glob(os.path.join(src_path, 'build-' + compiler_tag, '**/*PeleC*'), recursive=True) + hits = glob.glob( + os.path.join( + src_path, + 'build-' + + compiler_tag, + '**/*PeleC*'), + recursive=True) if not hits: return {'return': 1, 'error': f'PeleC artifact not found under {src_path}'} bin_dir = os.path.dirname(hits[0]) diff --git a/script/app-pelelmex/customize.py b/script/app-pelelmex/customize.py index 38f72447a..39204d50a 100644 --- a/script/app-pelelmex/customize.py +++ b/script/app-pelelmex/customize.py @@ -13,7 +13,13 @@ def postprocess(i): env = i['env'] src_path = env.get('MLC_PELELMEX_SRC_PATH', '') compiler_tag = env.get('MLC_COMPILER_FAMILY', '') or 'default' - hits = glob.glob(os.path.join(src_path, 'build-' + compiler_tag, '**/*PeleLMeX*'), recursive=True) + hits = glob.glob( + os.path.join( + src_path, + 'build-' + + compiler_tag, + '**/*PeleLMeX*'), + recursive=True) if not hits: return {'return': 1, 'error': f'PeleLMeX artifact not found under {src_path}'} bin_dir = os.path.dirname(hits[0]) diff --git a/script/app-pencil-code/customize.py b/script/app-pencil-code/customize.py index bf9b8fff6..6752a11bf 100644 --- a/script/app-pencil-code/customize.py +++ b/script/app-pencil-code/customize.py @@ -4,7 +4,8 @@ def preprocess(i): if i['os_info']['platform'] == 'windows': - return {'return': 1, 'error': 'Windows is not supported for Pencil Code builds'} + return {'return': 1, + 'error': 'Windows is not supported for Pencil Code builds'} return {'return': 0} diff --git a/script/app-pythia8/customize.py b/script/app-pythia8/customize.py index 44602dd66..7d2c20854 100644 --- a/script/app-pythia8/customize.py +++ b/script/app-pythia8/customize.py @@ -12,7 +12,11 @@ def preprocess(i): def postprocess(i): env = i['env'] src_path = env.get('MLC_PYTHIA8_SRC_PATH', '') - hits = glob.glob(os.path.join(src_path, 'lib/libpythia8*.so'), recursive=True) + hits = glob.glob( + os.path.join( + src_path, + 'lib/libpythia8*.so'), + recursive=True) if not hits: return {'return': 1, 'error': f'Pythia8 artifact not found under {src_path}'} bin_dir = os.path.dirname(hits[0]) diff --git a/script/app-quantum-espresso/customize.py b/script/app-quantum-espresso/customize.py index f8633de1f..31ec75d1b 100644 --- a/script/app-quantum-espresso/customize.py +++ b/script/app-quantum-espresso/customize.py @@ -6,7 +6,8 @@ def preprocess(i): os_info = i['os_info'] if os_info['platform'] == 'windows': - return {'return': 1, 'error': 'Windows is not supported for Quantum ESPRESSO builds'} + return {'return': 1, + 'error': 'Windows is not supported for Quantum ESPRESSO builds'} return {'return': 0} @@ -26,7 +27,8 @@ def postprocess(i): build_bin = os.path.join(src_path, 'build-' + compiler_tag, 'bin') pw_bin = os.path.join(build_bin, 'pw.x') if not os.path.isfile(pw_bin): - return {'return': 1, 'error': f'Quantum ESPRESSO binary (pw.x) not found in {bin_dir} or {build_bin}'} + return { + 'return': 1, 'error': f'Quantum ESPRESSO binary (pw.x) not found in {bin_dir} or {build_bin}'} bin_dir = build_bin env['MLC_QE_BIN_PATH'] = bin_dir diff --git a/script/app-ramses/customize.py b/script/app-ramses/customize.py index d96f16cd3..ec428b250 100644 --- a/script/app-ramses/customize.py +++ b/script/app-ramses/customize.py @@ -21,7 +21,8 @@ def postprocess(i): binary = os.path.join(bin_dir, 'ramses1d') if not os.path.isfile(binary): - return {'return': 1, 'error': f'RAMSES binary (ramses1d) not found in {bin_dir}'} + return {'return': 1, + 'error': f'RAMSES binary (ramses1d) not found in {bin_dir}'} env['MLC_RAMSES_INSTALL_PATH'] = src_path env['MLC_RAMSES_BIN_PATH'] = bin_dir diff --git a/script/app-roms/customize.py b/script/app-roms/customize.py index c0140241f..4c7ab2a66 100644 --- a/script/app-roms/customize.py +++ b/script/app-roms/customize.py @@ -26,7 +26,8 @@ def postprocess(i): install_bin = os.path.join(src_path, 'install-' + compiler_tag, 'bin') roms_bin = os.path.join(install_bin, 'romsM') if not os.path.isfile(roms_bin): - return {'return': 1, 'error': f'ROMS binary (romsM) not found in {build_dir} or {install_bin}'} + return { + 'return': 1, 'error': f'ROMS binary (romsM) not found in {build_dir} or {install_bin}'} bin_dir = os.path.dirname(roms_bin) env['MLC_ROMS_BIN_PATH'] = bin_dir diff --git a/script/app-sherpa/customize.py b/script/app-sherpa/customize.py index 35e83fde1..b3859ea3c 100644 --- a/script/app-sherpa/customize.py +++ b/script/app-sherpa/customize.py @@ -12,7 +12,13 @@ def preprocess(i): def postprocess(i): env = i['env'] src_path = env.get('MLC_SHERPA_SRC_PATH', '') - hits = glob.glob(os.path.join(src_path, 'build', '**', 'libSherpaMain*'), recursive=True) + hits = glob.glob( + os.path.join( + src_path, + 'build', + '**', + 'libSherpaMain*'), + recursive=True) if not hits: return {'return': 1, 'error': f'Sherpa library not found under {src_path}'} bin_dir = os.path.dirname(hits[0]) diff --git a/script/app-smilei/customize.py b/script/app-smilei/customize.py index 21d9758c1..3228d4ca0 100644 --- a/script/app-smilei/customize.py +++ b/script/app-smilei/customize.py @@ -15,7 +15,9 @@ def postprocess(i): binary = os.path.join(src_path, 'install-' + compiler_tag, 'bin', 'smilei') if not os.path.isfile(binary): return {'return': 1, 'error': f'Smilei binary not found at {binary}'} - env['MLC_SMILEI_INSTALL_PATH'] = os.path.join(src_path, 'install-' + compiler_tag) - env['MLC_SMILEI_BIN_PATH'] = os.path.join(src_path, 'install-' + compiler_tag, 'bin') + env['MLC_SMILEI_INSTALL_PATH'] = os.path.join( + src_path, 'install-' + compiler_tag) + env['MLC_SMILEI_BIN_PATH'] = os.path.join( + src_path, 'install-' + compiler_tag, 'bin') env['+PATH'] = [src_path] return {'return': 0} diff --git a/script/app-specfem3d/customize.py b/script/app-specfem3d/customize.py index 48d64d5a8..85d908fa1 100644 --- a/script/app-specfem3d/customize.py +++ b/script/app-specfem3d/customize.py @@ -20,7 +20,8 @@ def postprocess(i): binary = os.path.join(bin_dir, 'xspecfem3D') if not os.path.isfile(binary): - return {'return': 1, 'error': f'SPECFEM3D binary (xspecfem3D) not found in {bin_dir}'} + return { + 'return': 1, 'error': f'SPECFEM3D binary (xspecfem3D) not found in {bin_dir}'} env['MLC_SPECFEM3D_INSTALL_PATH'] = src_path env['MLC_SPECFEM3D_BIN_PATH'] = bin_dir diff --git a/script/app-su2/customize.py b/script/app-su2/customize.py index f1988b7e3..6f7431fec 100644 --- a/script/app-su2/customize.py +++ b/script/app-su2/customize.py @@ -12,11 +12,17 @@ def postprocess(i): env = i['env'] src_path = env.get('MLC_SU2_SRC_PATH', '') compiler_tag = env.get('MLC_COMPILER_FAMILY', '') or 'default' - binary = os.path.join(src_path, 'install-' + compiler_tag, 'bin', 'SU2_CFD') + binary = os.path.join( + src_path, + 'install-' + + compiler_tag, + 'bin', + 'SU2_CFD') if not os.path.isfile(binary): return {'return': 1, 'error': f'SU2 binary not found at {binary}'} bin_dir = os.path.dirname(binary) - env['MLC_SU2_INSTALL_PATH'] = os.path.join(src_path, 'install-' + compiler_tag) + env['MLC_SU2_INSTALL_PATH'] = os.path.join( + src_path, 'install-' + compiler_tag) env['MLC_SU2_BIN_PATH'] = bin_dir env['+PATH'] = [bin_dir] return {'return': 0} diff --git a/script/app-swift/customize.py b/script/app-swift/customize.py index 5ee2f2ccd..fff23642b 100644 --- a/script/app-swift/customize.py +++ b/script/app-swift/customize.py @@ -16,7 +16,8 @@ def postprocess(i): if not os.path.isfile(binary): return {'return': 1, 'error': f'SWIFT binary not found at {binary}'} bin_dir = os.path.dirname(binary) - env['MLC_SWIFT_INSTALL_PATH'] = os.path.join(src_path, 'install-' + compiler_tag) + env['MLC_SWIFT_INSTALL_PATH'] = os.path.join( + src_path, 'install-' + compiler_tag) env['MLC_SWIFT_BIN_PATH'] = bin_dir env['+PATH'] = [bin_dir] return {'return': 0} diff --git a/script/app-tinker-hp/customize.py b/script/app-tinker-hp/customize.py index 8b5ecd089..a9f0af4ef 100644 --- a/script/app-tinker-hp/customize.py +++ b/script/app-tinker-hp/customize.py @@ -14,7 +14,8 @@ def postprocess(i): install_dir = os.path.join(src_path, 'install') env['MLC_TINKER_HP_INSTALL_PATH'] = install_dir bin_dir = os.path.join(install_dir, 'bin') - env['MLC_TINKER_HP_BIN_PATH'] = bin_dir if os.path.isdir(bin_dir) else src_path + env['MLC_TINKER_HP_BIN_PATH'] = bin_dir if os.path.isdir( + bin_dir) else src_path if os.path.isdir(bin_dir): env['+PATH'] = [bin_dir] return {'return': 0} diff --git a/script/app-turbomole/customize.py b/script/app-turbomole/customize.py index cefedb716..96df1fa39 100644 --- a/script/app-turbomole/customize.py +++ b/script/app-turbomole/customize.py @@ -14,7 +14,8 @@ def postprocess(i): install_dir = os.path.join(src_path, 'install') env['MLC_TURBOMOLE_INSTALL_PATH'] = install_dir bin_dir = os.path.join(install_dir, 'bin') - env['MLC_TURBOMOLE_BIN_PATH'] = bin_dir if os.path.isdir(bin_dir) else src_path + env['MLC_TURBOMOLE_BIN_PATH'] = bin_dir if os.path.isdir( + bin_dir) else src_path if os.path.isdir(bin_dir): env['+PATH'] = [bin_dir] return {'return': 0} diff --git a/script/app-vpic/customize.py b/script/app-vpic/customize.py index 3d4002a40..ac07273a2 100644 --- a/script/app-vpic/customize.py +++ b/script/app-vpic/customize.py @@ -12,7 +12,11 @@ def preprocess(i): def postprocess(i): env = i['env'] src_path = env.get('MLC_VPIC_SRC_PATH', '') - hits = glob.glob(os.path.join(src_path, 'build/**/libvpic*.a'), recursive=True) + hits = glob.glob( + os.path.join( + src_path, + 'build/**/libvpic*.a'), + recursive=True) if not hits: return {'return': 1, 'error': f'VPIC artifact not found under {src_path}'} bin_dir = os.path.dirname(hits[0]) diff --git a/script/app-wannier90/customize.py b/script/app-wannier90/customize.py index a48f78ea2..a8dc55835 100644 --- a/script/app-wannier90/customize.py +++ b/script/app-wannier90/customize.py @@ -14,7 +14,8 @@ def postprocess(i): src_path = env.get('MLC_WANNIER90_SRC_PATH', '') hits = glob.glob(os.path.join(src_path, 'wannier90.x'), recursive=True) if not hits: - return {'return': 1, 'error': f'Wannier90 artifact not found under {src_path}'} + return {'return': 1, + 'error': f'Wannier90 artifact not found under {src_path}'} bin_dir = os.path.dirname(hits[0]) env['MLC_WANNIER90_INSTALL_PATH'] = src_path env['MLC_WANNIER90_BIN_PATH'] = bin_dir diff --git a/script/app-warpx/customize.py b/script/app-warpx/customize.py index 7d0415a11..aa0df0197 100644 --- a/script/app-warpx/customize.py +++ b/script/app-warpx/customize.py @@ -13,11 +13,17 @@ def postprocess(i): env = i['env'] src_path = env.get('MLC_WARPX_SRC_PATH', '') compiler_tag = env.get('MLC_COMPILER_FAMILY', '') or 'default' - libs = glob.glob(os.path.join(src_path, 'build-' + compiler_tag, 'bin/warpx*')) + libs = glob.glob( + os.path.join( + src_path, + 'build-' + + compiler_tag, + 'bin/warpx*')) if not libs: return {'return': 1, 'error': f'WarpX artifact not found under {src_path}'} bin_dir = os.path.dirname(libs[0]) - env['MLC_WARPX_INSTALL_PATH'] = os.path.join(src_path, 'build-' + compiler_tag) + env['MLC_WARPX_INSTALL_PATH'] = os.path.join( + src_path, 'build-' + compiler_tag) env['MLC_WARPX_BIN_PATH'] = bin_dir env['+PATH'] = [bin_dir] return {'return': 0} diff --git a/script/app-webarena/customize.py b/script/app-webarena/customize.py index 816b70004..7d5630cdd 100644 --- a/script/app-webarena/customize.py +++ b/script/app-webarena/customize.py @@ -6,7 +6,8 @@ def preprocess(i): env = i['env'] backend = str(env.get('MLC_WEBARENA_BACKEND', 'mock')).lower() - if backend == 'endpoint' and not env.get('MLC_WEBARENA_ENDPOINT_URL', '').strip(): + if backend == 'endpoint' and not env.get( + 'MLC_WEBARENA_ENDPOINT_URL', '').strip(): return {'return': 1, 'error': 'endpoint backend requires --endpoint (MLC_WEBARENA_ENDPOINT_URL)'} @@ -18,7 +19,10 @@ def preprocess(i): # The workload is executed by the benchmark-program posthook dependency. python_bin = env.get('MLC_PYTHON_BIN_WITH_PATH', 'python3') - script = os.path.join(env['MLC_TMP_CURRENT_SCRIPT_PATH'], 'src', 'run_webarena.py') + script = os.path.join( + env['MLC_TMP_CURRENT_SCRIPT_PATH'], + 'src', + 'run_webarena.py') env['MLC_RUN_CMD'] = f'{python_bin} "{script}"' if not env.get('MLC_RUN_DIR', ''): env['MLC_RUN_DIR'] = os.getcwd() @@ -45,5 +49,6 @@ def postprocess(i): env['MLC_WEBARENA_SUCCESS_RATE'] = str(data.get('success_rate_scored', '')) state['mlc_webarena'] = data - logger.info(f"WebArena scored success rate: {data.get('success_rate_scored')}") + logger.info( + f"WebArena scored success rate: {data.get('success_rate_scored')}") return {'return': 0} diff --git a/script/app-webarena/src/run_webarena.py b/script/app-webarena/src/run_webarena.py index 9b625c0df..5c4e6e7bb 100644 --- a/script/app-webarena/src/run_webarena.py +++ b/script/app-webarena/src/run_webarena.py @@ -71,7 +71,8 @@ def score_string_match(pred, reference_answers): if not reference_answers: return None if "exact_match" in reference_answers: - return float(_normalise(pred) == _normalise(reference_answers["exact_match"])) + return float(_normalise(pred) == _normalise( + reference_answers["exact_match"])) if "must_include" in reference_answers: return float(all(_normalise(x) in _normalise(pred) for x in reference_answers["must_include"])) @@ -140,7 +141,8 @@ def main(): print("ERROR: no tasks selected", file=sys.stderr) return 1 - print(f"WebArena: {len(tasks)} task(s) | dataset={dataset} backend={backend}") + print( + f"WebArena: {len(tasks)} task(s) | dataset={dataset} backend={backend}") results = [] start = time.time() @@ -149,7 +151,8 @@ def main(): eval_types = eval_block.get("eval_types", []) if generator is None: steps = min(max_steps, 5 + (len(task.get("intent", "")) % 8)) - success = (sum(ord(c) for c in str(task.get("task_id", ""))) % 3) != 0 + success = (sum(ord(c) + for c in str(task.get("task_id", ""))) % 3) != 0 answer = f"[mock] simulated completion for {task.get('task_id')}" score = float(success) needs_env = False @@ -161,7 +164,8 @@ def main(): answer = generator(system, user) steps = 1 if eval_types == ["string_match"]: - score = score_string_match(answer, eval_block.get("reference_answers")) + score = score_string_match( + answer, eval_block.get("reference_answers")) needs_env = score is None success = bool(score) else: @@ -210,7 +214,8 @@ def main(): print(f"Success rate (scored subset): " f"{summary['success_rate_scored'] * 100:.1f}% " f"({passed}/{len(scored)})") - print(f"{summary['num_needs_env']} task(s) need the live WebArena environment") + print( + f"{summary['num_needs_env']} task(s) need the live WebArena environment") print(f"Results written to {out_file}") return 0 diff --git a/script/app-webvoyager/customize.py b/script/app-webvoyager/customize.py index 7139d1ce8..b3f0f0972 100644 --- a/script/app-webvoyager/customize.py +++ b/script/app-webvoyager/customize.py @@ -6,21 +6,26 @@ def preprocess(i): env = i['env'] backend = str(env.get('MLC_WEBVOYAGER_BACKEND', 'mock')).lower() - if backend == 'endpoint' and not env.get('MLC_WEBVOYAGER_ENDPOINT_URL', '').strip(): + if backend == 'endpoint' and not env.get( + 'MLC_WEBVOYAGER_ENDPOINT_URL', '').strip(): return {'return': 1, 'error': 'endpoint backend requires --endpoint (MLC_WEBVOYAGER_ENDPOINT_URL)'} # When the official repo is cloned, point the harness at its task files. src = env.get('MLC_WEBVOYAGER_SRC_PATH', '').strip() if src and not env.get('MLC_WEBVOYAGER_TASK_FILE', '').strip(): - env['MLC_WEBVOYAGER_TASK_FILE'] = os.path.join(src, 'data', 'WebVoyager_data.jsonl') + env['MLC_WEBVOYAGER_TASK_FILE'] = os.path.join( + src, 'data', 'WebVoyager_data.jsonl') ref = os.path.join(src, 'data', 'reference_answer.json') if os.path.isfile(ref): env['MLC_WEBVOYAGER_REF_FILE'] = ref # The workload is executed by the benchmark-program posthook dependency. python_bin = env.get('MLC_PYTHON_BIN_WITH_PATH', 'python3') - script = os.path.join(env['MLC_TMP_CURRENT_SCRIPT_PATH'], 'src', 'run_webvoyager.py') + script = os.path.join( + env['MLC_TMP_CURRENT_SCRIPT_PATH'], + 'src', + 'run_webvoyager.py') env['MLC_RUN_CMD'] = f'{python_bin} "{script}"' if not env.get('MLC_RUN_DIR', ''): env['MLC_RUN_DIR'] = os.getcwd() diff --git a/script/app-webvoyager/src/run_webvoyager.py b/script/app-webvoyager/src/run_webvoyager.py index be5b047c6..361e5e0d5 100644 --- a/script/app-webvoyager/src/run_webvoyager.py +++ b/script/app-webvoyager/src/run_webvoyager.py @@ -136,7 +136,10 @@ def main(): tasks = load_tasks() if website: - tasks = [t for t in tasks if t.get("web_name", "").lower() == website.lower()] + tasks = [ + t for t in tasks if t.get( + "web_name", + "").lower() == website.lower()] tasks = tasks[:num_samples] if not tasks: print("ERROR: no tasks selected", file=sys.stderr) diff --git a/script/app-wien2k/customize.py b/script/app-wien2k/customize.py index 01401380c..df5a645c6 100644 --- a/script/app-wien2k/customize.py +++ b/script/app-wien2k/customize.py @@ -14,7 +14,8 @@ def postprocess(i): install_dir = os.path.join(src_path, 'install') env['MLC_WIEN2K_INSTALL_PATH'] = install_dir bin_dir = os.path.join(install_dir, 'bin') - env['MLC_WIEN2K_BIN_PATH'] = bin_dir if os.path.isdir(bin_dir) else src_path + env['MLC_WIEN2K_BIN_PATH'] = bin_dir if os.path.isdir( + bin_dir) else src_path if os.path.isdir(bin_dir): env['+PATH'] = [bin_dir] return {'return': 0} diff --git a/script/app-ww3/customize.py b/script/app-ww3/customize.py index db468abf5..4dd4ca72d 100644 --- a/script/app-ww3/customize.py +++ b/script/app-ww3/customize.py @@ -5,7 +5,8 @@ def preprocess(i): if i['os_info']['platform'] == 'windows': - return {'return': 1, 'error': 'Windows is not supported for WaveWatch III builds'} + return {'return': 1, + 'error': 'Windows is not supported for WaveWatch III builds'} return {'return': 0} diff --git a/script/benchmark-hnswlib/customize.py b/script/benchmark-hnswlib/customize.py index 832c80a7b..5889ccb81 100644 --- a/script/benchmark-hnswlib/customize.py +++ b/script/benchmark-hnswlib/customize.py @@ -13,7 +13,10 @@ def preprocess(i): # The workload is executed by the benchmark-program posthook dependency. python_bin = env.get('MLC_PYTHON_BIN_WITH_PATH', 'python3') - script = os.path.join(env['MLC_TMP_CURRENT_SCRIPT_PATH'], 'src', 'run_hnswlib.py') + script = os.path.join( + env['MLC_TMP_CURRENT_SCRIPT_PATH'], + 'src', + 'run_hnswlib.py') env['MLC_RUN_CMD'] = f'{python_bin} "{script}"' if not env.get('MLC_RUN_DIR', ''): env['MLC_RUN_DIR'] = os.getcwd() diff --git a/script/benchmark-hnswlib/src/run_hnswlib.py b/script/benchmark-hnswlib/src/run_hnswlib.py index 72b767f4f..d7f1b937c 100644 --- a/script/benchmark-hnswlib/src/run_hnswlib.py +++ b/script/benchmark-hnswlib/src/run_hnswlib.py @@ -33,7 +33,8 @@ def brute_force_topk(base, queries, k, metric): """Exact top-k neighbor indices for each query via numpy.""" if metric == "cosine": base = base / (np.linalg.norm(base, axis=1, keepdims=True) + 1e-12) - queries = queries / (np.linalg.norm(queries, axis=1, keepdims=True) + 1e-12) + queries = queries / \ + (np.linalg.norm(queries, axis=1, keepdims=True) + 1e-12) if metric in ("ip", "cosine"): scores = queries @ base.T # larger = closer idx = np.argpartition(-scores, k - 1, axis=1)[:, :k] diff --git a/script/benchmark-program/customize.py b/script/benchmark-program/customize.py index a2f0e63c9..9cb5dfbf9 100644 --- a/script/benchmark-program/customize.py +++ b/script/benchmark-program/customize.py @@ -73,7 +73,8 @@ def preprocess(i): env['MLC_BENCHMARK_PERF_DATA'] = data env['MLC_BENCHMARK_PERF_REPORT_FILE'] = report elif mode == 'insmix': - # True dynamic instruction mix via Intel SDE (emulated, host-agnostic). + # True dynamic instruction mix via Intel SDE (emulated, + # host-agnostic). sde_bin = env.get('MLC_INTEL_SDE_BIN_WITH_PATH', 'sde64') out = os.path.join(perf_out, 'sde-mix-out.txt') perf_prefix = q + sde_bin + q + ' -mix -omix ' + q + out + q + ' -- ' @@ -88,7 +89,9 @@ def preprocess(i): q + out + q) env['MLC_BENCHMARK_PERF_STAT_FILE'] = out env['MLC_RUN_PREFIX0'] = perf_prefix + env.get('MLC_RUN_PREFIX0', '') - logger.info('Perf profiling enabled ({}): {}'.format(mode, perf_prefix)) + logger.info( + 'Perf profiling enabled ({}): {}'.format( + mode, perf_prefix)) x = env.get('MLC_RUN_PREFIX0', '') if x != '': @@ -150,7 +153,8 @@ def preprocess(i): # perf record needs a post-run step to render the human-readable report. if perf_post_cmd: - post_run_cmd = post_run_cmd + ' ; ' + perf_post_cmd if post_run_cmd else perf_post_cmd + post_run_cmd = post_run_cmd + ' ; ' + \ + perf_post_cmd if post_run_cmd else perf_post_cmd env['MLC_POST_RUN_CMD'] = post_run_cmd diff --git a/script/build-apptainerfile/customize.py b/script/build-apptainerfile/customize.py index 2700472ea..ea1e7054d 100644 --- a/script/build-apptainerfile/customize.py +++ b/script/build-apptainerfile/customize.py @@ -289,7 +289,8 @@ def preprocess(i): for parent_dir, repo_name in host_repos_to_copy: f.write( f" tar -C {parent_dir} --exclude=repos.json --exclude='index_*.json' --exclude=local --exclude=modified_times.json --exclude='*.sif' -cf - {repo_name} | tar -xf - -C ${{APPTAINER_ROOTFS}}/opt/mlc_host_repos/\n") - f.write(" chmod -R 777 ${APPTAINER_ROOTFS}/opt/mlc_host_repos\n") + f.write( + " chmod -R 777 ${APPTAINER_ROOTFS}/opt/mlc_host_repos\n") f.write("\n") elif use_copy_repo: repo_name = os.path.basename(mlc_repo_path) diff --git a/script/generate-infragraph/COPYRIGHT.md b/script/generate-infragraph/COPYRIGHT.md new file mode 100644 index 000000000..d1f9c5e95 --- /dev/null +++ b/script/generate-infragraph/COPYRIGHT.md @@ -0,0 +1,9 @@ +# Copyright Notice + +© 2026-2027 MLCommons. All Rights Reserved. + +This file is licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. A copy of the License can be obtained at: + +[Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) + +Unless required by applicable law or agreed to in writing, software distributed under the License is provided on an "AS IS" basis, without warranties or conditions of any kind, either express or implied. Please refer to the License for the specific language governing permissions and limitations under the License. diff --git a/script/generate-infragraph/README.md b/script/generate-infragraph/README.md new file mode 100644 index 000000000..11250a899 --- /dev/null +++ b/script/generate-infragraph/README.md @@ -0,0 +1,71 @@ +# README for generate-infragraph +This README is automatically generated. Edit [info.md](info.md) to add custom contents. Please follow the [script execution document](https://docs.mlcommons.org/mlcflow/targets/script/execution-flow/) to understand more about the MLC script execution. + +`mlcflow` stores all local data under `$HOME/MLC` by default. So, if there is space constraint on the home directory and you have more space on say `/mnt/$USER`, you can do +``` +mkdir /mnt/$USER/MLC +ln -s /mnt/$USER/MLC $HOME/MLC +``` +You can also use the `ENV` variable `MLC_REPOS` to control this location but this will need a set after every system reboot. + +## Setup + +If you are not on a Python development environment please refer to the [official docs](https://docs.mlcommons.org/mlcflow/install/) for the installation. + +```bash +python3 -m venv mlcflow +. mlcflow/bin/activate +pip install mlcflow +``` + +- Using a virtual environment is recommended (per `pip` best practices), but you may skip it or use `--break-system-packages` if needed. + +### Pull mlperf-automations + +Once `mlcflow` is installed: + +```bash +mlc pull repo mlcommons@mlperf-automations --pat= +``` +- `--pat` or `--ssh` is only needed if the repo is PRIVATE +- If `--pat` is avoided, you'll be asked to enter the password where you can enter your Private Access Token +- `--ssh` option can be used instead of `--pat=<>` option if you prefer to use SSH for accessing the github repository. +## Run Commands + +```bash +mlcr generate,infragraph,infragraph +``` + +### Script Inputs + +| Name | Description | Choices | Default | +|------|-------------|---------|------| +| `--input_dir` | | | `` | +| `--graph_name` | | | `` | +| `--out_dir_path` | | | `` | +| `--out_file_name` | | | `infragraph.json` | +### Generic Script Inputs + +| Name | Description | Choices | Default | +|------|-------------|---------|------| +| `--input` | Input to the script passed using the env key `MLC_INPUT` | | `` | +| `--output` | Output from the script passed using the env key `MLC_OUTPUT` | | `` | +| `--outdirname` | The directory to store the script output | | `cache directory ($HOME/MLC/repos/local/cache/<>) if the script is cacheable or else the current directory` | +| `--outbasename` | The output file/folder name | | `` | +| `--search_folder_path` | The folder path where executables of a given script need to be searched. Search is done recursively upto 4 levels. | | `` | +| `--name` | | | `` | +| `--extra_cache_tags` | Extra cache tags to be added to the cached entry when the script results are saved | | `` | +| `--skip_compile` | Skip compilation | | `False` | +| `--skip_run` | Skip run | | `False` | +| `--skip_sudo` | Skip SUDO detection | | `False` | +| `--accept_license` | Accept the required license requirement to run the script | | `False` | +| `--skip_system_deps` | Skip installing any system dependencies | | `False` | +| `--git_ssh` | Use SSH for git repos | | `False` | +| `--gh_token` | Github Token | | `` | +| `--hf_token` | Huggingface Token | | `` | +| `--verify_ssl` | Verify SSL | | `False` | +## Variations + +### Ungrouped + +- `no_visualize` diff --git a/script/generate-infragraph/build_infragraph.py b/script/generate-infragraph/build_infragraph.py new file mode 100644 index 000000000..00c5eee86 --- /dev/null +++ b/script/generate-infragraph/build_infragraph.py @@ -0,0 +1,365 @@ +"""Build one infrastructure graph out of a directory of per-node captures. + +The directory is whatever `get-mlperf-multi-node-system-info,_infragraph` +leaves behind: for every node, an hwloc topology and the sysinfo JSON that +shares its stem. + + mlperf-system-info-single-node-0.lstopo.xml + mlperf-system-info-single-node-0.json + mlperf-system-info-single-node-1.lstopo.xml + mlperf-system-info-single-node-1.json + +Each topology is translated to an infragraph device definition, the +definitions are unioned into a single `Infrastructure`, and each node's cpu / +xpu graph nodes are annotated from that node's sysinfo. One node in equals a +single-node graph; N nodes in equals a multi-node graph -- the path through +this script is the same either way. + +Structurally identical devices are emitted once and instantiated per node, so +a homogeneous cluster yields one device definition rather than N copies of it. +Instances are named after each node's real hostname, which is what puts the +node identity into generated graph node names (`mlc2.0.cpu.0`) and lets each +node be annotated with its own sysinfo. + +No infrastructure-level `edges` are emitted: lstopo sees one host at a time, so +there is no observable inter-node fabric to infer. The merged graph is a set of +per-node subgraphs, not a fabric topology. +""" + +import argparse +import copy +import json +import sys +import xml.etree.ElementTree as ET +from pathlib import Path + +import yaml +from infragraph import * +from infragraph.infragraph_service import InfraGraphService +from infragraph.translators.translator_handler import run_translator +from infragraph.visualizer.visualize import run_visualizer + +TOPOLOGY_SUFFIX = ".lstopo.xml" + + +def parse_args(): + p = argparse.ArgumentParser(description=__doc__) + p.add_argument("--input-dir", required=True, + help="Directory holding the per-node *.lstopo.xml topologies " + "and their matching sysinfo JSON files.") + p.add_argument("--output", required=True, + help="Path of the annotated infrastructure graph JSON to write.") + p.add_argument("--output-yaml", required=True, + help="Path of the merged Infrastructure YAML to write.") + p.add_argument("--name", default="multi-node-system", + help="Name of the merged infrastructure.") + p.add_argument("--visuals-dir", default="", + help="Directory to write the visualizer bundle into. " + "Empty to skip visualization.") + return p.parse_args() + + +def sort_key(stem): + """Natural sort: trailing digits compare numerically, the rest lexically. + + Keeps node-2 ahead of node-10 in the instance list, so the graph reads + against the same node numbering the submission uses. Mirrors _sort_key in + customize.py -- the two must agree or the node count logged in preprocess + describes a different set than the one merged here. + """ + head = stem.rstrip("0123456789") + tail = stem[len(head):] + return (head, int(tail) if tail else -1) + + +def discover_nodes(input_dir): + """[(stem, xml_path, sysinfo_path_or_None)] for every topology in the dir.""" + nodes = [] + for xml in sorted(input_dir.glob("*" + TOPOLOGY_SUFFIX)): + stem = xml.name[:-len(TOPOLOGY_SUFFIX)] + sysinfo = input_dir / (stem + ".json") + nodes.append((stem, xml, sysinfo if sysinfo.is_file() else None)) + return sorted(nodes, key=lambda n: sort_key(n[0])) + + +def build_type_query(*node_types): + """One attribute query carrying a named node_filter per component type.""" + request = QueryRequest() + for node_type in node_types: + node_filter = request.attribute_query.node_filters.add( + name=f"{node_type} filter") + node_filter.attribute_filters.attributes.add( + attribute="type", value=node_type) + return request + + +def matched_nodes(response, node_type): + """Nodes matched by the ` filter`. attribute_filters matching is + substring based, so keep only the exact `type` hits.""" + for result in response.attribute_query.nodes: + if result.name != f"{node_type} filter": + continue + return [node for node in result.nodes + if any(a.attribute == "type" and a.value == node_type + for a in node.attributes)] + return [] + + +def unique_name(base, taken): + """Return `base` if free, else `base-2`, `base-3`, ... .""" + if base not in taken: + return base + suffix = 2 + while f"{base}-{suffix}" in taken: + suffix += 1 + return f"{base}-{suffix}" + + +def sanitize_instance_name(name): + """Make `name` safe to use as an infragraph instance name. + + Generated graph node names are "..." and + infragraph recovers the instance by splitting on '.', so a dot inside the + instance name would corrupt node addressing. An FQDN such as + `node1.cluster.local` therefore becomes `node1-cluster-local`. Whitespace is + collapsed for the same reason it is avoided elsewhere: these names end up in + shell output and in query filters. + """ + return "-".join(str(name).split()).replace(".", "-") + + +def node_display_name(xml_path, stem): + """The node's real hostname, read from its lstopo XML. + + lstopo records the host it ran on as a single + `` element, so the hostname costs no + extra remote work -- the XML is already here. Falls back to the file stem + when the element is missing (lstopo omits HostName on some platforms) so + naming never hard-fails. + """ + try: + tree = ET.parse(xml_path) + except ET.ParseError as e: + print(f"[WARN] {stem}: could not parse {xml_path} for a hostname " + f"({e}); falling back to {stem}.", file=sys.stderr) + return sanitize_instance_name(stem) + + for info in tree.iter("info"): + if info.get("name") == "HostName": + value = (info.get("value") or "").strip() + if value: + return sanitize_instance_name(value) + + print(f"[WARN] {stem}: no HostName in {xml_path}; falling back to {stem}.", + file=sys.stderr) + return sanitize_instance_name(stem) + + +def translate_nodes(nodes, work_dir): + """Run the lstopo translator over every node. Returns [(stem, dev_dict)].""" + translated = [] + for stem, xml_path, _sysinfo in nodes: + dev_path = work_dir / f"dev-{stem}.yaml" + run_translator("lstopo", str(xml_path), str(dev_path), "yaml", None) + if not dev_path.is_file(): + print(f"[ERROR] {stem}: `infragraph translate lstopo` produced no " + f"output at {dev_path}.", file=sys.stderr) + sys.exit(1) + with open(dev_path, "r", encoding="utf-8") as f: + translated.append((stem, yaml.safe_load(f) or {})) + print(f"[INFO] {stem}: topology translated to {dev_path}") + return translated + + +def merge_devices(translated, display_names): + """Build the merged Infrastructure dict and the stem -> instance map.""" + devices = {} # device name -> device dict + instance_of_node = {} # stem -> instance name + device_of_node = {} # stem -> device name + + for stem, per_node in translated: + node_devices = per_node.get("devices") or [] + if len(node_devices) != 1: + print(f"[ERROR] {stem}: translated topology declares " + f"{len(node_devices)} devices; expected exactly 1 from " + "`infragraph translate lstopo`.", file=sys.stderr) + sys.exit(1) + + device = copy.deepcopy(node_devices[0]) + original_name = device.get("name") or stem + + # Reuse an existing device definition when this node is structurally + # identical to one already merged -- the homogeneous-cluster case. + # Compare with the name masked out so a renamed-but-identical device + # still dedupes. + reused = None + probe = dict(device, name=None) + for existing_name, existing in devices.items(): + if dict(existing, name=None) == probe: + reused = existing_name + break + + if reused is None: + device_name = unique_name(original_name, devices) + device["name"] = device_name + devices[device_name] = device + else: + device_name = reused + + # Two nodes can legitimately report the same hostname (cloned images, a + # misconfigured cluster) and duplicate instance names would silently + # collapse two nodes into one, so uniqueness is enforced here. + instance_name = unique_name( + display_names[stem], set(instance_of_node.values())) + instance_of_node[stem] = instance_name + device_of_node[stem] = device_name + + merged = { + "devices": list(devices.values()), + "instances": [ + { + "name": instance_of_node[stem], + "device": device_of_node[stem], + "count": 1, + # Keep the stem in the description: it is the only link back to + # that node's sysinfo JSON once the instance has been renamed + # to the hostname. + "description": stem, + } + for stem, _ in translated + ], + } + return merged, instance_of_node + + +def load_sysinfo(sysinfo_path, stem): + """Load a node's sysinfo JSON. Returns {} when it is absent or unreadable.""" + if sysinfo_path is None: + print(f"[WARN] {stem}: no matching sysinfo JSON; that node's topology " + "will be emitted unannotated.", file=sys.stderr) + return {} + try: + with open(sysinfo_path, "r", encoding="utf-8") as f: + return json.load(f) + except (OSError, json.JSONDecodeError) as e: + print(f"[WARN] {stem}: could not read {sysinfo_path} ({e}); that " + "node's topology will be emitted unannotated.", file=sys.stderr) + return {} + + +def annotate(service, nodes, instance_of_node): + """Attach each node's sysinfo to that node's cpu / xpu graph nodes.""" + response = service.query_graph(build_type_query("cpu", "xpu")) + cpu_matches = matched_nodes(response, "cpu") + xpu_matches = matched_nodes(response, "xpu") + + annotation = Annotation() + annotated = 0 + + for stem, _xml, sysinfo_path in nodes: + sysinfo = load_sysinfo(sysinfo_path, stem) + if not sysinfo: + continue + + # The single-node sysinfo JSON is a flat dict of prefixed keys; group by + # prefix to recover the processor / accelerator attribute sets. + processor_attrs = {k: v for k, v in sysinfo.items() + if k.startswith("host_processor")} + accelerator_attrs = {k: v for k, v in sysinfo.items() + if k.startswith("accelerator")} + + # Graph node names are "...", so the + # instance name prefix is what scopes a match to this node. + prefix = instance_of_node[stem] + "." + + for match in cpu_matches: + if not match.name.startswith(prefix): + continue + node = annotation.nodes.add(name=match.name) + for key, value in processor_attrs.items(): + node.attributes.add(attribute=key, value=str(value)) + annotated += 1 + + accel_model = accelerator_attrs.get("accelerator_model_name", "") + node_xpus = [m for m in xpu_matches if m.name.startswith(prefix)] + accel_hits = 0 + for match in node_xpus: + if accel_model and accel_model not in match.name: + continue + node = annotation.nodes.add(name=match.name) + for key, value in accelerator_attrs.items(): + node.attributes.add(attribute=key, value=str(value)) + annotated += 1 + accel_hits += 1 + + # lstopo does not always surface the benchmark accelerator as an xpu + # component -- a discrete GPU can land under pci_device while the + # on-board BMC display controller is what gets typed xpu. Without this + # warning the graph looks complete while carrying no accelerator + # attributes for the node at all. + if accelerator_attrs and not accel_hits: + seen = [m.name.split(".", 2)[-1] for m in node_xpus] or "none" + print(f"[WARN] {stem}: sysinfo reports accelerator " + f"'{accel_model}' but no xpu component in this node's " + f"topology matches that name (xpu components seen: {seen}). " + "Accelerator attributes were NOT attached for this node.", + file=sys.stderr) + + if annotated: + service.annotate_graph(annotation) + print(f"[INFO] annotated {annotated} graph node(s) across " + f"{len(nodes)} node(s)") + + +def main(): + args = parse_args() + + input_dir = Path(args.input_dir) + nodes = discover_nodes(input_dir) + if not nodes: + print(f"[ERROR] no *{TOPOLOGY_SUFFIX} topology files in {input_dir}", + file=sys.stderr) + sys.exit(1) + + output_path = Path(args.output) + merged_yaml_path = Path(args.output_yaml) + output_path.parent.mkdir(parents=True, exist_ok=True) + merged_yaml_path.parent.mkdir(parents=True, exist_ok=True) + + display_names = {stem: node_display_name(xml, stem) + for stem, xml, _ in nodes} + + # The per-node translations are intermediates; they are kept beside the + # merged YAML rather than in a temp dir so a failed merge can be debugged + # from what is left on disk. + translated = translate_nodes(nodes, merged_yaml_path.parent) + + merged, instance_of_node = merge_devices(translated, display_names) + merged["name"] = args.name + merged["description"] = ( + f"Infrastructure graph for {len(nodes)} node(s): " + + ", ".join(instance_of_node[stem] for stem, _, _ in nodes)) + + with open(merged_yaml_path, "w", encoding="utf-8") as f: + yaml.safe_dump(merged, f, sort_keys=True) + print(f"[INFO] merged Infrastructure YAML written to {merged_yaml_path}") + + service = InfraGraphService() + service.set_graph(Infrastructure().deserialize(merged)) + + annotate(service, nodes, instance_of_node) + + get_graph_req = GraphRequest() + get_graph_req.choice = get_graph_req.INFRAGRAPH + get_graph_req.infragraph.annotations.choice = "full" + with open(output_path, "w", encoding="utf-8") as f: + f.write(service.get_graph(get_graph_req)) + print(f"[INFO] infrastructure graph written to {output_path}") + + if args.visuals_dir: + print(f"[INFO] generating visualizer bundle in {args.visuals_dir}") + run_visualizer(input_file=str(output_path), output=args.visuals_dir) + + +if __name__ == "__main__": + main() diff --git a/script/generate-infragraph/customize.py b/script/generate-infragraph/customize.py new file mode 100644 index 000000000..608adbe82 --- /dev/null +++ b/script/generate-infragraph/customize.py @@ -0,0 +1,138 @@ +from utils import is_true +import os +import glob + + +# The lstopo capture written by get-mlperf-single-node-system-info,_lstopo +# shares its stem with that node's sysinfo JSON: +# mlperf-system-info-single-node-2.json +# mlperf-system-info-single-node-2.lstopo.xml +# Pairing on the stem is what lets this script work for a directory produced by +# any caller, single node or multi node, without being told a node list. +_TOPOLOGY_SUFFIX = '.lstopo.xml' + +# infragraph >= 3.0 uses PEP 604 annotations (`str | None`) at class-definition +# time, so on an older interpreter it does not fail to install -- it fails to +# import, with a TypeError that says nothing about Python versions. +_MIN_PYTHON = (3, 10) + + +def _python_version(env): + """(major, minor) of the interpreter MLC selected, or None if unreadable.""" + raw = env.get('MLC_PYTHON_VERSION', '') + parts = str(raw).split('.') + if len(parts) >= 2 and parts[0].isdigit() and parts[1].isdigit(): + return (int(parts[0]), int(parts[1])) + return None + + +def _discover_nodes(input_dir): + """Every (stem, xml, sysinfo_or_None) triple found in input_dir. + + Sorted so that node-2 lands after node-10 in numeric rather than + lexicographic order -- the ordering shows up in the merged graph's + instance list, and a jumbled one is confusing to read against the + submission's node numbering. + """ + nodes = [] + for xml in glob.glob(os.path.join(input_dir, '*' + _TOPOLOGY_SUFFIX)): + stem = os.path.basename(xml)[:-len(_TOPOLOGY_SUFFIX)] + sysinfo = os.path.join(input_dir, stem + '.json') + nodes.append((stem, xml, sysinfo if os.path.isfile(sysinfo) else None)) + return sorted(nodes, key=lambda n: _sort_key(n[0])) + + +def _sort_key(stem): + """Natural sort: trailing digits compare numerically, rest lexically.""" + head = stem.rstrip('0123456789') + tail = stem[len(head):] + return (head, int(tail) if tail else -1) + + +def preprocess(i): + + env = i['env'] + logger = i['automation'].logger + + # version_min on the python dep is ignored when MLC_PYTHON_BIN_WITH_PATH + # is already set by an enclosing script -- get-python3 keeps the inherited + # interpreter rather than searching for one. Check here so the failure + # names the real problem instead of surfacing as an import TypeError. + version = _python_version(env) + if version and version < _MIN_PYTHON: + want = '.'.join(str(v) for v in _MIN_PYTHON) + return {'return': 1, + 'error': f'infragraph needs Python >= {want}, but MLC selected ' + f'{env.get("MLC_PYTHON_BIN_WITH_PATH", "?")} ' + f'(version {env.get("MLC_PYTHON_VERSION", "?")}). ' + 'Point MLC at a newer interpreter, e.g. ' + '`mlc rm cache --tags=get,python3` then re-run, or ' + 'pass --adr.python.version_min=' + want + ' to the ' + 'top-level script.'} + + input_dir = env.get('MLC_INFRAGRAPH_INPUT_DIR_PATH', '') or os.getcwd() + input_dir = os.path.abspath(input_dir) + if not os.path.isdir(input_dir): + return {'return': 1, + 'error': f'Input directory does not exist: {input_dir}'} + env['MLC_INFRAGRAPH_INPUT_DIR_PATH'] = input_dir + + out_dir = env.get('MLC_INFRAGRAPH_OUT_DIR_PATH', '') or input_dir + out_dir = os.path.abspath(out_dir) + os.makedirs(out_dir, exist_ok=True) + env['MLC_INFRAGRAPH_OUT_DIR_PATH'] = out_dir + + file_name = env.get('MLC_INFRAGRAPH_FILE_NAME', '') or 'infragraph.json' + env['MLC_INFRAGRAPH_FILE_PATH'] = os.path.join(out_dir, file_name) + env['MLC_INFRAGRAPH_YAML_FILE_PATH'] = os.path.join( + out_dir, os.path.splitext(file_name)[0] + '.yaml') + env['MLC_INFRAGRAPH_VISUALS_DIR_PATH'] = os.path.join(out_dir, 'visuals') + + nodes = _discover_nodes(input_dir) + if not nodes: + return {'return': 1, + 'error': f'No *{_TOPOLOGY_SUFFIX} topology files found in ' + f'{input_dir}. Run the system-info collection with ' + 'the _infragraph variation (or get,mlperf,single-' + 'node,system-info with _lstopo) so each node writes ' + 'its hwloc topology next to its sysinfo JSON.'} + + for stem, _xml, sysinfo in nodes: + if sysinfo is None: + logger.warning( + f'{stem}: topology found but no matching {stem}.json sysinfo; ' + 'this node will appear in the graph without processor or ' + 'accelerator attributes.') + logger.info( + f'Building infrastructure graph from {len(nodes)} node topology ' + f'file(s) in {input_dir}') + + env['MLC_INFRAGRAPH_NODE_COUNT'] = str(len(nodes)) + + # An empty MLC_MLPERF_SYSTEM_NAME templates through to an empty string + # rather than being absent, so test for content, not for the key. + if not env.get('MLC_INFRAGRAPH_NAME', '').strip(): + env['MLC_INFRAGRAPH_NAME'] = ( + 'single-node-system' if len(nodes) == 1 else 'multi-node-system') + + return {'return': 0} + + +def postprocess(i): + + env = i['env'] + logger = i['automation'].logger + + out_path = env.get('MLC_INFRAGRAPH_FILE_PATH', '') + if not out_path or not os.path.isfile(out_path): + return {'return': 1, + 'error': f'Expected the infrastructure graph at {out_path}, ' + 'but it was not produced.'} + + # Visuals are optional, so only advertise the directory when it is there. + if not os.path.isdir(env.get('MLC_INFRAGRAPH_VISUALS_DIR_PATH', '')): + del env['MLC_INFRAGRAPH_VISUALS_DIR_PATH'] + + logger.info(f'Infrastructure graph written to {out_path}') + + return {'return': 0} diff --git a/script/generate-infragraph/info.md b/script/generate-infragraph/info.md new file mode 100644 index 000000000..8771f36a7 --- /dev/null +++ b/script/generate-infragraph/info.md @@ -0,0 +1,103 @@ +# generate-infragraph + +Builds an [infragraph](https://pypi.org/project/infragraph/) infrastructure +graph from a directory of per-node system-info captures, and renders an +interactive HTML view of it. + +It is normally not run by hand. `get-mlperf-multi-node-system-info,_infragraph` +runs it as a `post_dep` once every node has reported in, which is the path most +people want. Running it directly is useful when you already have the captures +on disk and want to rebuild the graph — after editing a topology by hand, say, +or to re-render the visuals without re-probing the cluster. + +## What it reads + +The input directory is expected to hold, for each node, an hwloc topology and +the sysinfo JSON that shares its stem: + +``` +mlperf-system-info-single-node-0.lstopo.xml +mlperf-system-info-single-node-0.json +mlperf-system-info-single-node-1.lstopo.xml +mlperf-system-info-single-node-1.json +``` + +That pairing is the whole contract. The `.lstopo.xml` files come from +`get-mlperf-single-node-system-info,_lstopo`, which parks the topology beside +the JSON with a matching stem for exactly this reason. Nodes are discovered +from what is on disk rather than from a node list, so one node in gives you a +single-node graph and N nodes give you a multi-node one, through the same code +path. + +A topology with no matching JSON still gets into the graph — it just carries no +processor or accelerator attributes, and a warning says so. + +## What it writes + +| File | Contents | +|------|----------| +| `infragraph.json` | The annotated graph: the merged `Infrastructure` plus the per-node sysinfo attached to each node's `cpu` and `xpu` components. This is the artifact to keep. | +| `infragraph.yaml` | The merged `Infrastructure` definition on its own, without annotations. | +| `dev-.yaml` | One per node: the raw `infragraph translate lstopo` output, kept as an intermediate so a bad merge can be traced back to the node that caused it. | +| `visuals/` | A self-contained HTML/JS bundle; open `visuals/index.html` in a browser. Suppressed by `_no_visualize`. | + +## Usage + +```bash +mlcr generate,infragraph --input_dir=/tmp/sysinfo --graph_name=my-cluster +``` + +Rebuild the graph but skip the HTML bundle: + +```bash +mlcr generate,infragraph,_no_visualize --input_dir=/tmp/sysinfo +``` + +Write the graph somewhere other than next to the inputs: + +```bash +mlcr generate,infragraph \ + --input_dir=/tmp/sysinfo \ + --out_dir_path=/tmp/graph \ + --out_file_name=cluster.json +``` + +## Parameters + +| Flag | Env var | Meaning | +|------|---------|---------| +| `--input_dir` | `MLC_INFRAGRAPH_INPUT_DIR_PATH` | Directory holding the per-node captures. Defaults to the current directory. | +| `--out_dir_path` | `MLC_INFRAGRAPH_OUT_DIR_PATH` | Where to write the graph and visuals. Defaults to the input directory. | +| `--out_file_name` | `MLC_INFRAGRAPH_FILE_NAME` | Name of the annotated graph JSON. Defaults to `infragraph.json`; the YAML takes the same stem. | +| `--graph_name` | `MLC_INFRAGRAPH_NAME` | Name recorded in the graph. Defaults to `single-node-system` or `multi-node-system` depending on how many nodes were found. | + +## Variations + +| Tag | Effect | +|-----|--------| +| `_no_visualize` | Skip the HTML visualizer bundle. The JSON and YAML are still produced. | + +## How the merge works + +Each node's topology becomes one infragraph *device*. Devices that are +structurally identical are stored once and instantiated per node, so a +homogeneous cluster yields one device definition rather than N copies of it. +Instances are named after each node's real hostname, read from the `HostName` +field lstopo records in its own XML — that is what puts node identity into +generated graph node names (`mlc2.0.cpu.0`) and lets each node be annotated +with its own sysinfo. Two nodes reporting the same hostname get suffixed +(`mlc2`, `mlc2-2`) rather than silently collapsing into one. + +No infrastructure-level edges are emitted. lstopo sees one host at a time, so +there is no observable inter-node fabric to infer; the merged graph is a set of +per-node subgraphs, not a fabric topology. + +## Requirements + +- **Python 3.10 or newer.** infragraph 3.x uses PEP 604 annotations at import + time, so on 3.9 it fails to import rather than failing to install. The script + checks the interpreter MLC selected and says so up front. If MLC picks an + older Python, pass `--adr.python.version_min=3.10` or clear the stale + `get,python3` cache entry. +- `lstopo` is **not** needed here — the topologies were captured on the nodes + themselves. Only the machine running the collection needs infragraph. diff --git a/script/generate-infragraph/meta.yaml b/script/generate-infragraph/meta.yaml new file mode 100644 index 000000000..cf84b1376 --- /dev/null +++ b/script/generate-infragraph/meta.yaml @@ -0,0 +1,60 @@ +alias: generate-infragraph +uid: 6e48fe6ca033f490 +automation_alias: script +automation_uid: 5b4e0237da074764 + +# Metadata +category: Platform information +tags: +- generate +- infragraph + +# Cache +cache: false + +# Environment +new_env_keys: +- MLC_INFRAGRAPH_FILE_PATH +- MLC_INFRAGRAPH_YAML_FILE_PATH +- MLC_INFRAGRAPH_VISUALS_DIR_PATH +- MLC_INFRAGRAPH_NODE_COUNT + +# Input mapping +input_mapping: + input_dir: MLC_INFRAGRAPH_INPUT_DIR_PATH + graph_name: MLC_INFRAGRAPH_NAME + out_dir_path: MLC_INFRAGRAPH_OUT_DIR_PATH + out_file_name: MLC_INFRAGRAPH_FILE_NAME + +default_env: + MLC_INFRAGRAPH_FILE_NAME: infragraph.json + +clean_files: +- tmp-run-env.out + +# Dependencies +deps: +- tags: detect,os +# infragraph >= 3.0 uses PEP 604 (`str | None`) annotations at import time, +# so it fails on 3.9 with a TypeError rather than a clean install error. +- tags: get,python + names: + - python + - python3 + version_min: '3.10' +- tags: get,generic-python-lib,_package.infragraph + names: + - infragraph + +# Variations +variations: + # Skip the HTML visualizer bundle; the graph JSON/YAML is still produced. + no_visualize: + env: + MLC_INFRAGRAPH_SKIP_VISUALIZE: 'True' + +# Output / debugging +print_env_at_the_end: + MLC_INFRAGRAPH_FILE_PATH: Path to the annotated infrastructure graph JSON. + MLC_INFRAGRAPH_YAML_FILE_PATH: Path to the merged infrastructure graph YAML. + MLC_INFRAGRAPH_VISUALS_DIR_PATH: Directory holding the generated infragraph visualizer files. diff --git a/script/generate-infragraph/run.sh b/script/generate-infragraph/run.sh new file mode 100644 index 000000000..9052b77e8 --- /dev/null +++ b/script/generate-infragraph/run.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +set -e + +VISUALS_DIR="${MLC_INFRAGRAPH_VISUALS_DIR_PATH}" +if [[ "${MLC_INFRAGRAPH_SKIP_VISUALIZE}" == "True" ]]; then + VISUALS_DIR="" +fi + +# infragraph is driven through its Python API rather than its console script: +# get,generic-python-lib installs it into the MLC-selected interpreter, whose +# bin directory is not necessarily on PATH. +"${MLC_PYTHON_BIN_WITH_PATH}" "${MLC_TMP_CURRENT_SCRIPT_PATH}/build_infragraph.py" \ + --input-dir "${MLC_INFRAGRAPH_INPUT_DIR_PATH}" \ + --output "${MLC_INFRAGRAPH_FILE_PATH}" \ + --output-yaml "${MLC_INFRAGRAPH_YAML_FILE_PATH}" \ + --name "${MLC_INFRAGRAPH_NAME}" \ + --visuals-dir "${VISUALS_DIR}" diff --git a/script/get-lstopo/meta.yaml b/script/get-lstopo/meta.yaml index 2d0b595c1..46eac8aca 100644 --- a/script/get-lstopo/meta.yaml +++ b/script/get-lstopo/meta.yaml @@ -15,6 +15,14 @@ category: lstopo topology automation new_env_keys: - MLC_LSTOPO_XML_FILE_PATH +# Input mapping +input_mapping: + out_dir_path: MLC_LSTOPO_OUT_DIR_PATH + out_file_name: MLC_LSTOPO_OUT_FILE_NAME + +default_env: + MLC_LSTOPO_OUT_FILE_NAME: topo.xml + clean_files: - tmp-run-env.out diff --git a/script/get-lstopo/run.sh b/script/get-lstopo/run.sh index 88ca94131..30ff94972 100644 --- a/script/get-lstopo/run.sh +++ b/script/get-lstopo/run.sh @@ -1,7 +1,19 @@ #!/bin/bash set -e -rm -f topo.xml -lstopo topo.xml -echo "MLC_LSTOPO_XML_FILE_PATH=$(pwd)/topo.xml" > tmp-run-env.out -echo "topo.xml written to $(pwd)/topo.xml" + +# Where the topology lands. Defaults keep the historical behaviour (topo.xml +# in the caller's cwd) so existing users of get,lstopo are unaffected; callers +# that need a predictable path -- e.g. get-mlperf-single-node-system-info, +# which parks the XML next to the sysinfo JSON so both can be copied back from +# a remote node together -- set these two. +OUT_DIR="${MLC_LSTOPO_OUT_DIR_PATH:-$(pwd)}" +OUT_FILE="${MLC_LSTOPO_OUT_FILE_NAME:-topo.xml}" + +mkdir -p "${OUT_DIR}" +OUT_PATH="${OUT_DIR}/${OUT_FILE}" + +rm -f "${OUT_PATH}" +lstopo "${OUT_PATH}" +echo "MLC_LSTOPO_XML_FILE_PATH=${OUT_PATH}" > tmp-run-env.out +echo "lstopo topology written to ${OUT_PATH}" diff --git a/script/get-mlperf-multi-node-system-info/README.md b/script/get-mlperf-multi-node-system-info/README.md index 3ad4fbfcf..ea82822ad 100644 --- a/script/get-mlperf-multi-node-system-info/README.md +++ b/script/get-mlperf-multi-node-system-info/README.md @@ -124,6 +124,8 @@ mlcr get-mlperf-multi-node-system-info - `exclude_current_node` - `inference_optional_nameplate` +- `infragraph` - `network` +- `no_visualize` - `power` - `redfish` diff --git a/script/get-mlperf-multi-node-system-info/customize.py b/script/get-mlperf-multi-node-system-info/customize.py index 02571ef36..dd258e6e5 100644 --- a/script/get-mlperf-multi-node-system-info/customize.py +++ b/script/get-mlperf-multi-node-system-info/customize.py @@ -119,6 +119,25 @@ def _parse_node(node_str): return user, host, port +_REMOTE_SINGLE_NODE_DIR = "/tmp/mlperf-system-info-single-node" + + +def _files_to_copy_back(node_id, collect_lstopo): + """Remote artifacts to pull back for one node. + + The lstopo XML shares the sysinfo JSON's stem by construction -- see + get-mlperf-single-node-system-info's preprocess() -- so its remote name is + predictable from the node id alone. A node running an older copy of the + automations repo will not produce it; rsync logs that miss and the run + continues, and generate-infragraph simply omits that node from the graph. + """ + stem = f"{_REMOTE_SINGLE_NODE_DIR}/mlperf-system-info-single-node-{node_id}" + files = [f"{stem}.json"] + if collect_lstopo: + files.append(f"{stem}.lstopo.xml") + return files + + def preprocess(i): env = i['env'] @@ -148,6 +167,14 @@ def preprocess(i): backend = env.get('MLC_ACCELERATOR_BACKEND', '') if backend in ('cuda', 'rocm', 'xpu', 'tpu'): rr_tags += f",_{backend}" + + # Under _infragraph each node also captures its hwloc topology. The + # tag is passed explicitly rather than relying on env inheritance, + # because the remote node resolves its own variations from the tag + # string it is given. + collect_lstopo = is_true(env.get('MLC_COLLECT_LSTOPO_TOPOLOGY', False)) + if collect_lstopo: + rr_tags += ",_lstopo" ssh_ids = [ s.strip() for s in env['MLC_MULTINODE_SYSTEM_SSH_IDS'].split(',') if s.strip()] @@ -167,11 +194,11 @@ def preprocess(i): 'run_cmd': rr_tags, 'mlc_run_cmd': f"mlcr {rr_tags}", 'node_id': actual_node_id, - 'out_dir_path': "/tmp/mlperf-system-info-single-node", + 'out_dir_path': _REMOTE_SINGLE_NODE_DIR, 'remote_host': host, 'remote_user': user, 'remote_port': port, - 'files_to_copy_back': [f"/tmp/mlperf-system-info-single-node/mlperf-system-info-single-node-{actual_node_id}.json"], + 'files_to_copy_back': _files_to_copy_back(actual_node_id, collect_lstopo), 'path_to_copy_back_files': env['MLC_MULTI_NODE_SYSTEM_INFO_DIR_PATH'], 'run_state': run_state, 'skip_ssh_key_file': env.get('MLC_SKIP_SSH_KEY_FILE', ''), diff --git a/script/get-mlperf-multi-node-system-info/info.md b/script/get-mlperf-multi-node-system-info/info.md index f207d1cec..00cedf0e0 100644 --- a/script/get-mlperf-multi-node-system-info/info.md +++ b/script/get-mlperf-multi-node-system-info/info.md @@ -359,6 +359,48 @@ Specify one of `_cuda`, `_rocm`, `_xpu`, or `_tpu` to match your hardware. If no | `_power` | Adds the power submission extra fields (`power_supply_quantity_and_rating_watts`, `power_supply_details`, `boot_firmware_version`, etc.) to the output as blank strings for manual entry. Stack with `_inference`. | | `_redfish` | Runs [`get-redfish-power-info`](../get-redfish-power-info/README.md) as a `prehook_dep` to capture live PSU data from a Redfish BMC/mockup endpoint. On its own, just produces a raw capture YAML in the output dir for reference. | | `_inference_optional_nameplate` | Produces the nameplate power YAML the MLPerf Inference submission_checker optionally accepts (see [Nameplate power YAML](#nameplate-power-yaml-_redfish_inference_optional_nameplate)). Stacked with `_redfish`, it's populated with real PSU data from the BMC; used **alone**, it writes the generic fill-in-the-blanks skeleton template instead — no BMC is contacted. | +| `_infragraph` | Captures an hwloc topology on every node alongside its sysinfo, then builds an infrastructure graph from the whole set (see [Infrastructure graph](#infrastructure-graph-_infragraph)). | +| `_no_visualize` | Only meaningful with `_infragraph`: skip the HTML visualizer bundle and produce just the graph JSON and YAML. | + +### Infrastructure graph (`_infragraph`) + +`_infragraph` adds a topology layer on top of the sysinfo collection. Each node +captures its own hwloc topology while it is already being probed — no second SSH +pass — and once every node has reported in, [`generate-infragraph`](../generate-infragraph/README.md) +runs as a `post_dep` and merges the lot into one +[infragraph](https://pypi.org/project/infragraph/) infrastructure graph, +annotated with each node's processor and accelerator details. + +```bash +mlcr get-mlperf-multi-node-system-info,_cuda,_infragraph \ + --ssh_ids=user@node1:22,user@node2:22 \ + --out_dir_path=/tmp/sysinfo \ + --system_name=my-cluster +``` + +Alongside the usual system-info output, `/tmp/sysinfo` then holds: + +| File | Contents | +|------|----------| +| `infragraph.json` | The annotated graph — merged topology plus each node's sysinfo attached to its `cpu` and `xpu` components. | +| `infragraph.yaml` | The merged `Infrastructure` definition without annotations. | +| `mlperf-system-info-single-node-.lstopo.xml` | Per-node hwloc topology, one per node. | +| `dev-mlperf-system-info-single-node-.yaml` | Per-node translated device definition (intermediate). | +| `visuals/index.html` | Interactive browser view of the graph. | + +The graph is named after `--system_name` when one is given. It works the same +way with one node as with many: run without `--ssh_ids` and you get a +single-node graph of the local machine. + +Two things this needs that the plain collection does not: + +- **`hwloc` on every node.** It is installed by the `get,lstopo` dependency + where a package manager is available. A node that cannot produce a topology + is left out of the graph with a warning rather than failing the run. +- **Python 3.10+ and `infragraph` on the machine running the collection.** The + remote nodes only need `lstopo`; the graph itself is built locally. + +Add `_no_visualize` to skip the HTML bundle. ### Example: inference submission with power fields diff --git a/script/get-mlperf-multi-node-system-info/meta.yaml b/script/get-mlperf-multi-node-system-info/meta.yaml index d32d8883a..bc34ee046 100644 --- a/script/get-mlperf-multi-node-system-info/meta.yaml +++ b/script/get-mlperf-multi-node-system-info/meta.yaml @@ -16,6 +16,7 @@ new_env_keys: - MLC_REMOTE_RUN_SSH_ID_COUNT - MLC_MULTI_NODE_SYSTEM_INFO_FILE_PATH - MLC_NAMEPLATE_POWER_YAML_FILE_PATH +- MLC_INFRAGRAPH_* # Input mapping input_mapping: @@ -85,13 +86,6 @@ prehook_deps: env: MLC_SINGLE_NODE_SYSTEM_INFO_DIR_PATH: <<>> MLC_SINGLE_NODE_SYSTEM_INFO_FILE_NAME: mlperf-system-info-single-node-0.json - # Two mutually exclusive get-redfish-power-info invocations, selected by - # whether _inference_optional_nameplate is also active. Only one of these - # two ever runs: _redfish + _inference_optional_nameplate together use the - # lean scope (PSU-only walk, no Thermal/Systems); _redfish alone uses the - # full general-purpose capture. If _inference_optional_nameplate is set - # WITHOUT _redfish, neither of these deps runs at all -- postprocess() - # writes the generic skeleton template instead (no BMC contact). - tags: get,redfish,power,info,_inference_optional_nameplate names: - get-redfish-power-info @@ -101,11 +95,6 @@ prehook_deps: MLC_MLPERF_INFERENCE_OPTIONAL_NAMEPLATE_ENABLED: - 'True' env: - # MLC_REDFISH_ENDPOINT/USERNAME/PASSWORD are NOT re-templated here: the - # template engine can't resolve <<>> when the destination key is the - # same name as the source (self-referential templates resolve to a - # literal string, not the value) -- these pass through via ordinary env - # inheritance instead, since both scripts use the identical var names. MLC_REDFISH_NAMEPLATE_OUTPUT_FILE: <<>>/redfish_nameplate_power.yaml MLC_REDFISH_SYSTEM_NAME: <<>> - tags: get,redfish,power,info,_full @@ -122,6 +111,17 @@ prehook_deps: # ordinary env inheritance, not self-referential templates. MLC_REDFISH_OUTPUT_FILE: <<>>/redfish_capture.yaml +post_deps: +- tags: generate,infragraph + names: + - generate-infragraph + enable_if_env: + MLC_MLPERF_INFRAGRAPH_ENABLED: + - 'True' + env: + MLC_INFRAGRAPH_INPUT_DIR_PATH: <<>> + MLC_INFRAGRAPH_NAME: <<>> + # Variations variations: cuda: @@ -179,8 +179,23 @@ variations: inference_optional_nameplate: env: MLC_MLPERF_INFERENCE_OPTIONAL_NAMEPLATE_ENABLED: 'True' + # Capture an hwloc topology per node alongside the sysinfo, then build the + # infrastructure graph from the whole set once every node has reported in. + # MLC_COLLECT_LSTOPO_TOPOLOGY is inherited by the local single-node dep; the + # remote nodes get it as an explicit _lstopo tag in preprocess(). + infragraph: + env: + MLC_MLPERF_INFRAGRAPH_ENABLED: 'True' + MLC_COLLECT_LSTOPO_TOPOLOGY: 'True' + # Skip the HTML visualizer bundle; the graph JSON/YAML is still produced. + no_visualize: + env: + MLC_INFRAGRAPH_SKIP_VISUALIZE: 'True' # Output / debugging print_env_at_the_end: + MLC_INFRAGRAPH_FILE_PATH: Path to the annotated infrastructure graph JSON (with _infragraph). + MLC_INFRAGRAPH_YAML_FILE_PATH: Path to the merged infrastructure graph YAML (with _infragraph). + MLC_INFRAGRAPH_VISUALS_DIR_PATH: Directory holding the generated infragraph visualizer files. MLC_MULTI_NODE_SYSTEM_INFO_FILE_PATH: Path to the generated multi-node system info file. MLC_NAMEPLATE_POWER_YAML_FILE_PATH: Path to the generated nameplate power YAML file (populated from Redfish with _redfish,_inference_optional_nameplate; a generic skeleton template with _inference_optional_nameplate alone). diff --git a/script/get-mlperf-single-node-system-info/customize.py b/script/get-mlperf-single-node-system-info/customize.py index f14f498f0..e6c134b3d 100644 --- a/script/get-mlperf-single-node-system-info/customize.py +++ b/script/get-mlperf-single-node-system-info/customize.py @@ -1,4 +1,5 @@ from mlc import utils +from utils import is_true import os import json import subprocess @@ -19,6 +20,22 @@ def preprocess(i): if not os.path.exists(env['MLC_SINGLE_NODE_SYSTEM_INFO_DIR_PATH']): os.makedirs(env['MLC_SINGLE_NODE_SYSTEM_INFO_DIR_PATH'], exist_ok=True) + # With _lstopo, get,lstopo runs as a prehook dep and parks this node's + # topology beside the sysinfo JSON, sharing its stem: + # mlperf-system-info-single-node-3.json + # mlperf-system-info-single-node-3.lstopo.xml + # The shared stem is the contract generate-infragraph pairs on, and it is + # what lets get-mlperf-multi-node-system-info predict the remote filename + # it has to copy back without a second round trip. Both keys are set only + # when the capture is enabled, so a plain run exports nothing about a + # topology it never took. + if is_true(env.get('MLC_COLLECT_LSTOPO_TOPOLOGY', False)): + info_path = env['MLC_SINGLE_NODE_SYSTEM_INFO_FILE_PATH'] + xml_path = os.path.splitext(info_path)[0] + '.lstopo.xml' + env['MLC_SINGLE_NODE_LSTOPO_XML_FILE_NAME'] = os.path.basename( + xml_path) + env['MLC_SINGLE_NODE_LSTOPO_XML_FILE_PATH'] = xml_path + CMD = f"""{env['MLC_PYTHON_BIN_WITH_PATH']} {env['MLC_TMP_CURRENT_SCRIPT_PATH']}/parse.py --output {env['MLC_SINGLE_NODE_SYSTEM_INFO_FILE_PATH']}""" env['MLC_RUN_CMD'] = CMD @@ -40,6 +57,17 @@ def postprocess(i): # produced it (traceability, since mlc-scripts has no tagged release). output_path = env.get('MLC_SINGLE_NODE_SYSTEM_INFO_FILE_PATH', '') repo_path = env.get('MLC_TMP_CURRENT_SCRIPT_REPO_PATH', '') + + # Only advertise the topology path if the capture actually happened -- + # a dangling path reads as "there is a topology here" to callers. + xml_path = env.get('MLC_SINGLE_NODE_LSTOPO_XML_FILE_PATH', '') + if xml_path and not os.path.isfile(xml_path): + automation.logger.warning( + f"_lstopo was requested but no topology was written to " + f"{xml_path}; this node will have no entry in the " + f"infrastructure graph.") + del env['MLC_SINGLE_NODE_LSTOPO_XML_FILE_PATH'] + if output_path and os.path.exists(output_path): try: from mlc.utils import get_repo_version diff --git a/script/get-mlperf-single-node-system-info/meta.yaml b/script/get-mlperf-single-node-system-info/meta.yaml index c79777ba6..356abbc1d 100644 --- a/script/get-mlperf-single-node-system-info/meta.yaml +++ b/script/get-mlperf-single-node-system-info/meta.yaml @@ -19,6 +19,8 @@ new_env_keys: - MLC_SINGLE_NODE_SYSTEM_INFO_FILE_PATH - MLC_SINGLE_NODE_SYSTEM_INFO_DIR_PATH - MLC_SINGLE_NODE_SYSTEM_INFO_FILE_NAME +- MLC_SINGLE_NODE_LSTOPO_XML_FILE_PATH +- MLC_SINGLE_NODE_LSTOPO_XML_FILE_NAME # Input mapping input_mapping: @@ -68,8 +70,29 @@ deps: - platform-details - tags: detect,host,system,details +# The lstopo capture has to sit next to the sysinfo JSON, and that path is only +# resolved in preprocess(), so this is a prehook dep rather than a plain dep. +prehook_deps: +- tags: get,lstopo + names: + - lstopo + enable_if_env: + MLC_COLLECT_LSTOPO_TOPOLOGY: + - 'True' + env: + MLC_LSTOPO_OUT_DIR_PATH: <<>> + MLC_LSTOPO_OUT_FILE_NAME: <<>> + # Variations variations: + # Capture this node's hwloc topology alongside the sysinfo JSON. Used by + # get-mlperf-multi-node-system-info,_infragraph, which needs one lstopo XML + # per node to build the infrastructure graph -- collecting it here means the + # existing sysinfo fan-out carries the topology back too, with no second SSH + # pass. + lstopo: + env: + MLC_COLLECT_LSTOPO_TOPOLOGY: 'True' cuda: group: accelerator-backend env: diff --git a/script/get-phoronix-test-suite/customize.py b/script/get-phoronix-test-suite/customize.py index 83a684085..af0fc7441 100644 --- a/script/get-phoronix-test-suite/customize.py +++ b/script/get-phoronix-test-suite/customize.py @@ -42,7 +42,8 @@ def preprocess(i): # Reuse a prior no-sudo install in this prefix if present. bin_path = _resolve_launcher(prefix) if not bin_path: - # run.sh will perform the no-sudo portable install into the prefix. + # run.sh will perform the no-sudo portable install into the + # prefix. env['MLC_PHORONIX_DO_PORTABLE_INSTALL'] = 'yes' if bin_path: @@ -79,7 +80,8 @@ def postprocess(i): bin_path = '/usr/bin/phoronix-test-suite' if not bin_path: - return {'return': 1, 'error': 'phoronix-test-suite not found after installation'} + return {'return': 1, + 'error': 'phoronix-test-suite not found after installation'} env['MLC_PHORONIX_TEST_SUITE_BIN_WITH_PATH'] = bin_path env['MLC_PHORONIX_INSTALLED_PATH'] = os.path.dirname(bin_path) diff --git a/script/get-tpu-devices/customize.py b/script/get-tpu-devices/customize.py index 7958a02d3..31fbc2a6f 100644 --- a/script/get-tpu-devices/customize.py +++ b/script/get-tpu-devices/customize.py @@ -190,5 +190,3 @@ def _tpu_env_value(tpu_env, key): """Extract KEY from a tpu-env blob of lines like: KEY: 'value'.""" m = re.search(rf"^{key}:\s*'?([^'\n]*?)'?\s*$", tpu_env, re.M) return m.group(1).strip() if m else '' - - diff --git a/script/get-tpu-devices/detect.py b/script/get-tpu-devices/detect.py index ce592c51a..5625a9111 100644 --- a/script/get-tpu-devices/detect.py +++ b/script/get-tpu-devices/detect.py @@ -93,7 +93,8 @@ def get_tpu_info(sysfs_pci=SYSFS_PCI): chips.setdefault(base_addr, (device_id, dev_path)) if not chips: - raise RuntimeError(f"no Google TPU PCI devices found under {sysfs_pci}") + raise RuntimeError( + f"no Google TPU PCI devices found under {sysfs_pci}") libtpu_version = _libtpu_version() diff --git a/script/run-apptainer-container/customize.py b/script/run-apptainer-container/customize.py index 4db6eb294..a0b22d6ad 100644 --- a/script/run-apptainer-container/customize.py +++ b/script/run-apptainer-container/customize.py @@ -110,7 +110,8 @@ def postprocess(i): repo_name = os.path.basename(env['MLC_REPO_PATH']) run_opts += f' --env MLC_REPOS=/opt/mlc_repo/{repo_name}' elif is_true(env.get('MLC_APPTAINER_HOST_MLC_REPOS', '')): - # Host repos were registered under /opt/mlc_host_repos at build time. + # Host repos were registered under /opt/mlc_host_repos at build + # time. run_opts += ' --env MLC_REPOS=/opt/mlc_host_repos' else: run_opts += ' --env MLC_REPOS=/tmp/mlc-repos' @@ -129,7 +130,8 @@ def postprocess(i): bind_mounts = [bind_mounts] for mount in bind_mounts: if mount: - # Apptainer (unlike Docker) does not auto-create missing bind sources. + # Apptainer (unlike Docker) does not auto-create missing bind + # sources. bind_src = mount.split(':', 1)[0] if not os.path.exists(bind_src): logger.info( diff --git a/script/test-profiler-uprof/customize.py b/script/test-profiler-uprof/customize.py index 804078ab6..cf0ec1da4 100644 --- a/script/test-profiler-uprof/customize.py +++ b/script/test-profiler-uprof/customize.py @@ -5,7 +5,8 @@ def preprocess(i): env = i['env'] if env.get('MLC_UPROF_BIN_WITH_PATH', '') == '': - return {'return': 1, 'error': 'MLC_UPROF_BIN_WITH_PATH not set; get,profiler,uprof must run first'} + return { + 'return': 1, 'error': 'MLC_UPROF_BIN_WITH_PATH not set; get,profiler,uprof must run first'} return {'return': 0} diff --git a/script/test-tool-perf/customize.py b/script/test-tool-perf/customize.py index f4c24d1c2..d83515b5c 100644 --- a/script/test-tool-perf/customize.py +++ b/script/test-tool-perf/customize.py @@ -5,7 +5,8 @@ def preprocess(i): env = i['env'] if env.get('MLC_PERF_BIN_WITH_PATH', '') == '': - return {'return': 1, 'error': 'MLC_PERF_BIN_WITH_PATH not set; get,tool,perf must run first'} + return { + 'return': 1, 'error': 'MLC_PERF_BIN_WITH_PATH not set; get,tool,perf must run first'} return {'return': 0}