From 4455b25b5da89f02ea34778d8d15d0d90bf81749 Mon Sep 17 00:00:00 2001 From: Yang Wang Date: Fri, 8 May 2026 15:45:27 -0400 Subject: [PATCH 1/6] fix crash of attah/detach on gfx1151 by skiping pc-sampling requried tests and forcing sdk output to csv --- .../tests/test_profile_general.py | 42 +++++++++++++------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/projects/rocprofiler-compute/tests/test_profile_general.py b/projects/rocprofiler-compute/tests/test_profile_general.py index 534bf35ac12..6c982d5c079 100644 --- a/projects/rocprofiler-compute/tests/test_profile_general.py +++ b/projects/rocprofiler-compute/tests/test_profile_general.py @@ -57,6 +57,8 @@ DEFAULT_REL_DIFF = 50 MAX_REOCCURING_COUNT = 28 +LIVE_ATTACH_OUTPUT_OPTIONS = ["--format-rocprof-output", "csv"] + CSVS = sorted([ "sysinfo.csv", ]) @@ -588,6 +590,15 @@ def is_rdna35_halo_soc(): return soc == "RDNA35_HALO" +def skip_unsupported_pc_sampling_soc(is_stochastic=False): + unsupported_socs = {"MI100", "RDNA35_HALO"} + if is_stochastic: + unsupported_socs.add("MI200") + + if soc in unsupported_socs: + pytest.skip(f"PC sampling is not supported on {soc}") + + # -- # Start of profiling tests # -- @@ -2031,7 +2042,13 @@ def test_comprehensive_error_paths(): @pytest.mark.live_attach_detach def test_live_attach_detach_block(binary_handler_profile_rocprof_compute): - options = ["--block", "3.1.1", "4.1.1", "5.1.1"] + options = [ + "--block", + "3.1.1", + "4.1.1", + "5.1.1", + *LIVE_ATTACH_OUTPUT_OPTIONS, + ] workload_dir = common.get_output_dir() # TODO: temp fix for sdk defautly disable attach/detach, @@ -2086,7 +2103,7 @@ def test_live_attach_detach_block(binary_handler_profile_rocprof_compute): ) @pytest.mark.live_attach_detach def test_live_attach_detach_block_thread_sleep(binary_handler_profile_rocprof_compute): - options = ["--block", "3.1.1", "4.1.1", "5.1.1"] + options = ["--block", "3.1.1", "4.1.1", "5.1.1", *LIVE_ATTACH_OUTPUT_OPTIONS] workload_dir = common.get_output_dir() # TODO: temp fix for sdk defautly disable attach/detach, @@ -2151,7 +2168,7 @@ def test_live_attach_detach_block_thread_sleep(binary_handler_profile_rocprof_co def test_live_attach_detach_singlepass_launch_stats( binary_handler_profile_rocprof_compute, ): - options = ["--set", "launch_stats"] + options = ["--set", "launch_stats", *LIVE_ATTACH_OUTPUT_OPTIONS] workload_dir = common.get_output_dir() # TODO: temp fix for sdk defautly disable attach/detach, @@ -2205,14 +2222,13 @@ def test_live_attach_detach_singlepass_launch_stats( # Check that launch-stat sets were applied config_file = f"{workload_dir}/profiling_config.yaml" for tag in [ - "7.1.0", - "7.1.1", - "7.1.2", - "7.1.5", - "7.1.6", - "7.1.7", - "7.1.8", - "7.1.9", + "7.2.0", + "7.2.1", + "7.3.0", + "7.2.2", + "7.2.3", + "7.2.4", + "7.2.5", ]: assert common.check_file_pattern(f"- {tag}", config_file) @@ -2223,7 +2239,9 @@ def test_live_attach_detach_singlepass_launch_stats( def test_live_attach_detach_pc_sampling( binary_handler_profile_rocprof_compute, ): - options = ["-b", "21"] + skip_unsupported_pc_sampling_soc(is_stochastic=True) + + options = ["-b", "21", *LIVE_ATTACH_OUTPUT_OPTIONS] workload_dir = common.get_output_dir() # TODO: temp fix for sdk defautly disable attach/detach, From f2c2595ef64482ce7ab6721ec910765620e4a0a5 Mon Sep 17 00:00:00 2001 From: Yang Wang Date: Mon, 11 May 2026 13:30:55 -0400 Subject: [PATCH 2/6] remove csv conversion for all test but any one more sigle test in csv --- .../tests/test_profile_general.py | 79 +++++++++++++++---- 1 file changed, 65 insertions(+), 14 deletions(-) diff --git a/projects/rocprofiler-compute/tests/test_profile_general.py b/projects/rocprofiler-compute/tests/test_profile_general.py index 6c982d5c079..08c1146a67f 100644 --- a/projects/rocprofiler-compute/tests/test_profile_general.py +++ b/projects/rocprofiler-compute/tests/test_profile_general.py @@ -57,8 +57,6 @@ DEFAULT_REL_DIFF = 50 MAX_REOCCURING_COUNT = 28 -LIVE_ATTACH_OUTPUT_OPTIONS = ["--format-rocprof-output", "csv"] - CSVS = sorted([ "sysinfo.csv", ]) @@ -2041,13 +2039,14 @@ def test_comprehensive_error_paths(): @pytest.mark.live_attach_detach -def test_live_attach_detach_block(binary_handler_profile_rocprof_compute): +def test_live_attach_detach_block_csv(binary_handler_profile_rocprof_compute): options = [ "--block", "3.1.1", "4.1.1", "5.1.1", - *LIVE_ATTACH_OUTPUT_OPTIONS, + "--format-rocprof-output", + "csv", ] workload_dir = common.get_output_dir() @@ -2097,13 +2096,64 @@ def test_live_attach_detach_block(binary_handler_profile_rocprof_compute): common.clean_output_dir(config["cleanup"], workload_dir) +@pytest.mark.live_attach_detach +def test_live_attach_detach_block(binary_handler_profile_rocprof_compute): + options = ["--block", "3.1.1", "4.1.1", "5.1.1"] + workload_dir = common.get_output_dir() + + # TODO: temp fix for sdk defautly disable attach/detach, + # remove after it sets default to enable + env = os.environ.copy() + env["ROCP_TOOL_ATTACH"] = "1" + + process_workload = None + + try: + # Start workload + process_workload = subprocess.Popen(config["app_hip_dynamic_shared"], env=env) + time.sleep(5) # Give workload time to start + + attach_detach = { + "attach_pid": process_workload.pid, + "attach-duration-msec": attach_detach_interval_msec_no_delay, + } + + # Run profiler (might fail / timeout / throw) + binary_handler_profile_rocprof_compute( + config, + workload_dir, + options, + check_success=True, + roof=False, + app_name="app_hip_dynamic_shared", + attach_detach_para=attach_detach, + ) + + finally: + if process_workload and process_workload.poll() is None: + print(f"[finally] killing workload pid={process_workload.pid}") + process_workload.kill() + process_workload.wait() + # Clean up any stale rocprof-attach processes to prevent interference + # with subsequent tests. + subprocess.run( + ["pkill", "-9", "-f", "rocprof-attach"], + capture_output=True, + ) + + # Validate results + file_dict = common.check_csv_files(workload_dir, 1, num_kernels) + validate(inspect.stack()[0][3], workload_dir, file_dict) + common.clean_output_dir(config["cleanup"], workload_dir) + + @pytest.mark.skip( reason="Temporarily disabled: \ waiting for SDK fix for no outputfile with thread sleeping" ) @pytest.mark.live_attach_detach def test_live_attach_detach_block_thread_sleep(binary_handler_profile_rocprof_compute): - options = ["--block", "3.1.1", "4.1.1", "5.1.1", *LIVE_ATTACH_OUTPUT_OPTIONS] + options = ["--block", "3.1.1", "4.1.1", "5.1.1"] workload_dir = common.get_output_dir() # TODO: temp fix for sdk defautly disable attach/detach, @@ -2168,7 +2218,7 @@ def test_live_attach_detach_block_thread_sleep(binary_handler_profile_rocprof_co def test_live_attach_detach_singlepass_launch_stats( binary_handler_profile_rocprof_compute, ): - options = ["--set", "launch_stats", *LIVE_ATTACH_OUTPUT_OPTIONS] + options = ["--set", "launch_stats"] workload_dir = common.get_output_dir() # TODO: temp fix for sdk defautly disable attach/detach, @@ -2222,13 +2272,14 @@ def test_live_attach_detach_singlepass_launch_stats( # Check that launch-stat sets were applied config_file = f"{workload_dir}/profiling_config.yaml" for tag in [ - "7.2.0", - "7.2.1", - "7.3.0", - "7.2.2", - "7.2.3", - "7.2.4", - "7.2.5", + "7.1.0", + "7.1.1", + "7.1.2", + "7.1.5", + "7.1.6", + "7.1.7", + "7.1.8", + "7.1.9", ]: assert common.check_file_pattern(f"- {tag}", config_file) @@ -2241,7 +2292,7 @@ def test_live_attach_detach_pc_sampling( ): skip_unsupported_pc_sampling_soc(is_stochastic=True) - options = ["-b", "21", *LIVE_ATTACH_OUTPUT_OPTIONS] + options = ["-b", "21"] workload_dir = common.get_output_dir() # TODO: temp fix for sdk defautly disable attach/detach, From a35ccb5bf9f6a4667d69a6618497f903649de50a Mon Sep 17 00:00:00 2001 From: Yang Wang Date: Mon, 11 May 2026 14:55:51 -0400 Subject: [PATCH 3/6] remove duplicated csv test function --- .../tests/test_profile_general.py | 63 +------------------ 1 file changed, 3 insertions(+), 60 deletions(-) diff --git a/projects/rocprofiler-compute/tests/test_profile_general.py b/projects/rocprofiler-compute/tests/test_profile_general.py index 08c1146a67f..49a60cb9f34 100644 --- a/projects/rocprofiler-compute/tests/test_profile_general.py +++ b/projects/rocprofiler-compute/tests/test_profile_general.py @@ -2039,66 +2039,9 @@ def test_comprehensive_error_paths(): @pytest.mark.live_attach_detach -def test_live_attach_detach_block_csv(binary_handler_profile_rocprof_compute): - options = [ - "--block", - "3.1.1", - "4.1.1", - "5.1.1", - "--format-rocprof-output", - "csv", - ] - workload_dir = common.get_output_dir() - - # TODO: temp fix for sdk defautly disable attach/detach, - # remove after it sets default to enable - env = os.environ.copy() - env["ROCP_TOOL_ATTACH"] = "1" - - process_workload = None - - try: - # Start workload - process_workload = subprocess.Popen(config["app_hip_dynamic_shared"], env=env) - time.sleep(5) # Give workload time to start - - attach_detach = { - "attach_pid": process_workload.pid, - "attach-duration-msec": attach_detach_interval_msec_no_delay, - } - - # Run profiler (might fail / timeout / throw) - binary_handler_profile_rocprof_compute( - config, - workload_dir, - options, - check_success=True, - roof=False, - app_name="app_hip_dynamic_shared", - attach_detach_para=attach_detach, - ) - - finally: - if process_workload and process_workload.poll() is None: - print(f"[finally] killing workload pid={process_workload.pid}") - process_workload.kill() - process_workload.wait() - # Clean up any stale rocprof-attach processes to prevent interference - # with subsequent tests. - subprocess.run( - ["pkill", "-9", "-f", "rocprof-attach"], - capture_output=True, - ) - - # Validate results - file_dict = common.check_csv_files(workload_dir, 1, num_kernels) - validate(inspect.stack()[0][3], workload_dir, file_dict) - common.clean_output_dir(config["cleanup"], workload_dir) - - -@pytest.mark.live_attach_detach -def test_live_attach_detach_block(binary_handler_profile_rocprof_compute): - options = ["--block", "3.1.1", "4.1.1", "5.1.1"] +@pytest.mark.parametrize("profile_format", ["rocpd", "csv"]) +def test_live_attach_detach_block(binary_handler_profile_rocprof_compute, profile_format): + options = ["--block", "3.1.1", "4.1.1", "5.1.1","--format-rocprof-output", profile_format] workload_dir = common.get_output_dir() # TODO: temp fix for sdk defautly disable attach/detach, From dada461618416c4f427aa9977f974cda71d04eca Mon Sep 17 00:00:00 2001 From: Yang Wang Date: Mon, 11 May 2026 15:16:25 -0400 Subject: [PATCH 4/6] remove deupication of skip_unsupported_pc_sampling_soc --- .../rocprofiler-compute/tests/test_profile_general.py | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/projects/rocprofiler-compute/tests/test_profile_general.py b/projects/rocprofiler-compute/tests/test_profile_general.py index 49a60cb9f34..50e3d84a8c4 100644 --- a/projects/rocprofiler-compute/tests/test_profile_general.py +++ b/projects/rocprofiler-compute/tests/test_profile_general.py @@ -18,6 +18,7 @@ import pytest import yaml from scipy.stats import zscore +from tests.test_pc_sampling import skip_unsupported_pc_sampling_soc # Runtime config options config = {} @@ -588,15 +589,6 @@ def is_rdna35_halo_soc(): return soc == "RDNA35_HALO" -def skip_unsupported_pc_sampling_soc(is_stochastic=False): - unsupported_socs = {"MI100", "RDNA35_HALO"} - if is_stochastic: - unsupported_socs.add("MI200") - - if soc in unsupported_socs: - pytest.skip(f"PC sampling is not supported on {soc}") - - # -- # Start of profiling tests # -- From 04ec9add6e4bb56cbbc4547a5a63b944f3a9a578 Mon Sep 17 00:00:00 2001 From: Yang Wang Date: Mon, 11 May 2026 15:16:25 -0400 Subject: [PATCH 5/6] remove deupication of skip_unsupported_pc_sampling_soc --- projects/rocprofiler-compute/tests/common.py | 13 ++++++++++++ .../tests/test_pc_sampling.py | 21 ++++++------------- .../tests/test_profile_general.py | 2 +- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/projects/rocprofiler-compute/tests/common.py b/projects/rocprofiler-compute/tests/common.py index 66cb38cf8e8..37ef5157ce3 100644 --- a/projects/rocprofiler-compute/tests/common.py +++ b/projects/rocprofiler-compute/tests/common.py @@ -10,6 +10,7 @@ from pathlib import Path import pandas as pd +import pytest ROOT = os.path.dirname(os.path.dirname(__file__)) src_candidate = os.path.join(ROOT, "src") @@ -255,3 +256,15 @@ def gpu_soc(): return "", "" model = list(SUPPORTED_ARCHS[arch].keys())[0].upper() return arch, model + + +def skip_unsupported_pc_sampling_soc(is_stochastic=False): + """Skip PC-sampling tests on SoCs that do not support the selected mode.""" + _, soc = gpu_soc() + + unsupported_socs = {"MI100", "RDNA35_HALO"} + if is_stochastic: + unsupported_socs.add("MI200") + + if soc in unsupported_socs: + pytest.skip(f"PC sampling is not supported on {soc}") diff --git a/projects/rocprofiler-compute/tests/test_pc_sampling.py b/projects/rocprofiler-compute/tests/test_pc_sampling.py index 67af8803d33..f4309f4a74b 100644 --- a/projects/rocprofiler-compute/tests/test_pc_sampling.py +++ b/projects/rocprofiler-compute/tests/test_pc_sampling.py @@ -48,20 +48,11 @@ def is_pc_sampling_not_supported(output): return "Given PC sampling configuration is not supported" in output -def skip_unsupported_pc_sampling_soc(is_stochastic=False): - unsupported_socs = {"MI100", "RDNA35_HALO"} - if is_stochastic: - unsupported_socs.add("MI200") - - if soc in unsupported_socs: - pytest.skip(f"PC sampling is not supported on {soc}") - - def test_pc_sampling_host_trap(binary_handler_profile_rocprof_compute): """ Test that PC sampling works with --block 21 and --pc-sampling-method host_trap. """ - skip_unsupported_pc_sampling_soc() + common.skip_unsupported_pc_sampling_soc() options = [ "--block", @@ -93,7 +84,7 @@ def test_pc_sampling_stochastic(binary_handler_profile_rocprof_compute): """ Test that PC sampling works with --block 21 and --pc-sampling-method stochastic. """ - skip_unsupported_pc_sampling_soc(is_stochastic=True) + common.skip_unsupported_pc_sampling_soc(is_stochastic=True) options = [ "--block", @@ -135,7 +126,7 @@ def test_multi_rank_pc_sampling_only( Test that no multi-rank warning is printed when running with only --block 21 (PC sampling only mode requires a single pass) with multi-rank. """ - skip_unsupported_pc_sampling_soc() + common.skip_unsupported_pc_sampling_soc() monkeypatch.setenv("OMPI_COMM_WORLD_RANK", "0") monkeypatch.setenv("OMPI_COMM_WORLD_SIZE", "2") @@ -174,7 +165,7 @@ def test_multi_rank_warning_pc_sampling_with_counters( and another block (PC sampling with counters mode requires multiple passes) with multi-rank. """ - skip_unsupported_pc_sampling_soc() + common.skip_unsupported_pc_sampling_soc() monkeypatch.setenv("OMPI_COMM_WORLD_RANK", "0") monkeypatch.setenv("OMPI_COMM_WORLD_SIZE", "2") @@ -219,7 +210,7 @@ def test_pc_sampling_profile_then_analyze( End-to-end: profile with PC sampling (host_trap), then run analysis on the profiling output. """ - skip_unsupported_pc_sampling_soc() + common.skip_unsupported_pc_sampling_soc() options = [ "--block", @@ -301,7 +292,7 @@ def test_pc_sampling_with_sol_block(binary_handler_profile_rocprof_compute): Test that PC sampling works with --block 21 and --block 2 (PC sampling with counter collection) """ - skip_unsupported_pc_sampling_soc() + common.skip_unsupported_pc_sampling_soc() options = [ "--block", diff --git a/projects/rocprofiler-compute/tests/test_profile_general.py b/projects/rocprofiler-compute/tests/test_profile_general.py index 50e3d84a8c4..cfa86286836 100644 --- a/projects/rocprofiler-compute/tests/test_profile_general.py +++ b/projects/rocprofiler-compute/tests/test_profile_general.py @@ -2225,7 +2225,7 @@ def test_live_attach_detach_singlepass_launch_stats( def test_live_attach_detach_pc_sampling( binary_handler_profile_rocprof_compute, ): - skip_unsupported_pc_sampling_soc(is_stochastic=True) + common.skip_unsupported_pc_sampling_soc(is_stochastic=True) options = ["-b", "21"] workload_dir = common.get_output_dir() From 17c407541bcfef59493d5e1fa77404dbd6d81926 Mon Sep 17 00:00:00 2001 From: Yang Wang Date: Mon, 11 May 2026 15:36:45 -0400 Subject: [PATCH 6/6] ruff format --- .../tests/test_profile_general.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/projects/rocprofiler-compute/tests/test_profile_general.py b/projects/rocprofiler-compute/tests/test_profile_general.py index cfa86286836..b1c82338e0c 100644 --- a/projects/rocprofiler-compute/tests/test_profile_general.py +++ b/projects/rocprofiler-compute/tests/test_profile_general.py @@ -18,7 +18,6 @@ import pytest import yaml from scipy.stats import zscore -from tests.test_pc_sampling import skip_unsupported_pc_sampling_soc # Runtime config options config = {} @@ -2031,9 +2030,18 @@ def test_comprehensive_error_paths(): @pytest.mark.live_attach_detach -@pytest.mark.parametrize("profile_format", ["rocpd", "csv"]) -def test_live_attach_detach_block(binary_handler_profile_rocprof_compute, profile_format): - options = ["--block", "3.1.1", "4.1.1", "5.1.1","--format-rocprof-output", profile_format] +@pytest.mark.parametrize("profile_format", ["rocpd", "csv"]) +def test_live_attach_detach_block( + binary_handler_profile_rocprof_compute, profile_format +): + options = [ + "--block", + "3.1.1", + "4.1.1", + "5.1.1", + "--format-rocprof-output", + profile_format, + ] workload_dir = common.get_output_dir() # TODO: temp fix for sdk defautly disable attach/detach,