From 59e06eda441a6439c993ebb96f4090522e3c9b7c Mon Sep 17 00:00:00 2001 From: ishitag Date: Wed, 18 Nov 2026 14:36:13 -0700 Subject: [PATCH 1/3] Skip overlay mounting if overlay is not available in a test and continue with running the test Co-authored-by: Cursor --- ...rofile_detailed_report_ve2_board_runner.py | 68 ++++++++++++------- 1 file changed, 44 insertions(+), 24 deletions(-) diff --git a/src/mldebug/scripts/vaiprofile_detailed_report_ve2_board_runner.py b/src/mldebug/scripts/vaiprofile_detailed_report_ve2_board_runner.py index d5ffa15..db39318 100644 --- a/src/mldebug/scripts/vaiprofile_detailed_report_ve2_board_runner.py +++ b/src/mldebug/scripts/vaiprofile_detailed_report_ve2_board_runner.py @@ -29,8 +29,10 @@ For each test, from its own folder, the overlay is reloaded first: fpgautil -R fpgautil -b ./overlay/x_plus_ml.pdi -o ./overlay/x_plus_ml.dtbo -If /overlay/ lacks either file, or either command fails, the test is an -ERROR and none of its runs are done. +If /overlay/ or either file is missing, a warning is printed, fpgautil is +not run and the test's runs still go ahead. If fpgautil -R fails, a warning is +printed and fpgautil -b still runs. If fpgautil -b fails, the test is an ERROR +and none of its runs are done. Each test is then run once from its own folder: python ve2.py --input_model onnx_model/.onnx --analyzer_profiling True @@ -658,15 +660,25 @@ def ensure_vai_packages(test_path, test_dirs, single, dry_run, timeout): return None +def missing_overlay(test_dir): + """Return a description of what is missing from /overlay/, or None if OVERLAY_FILES are all there.""" + overlay_dir = os.path.dirname(OVERLAY_FILES[0]) + if not os.path.isdir(os.path.join(test_dir, overlay_dir)): + return '%s/ not found' % overlay_dir + missing = [f for f in OVERLAY_FILES if not os.path.isfile(os.path.join(test_dir, f))] + return '%s not found' % ' and '.join(missing) if missing else None + + def load_overlay(test_dir, timeout): - """Run FPGA_CMDS from test_dir, logged to /fpgautil.log. Return an error or None.""" + """Run FPGA_CMDS from test_dir, logged to /fpgautil.log. + + Return (warning or None, error or None): fpgautil -R failing is a warning, fpgautil -b failing is an error. + """ log_path = os.path.join(test_dir, FPGA_LOG) open(log_path, 'w').close() - for cmd in FPGA_CMDS: - err = run_logged(cmd, test_dir, log_path, timeout) - if err: - return err - return None + reset_cmd, load_cmd = FPGA_CMDS + warning = run_logged(reset_cmd, test_dir, log_path, timeout) + return warning, run_logged(load_cmd, test_dir, log_path, timeout) def run_one_test(name, test_dir, model, tag, test_runner, profiling, args): @@ -691,13 +703,13 @@ def run_one_test(name, test_dir, model, tag, test_runner, profiling, args): return row if ops: cmd += ['--vaiml_custom_ops', ops] - missing = [f for f in OVERLAY_FILES if not os.path.isfile(os.path.join(test_dir, f))] - if missing: - row['status'] = 'ERROR (%s not found)' % ' and '.join(missing) - print('ERROR %s: %s not found; no runs done' % (tag, ' and '.join(missing))) - return row + overlay_missing = missing_overlay(test_dir) + if overlay_missing: + msg = '%s; fpgautil skipped' % overlay_missing + row['note'] = msg + print('WARNING %s: %s' % (tag, msg)) if profiling and not control_instrumentation_found(test_dir, cfg): - row['note'] = CI_WARNING + row['note'] = '; '.join(n for n in (row.get('note'), CI_WARNING) if n) print('WARNING %s: %s' % (tag, CI_WARNING)) base_cfg = with_control_instrumentation(cfg) if profiling else None if profiling: @@ -705,8 +717,11 @@ def run_one_test(name, test_dir, model, tag, test_runner, profiling, args): if args.dry_run: print(' cwd: %s' % test_dir) - for fcmd in FPGA_CMDS: - print(' %s >> %s' % (subprocess.list2cmdline(fcmd), FPGA_LOG)) + if overlay_missing: + print(' (fpgautil skipped: %s)' % overlay_missing) + else: + for fcmd in FPGA_CMDS: + print(' %s >> %s' % (subprocess.list2cmdline(fcmd), FPGA_LOG)) print(' %s > %s' % (subprocess.list2cmdline(cmd), BASE_LOG)) if has_control_instrumentation(cfg): print(' (Base Run: control_instrumentation removed from %s; restored only if the Base Run ' @@ -727,14 +742,19 @@ def run_one_test(name, test_dir, model, tag, test_runner, profiling, args): row['status'] = 'DRY_RUN' return row - print('%s: Reloading Overlay (fpgautil -R, fpgautil -b) ...' % tag) - sys.stdout.flush() - err = load_overlay(test_dir, args.timeout) - if err: - row['status'] = 'ERROR (%s)' % err - row.pop('profile', None) - print('ERROR %s: %s; no runs done' % (tag, err)) - return row + if not overlay_missing: + print('%s: Reloading Overlay (fpgautil -R, fpgautil -b) ...' % tag) + sys.stdout.flush() + warning, err = load_overlay(test_dir, args.timeout) + if warning: + msg = '%s; continuing' % warning + row['note'] = '; '.join(n for n in (row.get('note'), msg) if n) + print('WARNING %s: %s' % (tag, msg)) + if err: + row['status'] = 'ERROR (%s)' % err + row.pop('profile', None) + print('ERROR %s: %s; no runs done' % (tag, err)) + return row print('%s: Running Inference ...' % tag) sys.stdout.flush() status, rc, secs, note = base_run(cmd, test_dir, cfg, args.timeout, tag) From ffc1dd1736d13e0d2475a9bb48fb640ab583fe4f Mon Sep 17 00:00:00 2001 From: ishitag Date: Wed, 18 Nov 2026 15:08:32 -0700 Subject: [PATCH 2/3] Add Apache License 2.0 and skip setting debug log level for FlexmlRT Co-authored-by: Cursor --- .../vaiprofile_detailed_report_ve2_board_runner.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/mldebug/scripts/vaiprofile_detailed_report_ve2_board_runner.py b/src/mldebug/scripts/vaiprofile_detailed_report_ve2_board_runner.py index db39318..bcb5e8f 100644 --- a/src/mldebug/scripts/vaiprofile_detailed_report_ve2_board_runner.py +++ b/src/mldebug/scripts/vaiprofile_detailed_report_ve2_board_runner.py @@ -1,4 +1,7 @@ #!/usr/bin/env python3 +# SPDX-License-Identifier: Apache-2.0 +# Copyright (C) 2026 Advanced Micro Devices, Inc. All rights reserved + """Run VAIML tests on a PetaLinux board with the Detailed Profile Report flow (on by default; --no-detailed-profiling turns it off). @@ -15,8 +18,8 @@ Setup, done once (the pip3 commands are skipped with --skip-setup): pip3 config set global.trusted-host "..."; pip3 install torch==2.5.1 onnx pandas torchvision==0.20.1 ... - LD_LIBRARY_PATH, XRT_AIARM, XLNX_ENABLE_CACHE, ENABLE_ML_DEBUG, QEMU_TEST, - DEBUG_VAIML_PARTITION and FLEXMLRT_LOG_LEVEL are set for every run. + LD_LIBRARY_PATH, XRT_AIARM, XLNX_ENABLE_CACHE, ENABLE_ML_DEBUG, QEMU_TEST and + DEBUG_VAIML_PARTITION are set for every run. Then, also once and even with --skip-setup, pip3 list | grep -iE 'flexmlrt|voe|onnxruntime[-_]vitisai' checks the VAI packages (pip may list onnxruntime-vitisai as onnxruntime_vitisai). @@ -126,7 +129,7 @@ FPGA_LOG = 'fpgautil.log' LD_PATHS = ('/usr/lib/python3.12/site-packages/flexmlrt/lib/', '/usr/lib/python3.12/site-packages/voe/lib/') ENV = (('XRT_AIARM', 'true'), ('XLNX_ENABLE_CACHE', '0'), ('ENABLE_ML_DEBUG', '0'), ('QEMU_TEST', '0'), - ('DEBUG_VAIML_PARTITION', '2'), ('FLEXMLRT_LOG_LEVEL', 'debug')) + ('DEBUG_VAIML_PARTITION', '2')) PROFILE_RUNS = ( ('A', 'detailed_core_shim_read_ch_0', {'interface_tile': 'detailed_ddr_read_bandwidth:0', 'aie_tile': 'compute_io_bound'}), From 8664744078df3d8898d9ef9dafa3f90996c7c8d7 Mon Sep 17 00:00:00 2001 From: ishitag Date: Wed, 18 Nov 2026 15:52:01 -0700 Subject: [PATCH 3/3] Rename runner as vaiprofile_detailed_report_runner.py Co-authored-by: Cursor --- ...t_ve2_board_runner.py => vaiprofile_detailed_report_runner.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/mldebug/scripts/{vaiprofile_detailed_report_ve2_board_runner.py => vaiprofile_detailed_report_runner.py} (100%) diff --git a/src/mldebug/scripts/vaiprofile_detailed_report_ve2_board_runner.py b/src/mldebug/scripts/vaiprofile_detailed_report_runner.py similarity index 100% rename from src/mldebug/scripts/vaiprofile_detailed_report_ve2_board_runner.py rename to src/mldebug/scripts/vaiprofile_detailed_report_runner.py