From 6cbda3f1d8b20ebf3c8485106bd9d66210ce0cc7 Mon Sep 17 00:00:00 2001 From: Fei Zheng <44449748+feizheng10@users.noreply.github.com> Date: Thu, 31 Jul 2025 08:20:49 -0600 Subject: [PATCH] Format code (#842) --- docs/conf.py | 2 +- src/config.py | 2 +- src/utils/roofline_calc.py | 70 +++++++--------------------------- tests/test_analyze_commands.py | 8 ++-- tests/test_db_connector.py | 6 +-- utils/split_config.py | 13 +++++-- 6 files changed, 32 insertions(+), 69 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index aef5591810..be644da1b4 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -212,4 +212,4 @@ extlinks = { } # Uncomment if facing rate limit exceed issue with local build -external_projects_remote_repository = "" \ No newline at end of file +external_projects_remote_repository = "" diff --git a/src/config.py b/src/config.py index 88cde44384..5cb8b279cf 100644 --- a/src/config.py +++ b/src/config.py @@ -32,4 +32,4 @@ HIDDEN_COLUMNS = ["coll_level"] HIDDEN_COLUMNS_CLI = ["Description", "coll_level"] HIDDEN_SECTIONS = [400, 1900, 2000] -TIME_UNITS = {"s": 10 ** 9, "ms": 10 ** 6, "us": 10 ** 3, "ns": 1} +TIME_UNITS = {"s": 10**9, "ms": 10**6, "us": 10**3, "ns": 1} diff --git a/src/utils/roofline_calc.py b/src/utils/roofline_calc.py index 4fb715f1e5..c141c349ad 100644 --- a/src/utils/roofline_calc.py +++ b/src/utils/roofline_calc.py @@ -259,25 +259,11 @@ def calc_ai(mspec, sort_type, ret_df): df = df.sort_values(by=["Kernel_Name"]) df = df.reset_index(drop=True) - total_flops = ( - valu_flops - ) = ( - mfma_flops_f6f4 - ) = ( - mfma_flops_f8 - ) = ( - mfma_flops_bf16 - ) = ( + total_flops = valu_flops = mfma_flops_f6f4 = mfma_flops_f8 = mfma_flops_bf16 = ( mfma_flops_f16 - ) = ( - mfma_iops_i8 - ) = ( - mfma_flops_f32 - ) = ( - mfma_flops_f64 - ) = ( - lds_data - ) = L1cache_data = L2cache_data = hbm_data = calls = totalDuration = avgDuration = 0.0 + ) = mfma_iops_i8 = mfma_flops_f32 = mfma_flops_f64 = lds_data = L1cache_data = ( + L2cache_data + ) = hbm_data = calls = totalDuration = avgDuration = 0.0 kernelName = "" @@ -498,27 +484,13 @@ def calc_ai(mspec, sort_type, ret_df): kernelName, idx, calls ) ) - total_flops = ( - valu_flops - ) = ( - mfma_flops_f6f4 - ) = ( - mfma_flops_f8 - ) = ( + total_flops = valu_flops = mfma_flops_f6f4 = mfma_flops_f8 = ( mfma_flops_bf16 - ) = ( - mfma_flops_f16 - ) = ( - mfma_iops_i8 - ) = ( - mfma_flops_f32 - ) = ( - mfma_flops_f64 - ) = ( + ) = mfma_flops_f16 = mfma_iops_i8 = mfma_flops_f32 = mfma_flops_f64 = ( lds_data - ) = ( - L1cache_data - ) = L2cache_data = hbm_data = calls = totalDuration = avgDuration = 0.0 + ) = L1cache_data = L2cache_data = hbm_data = calls = totalDuration = ( + avgDuration + ) = 0.0 if sort_type == "dispatches": myList.append( @@ -542,27 +514,13 @@ def calc_ai(mspec, sort_type, ret_df): avgDuration, ) ) - total_flops = ( - valu_flops - ) = ( - mfma_flops_f6f4 - ) = ( - mfma_flops_f8 - ) = ( + total_flops = valu_flops = mfma_flops_f6f4 = mfma_flops_f8 = ( mfma_flops_bf16 - ) = ( - mfma_flops_f16 - ) = ( - mfma_iops_i8 - ) = ( - mfma_flops_f32 - ) = ( - mfma_flops_f64 - ) = ( + ) = mfma_flops_f16 = mfma_iops_i8 = mfma_flops_f32 = mfma_flops_f64 = ( lds_data - ) = ( - L1cache_data - ) = L2cache_data = hbm_data = calls = totalDuration = avgDuration = 0.0 + ) = L1cache_data = L2cache_data = hbm_data = calls = totalDuration = ( + avgDuration + ) = 0.0 myList.sort(key=lambda x: x.totalDuration, reverse=True) diff --git a/tests/test_analyze_commands.py b/tests/test_analyze_commands.py index 13106f93ca..0dbfd53d52 100644 --- a/tests/test_analyze_commands.py +++ b/tests/test_analyze_commands.py @@ -42,7 +42,7 @@ indirs = [ "tests/workloads/vcopy/MI350", ] -time_units = {"s": 10 ** 9, "ms": 10 ** 6, "us": 10 ** 3, "ns": 1} +time_units = {"s": 10**9, "ms": 10**6, "us": 10**3, "ns": 1} @pytest.mark.misc @@ -1308,9 +1308,9 @@ def test_mathematical_correctness_all_units(sample_time_data, original_ns_values from utils.tty import convert_time_columns test_cases = [ - ("s", 10 ** 9), # 1 second = 10^9 nanoseconds - ("ms", 10 ** 6), # 1 millisecond = 10^6 nanoseconds - ("us", 10 ** 3), # 1 microsecond = 10^3 nanoseconds + ("s", 10**9), # 1 second = 10^9 nanoseconds + ("ms", 10**6), # 1 millisecond = 10^6 nanoseconds + ("us", 10**3), # 1 microsecond = 10^3 nanoseconds ("ns", 1), # 1 nanosecond = 1 nanosecond ] diff --git a/tests/test_db_connector.py b/tests/test_db_connector.py index 7a6aa2171f..ad48a87a77 100644 --- a/tests/test_db_connector.py +++ b/tests/test_db_connector.py @@ -209,9 +209,9 @@ class TestDatabaseConnector: with patch.object(connector, "prep_import") as mock_prep: mock_prep.return_value = None - connector.connection_info[ - "db" - ] = "rocprofiler-compute_test_team_test_workload_MI100" + connector.connection_info["db"] = ( + "rocprofiler-compute_test_team_test_workload_MI100" + ) connector.db_import() diff --git a/utils/split_config.py b/utils/split_config.py index 52bbef8b0c..bc0e6db392 100644 --- a/utils/split_config.py +++ b/utils/split_config.py @@ -6,9 +6,9 @@ # Read utils/unified_config.yaml and split it into metric tables per documentation section # WARNING: This script will overwrite existing docs/data/metrics_description.yaml +import copy import hashlib import re -import copy from pathlib import Path import yaml @@ -34,7 +34,10 @@ def update_analysis_config(): new_panel_config = {"Panel Config": {}} new_panel_config["Panel Config"]["id"] = panel_config["id"] new_panel_config["Panel Config"]["title"] = panel_config["title"] - new_panel_config["Panel Config"]["metrics_description"] = {key: value["plain"] for key, value in panel_config.get("metrics_description", {}).items()} + new_panel_config["Panel Config"]["metrics_description"] = { + key: value["plain"] + for key, value in panel_config.get("metrics_description", {}).items() + } # Convert int into str with 4 digits panel_id = str(panel_config["id"]).zfill(4) # Replace parentehsis, hyphen, slash and space with underscore @@ -57,7 +60,9 @@ def update_analysis_config(): for data_source_config in panel_config["data source"]: data_source_config = copy.deepcopy(data_source_config) if "metric_table" in data_source_config: - data_source_config["metric_table"]["metric"] = data_source_config["metric_table"]["metric"][gfx_version] + data_source_config["metric_table"]["metric"] = data_source_config[ + "metric_table" + ]["metric"][gfx_version] new_panel_config["Panel Config"]["data source"].append(data_source_config) # Write panel config to file filename = Path( @@ -126,7 +131,7 @@ def update_documentation(): "rst": panel_config["metrics_description"][key]["rst"], "unit": panel_config["metrics_description"][key]["unit"], } - panel_metric_map[data_source["metric_table"]["id"]] = metrics_info + panel_metric_map[data_source["metric_table"]["id"]] = metrics_info # Merge panel_metric_map with section_panel_map section_metric_map = {}