Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,10 @@ def generate_from_filter(
console_debug("analysis", f"gui gpu filter is {gcd_filter}")
console_debug("analysis", f"gui top-n filter is {top_n_filt}")

base_data[base_run].filter_kernel_ids = (
[str(k) for k in kernel_filter] if kernel_filter else []
)
base_data[base_run].filter_kernel_ids = (kernel_filter if kernel_filter else [])
console_warning('kernel_filter',kernel_filter)
console_warning('base_data[base_run].filter_kernel_ids',base_data[base_run].filter_kernel_ids)

Comment on lines +156 to +158

Copilot AI Dec 19, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug console_warning statements should be removed before merging. These appear to be temporary debugging code left to track kernel filter values.

Suggested change
console_warning('kernel_filter',kernel_filter)
console_warning('base_data[base_run].filter_kernel_ids',base_data[base_run].filter_kernel_ids)

Copilot uses AI. Check for mistakes.
base_data[base_run].filter_gpu_ids = (
[int(g) for g in gcd_filter] if gcd_filter else []
)
Expand Down Expand Up @@ -185,13 +186,15 @@ def generate_from_filter(
for key in base_data[base_run].dfs
if key in basic_dfs_keep
}
base_data[base_run].dfs = filtered_dfs
# base_data[base_run].dfs = filtered_dfs

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove comments of unused code in production code

Copilot AI Dec 19, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is commented out but filtered_dfs is still used later in the code. The assignment to filtered_dfs should either be uncommented or the variable should be renamed to avoid confusion about which dfs object is being used.

Suggested change
# base_data[base_run].dfs = filtered_dfs
base_data[base_run].dfs = filtered_dfs

Copilot uses AI. Check for mistakes.

panel_configs = {
key: panel_configs[key]
for key in panel_configs
if key in basic_panels_keep
}
else:
filtered_dfs = base_data[base_run].dfs

# All filtering will occur here
parser.load_table_data(
Expand Down Expand Up @@ -257,7 +260,7 @@ def generate_from_filter(
# Iterate over each table per section
for data_source in panel["data source"]:
for t_type, table_config in data_source.items():
original_df = base_data[base_run].dfs[table_config["id"]]
original_df = filtered_dfs[table_config["id"]]

# The sys info table need to add index back
if t_type == "raw_csv_table" and "Info" in original_df.keys():
Expand Down
8 changes: 8 additions & 0 deletions projects/rocprofiler-compute/src/roofline.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,14 @@ def generate_plot(

subplot_row = 1
skipAI = False
else:
console_warning('fig is None and no kernel names data provided')
# New figure without kernel names table
fig = make_subplots(
rows=1,
cols=1,
subplot_titles=["Roofline Analysis - NO DATA"],
)
else:
# Adding to existing figure
if hasattr(fig, "_grid_ref") and fig._grid_ref is not None:
Expand Down
8 changes: 4 additions & 4 deletions projects/rocprofiler-compute/src/utils/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def discrete_background_color_bins(
####################
def create_instruction_mix_bar_chart(display_df: pd.DataFrame, df_unit: str) -> px.bar:
display_df = display_df.copy()
display_df["Avg"] = display_df["Avg"].apply(lambda x: int(x) if x != "" else 0)
display_df["Avg"] = display_df["Avg"].apply(lambda x: int(x) if x not in ["","N/A",None] else 0)

return px.bar(
display_df,
Expand All @@ -150,7 +150,7 @@ def create_multi_bar_charts(
display_df: pd.DataFrame, table_id: int, df_unit: str
) -> list[px.bar]:
display_df = display_df.copy()
display_df["Avg"] = display_df["Avg"].apply(lambda x: int(x) if x != "" else 0)
display_df["Avg"] = display_df["Avg"].apply(lambda x: int(x) if x not in ["","N/A",None] else 0)

nested_bar = multi_bar_chart(table_id, display_df)
charts = []
Expand All @@ -175,7 +175,7 @@ def create_multi_bar_charts(

def create_sol_charts(display_df: pd.DataFrame, table_id: int) -> list[px.bar]:
display_df = display_df.copy()
display_df["Avg"] = display_df["Avg"].apply(lambda x: float(x) if x != "" else 0.0)
display_df["Avg"] = display_df["Avg"].apply(lambda x: float(x) if x not in ["","N/A",None] else 0.0)

charts = []

Expand Down Expand Up @@ -216,7 +216,7 @@ def create_sol_charts(display_df: pd.DataFrame, table_id: int) -> list[px.bar]:
elif table_id == 1101:
# Special formatting reference 'Pct of Peak' value
display_df["Pct of Peak"] = display_df["Pct of Peak"].apply(
lambda x: float(x) if x != "" else 0.0
lambda x: float(x) if x not in ["","N/A",None] else 0.0
)
charts.append(
px.bar(
Expand Down
89 changes: 69 additions & 20 deletions projects/rocprofiler-compute/src/utils/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
# }
SUPPORTED_DENOM: dict[str, str] = {
"per_wave": "SQ_WAVES",
"per_cycle": "$GRBM_GUI_ACTIVE_PER_XCD",
"per_cycle": "GRBM_GUI_ACTIVE_PER_XCD",
"per_second": "((End_Timestamp - Start_Timestamp) / 1000000000)",
"per_kernel": "1",
}
Expand Down Expand Up @@ -197,6 +197,8 @@ def to_int(
if a is None:
return None
elif isinstance(a, (int, float, np.integer)):
if pd.isna(a):
return None
return int(a)
elif isinstance(a, pd.Series):
return a.astype(int)
Expand Down Expand Up @@ -317,14 +319,20 @@ def __init__(
self.empirical_peaks = empirical_peaks

def eval_expression(self, expr: str) -> Union[str, float, int]:
"""Evaluate a single expression with proper local context."""
"""Evaluate a single expression with proper local context."""

Comment on lines +322 to +323

Copilot AI Dec 19, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing whitespace detected at the end of this line. This should be removed to maintain clean code formatting.

Suggested change
"""Evaluate a single expression with proper local context."""
"""Evaluate a single expression with proper local context."""

Copilot uses AI. Check for mistakes.
if isinstance(expr, (int, float)):
if pd.isna(expr):
return "N/A"
return expr
if expr in {"", "N/A", None}:
return "N/A"
try:
# Create comprehensive local context
local_expr_context = {}
local_expr_context.update({"raw_pmc_df": self.raw_pmc_df})
local_expr_context.update(self.sys_vars)
local_expr_context.update(self.empirical_peaks)

# Add utility functions to local context
local_expr_context.update({
"to_min": to_min,
Expand All @@ -340,40 +348,72 @@ def eval_expression(self, expr: str) -> Union[str, float, int]:
"to_concat": to_concat,
})

# # Debug print for GRBM expressions
# if isinstance(expr,str) and "grbm" in expr.lower() and "ammolite__num_xcd" in expr:
# console_warning("Local context keys:",local_expr_context)
# console_warning(f"=== EVAL DEBUG for: {expr} ===")

# if 'raw_pmc_df' in local_expr_context:
# pmc_df = local_expr_context['raw_pmc_df']
# console_warning(f"raw_pmc_df type: {type(pmc_df)}")

# grbm_col = pmc_df['pmc_perf']['GRBM_GUI_ACTIVE']
# console_warning(f"GRBM_GUI_ACTIVE type: {type(grbm_col)}")
# console_warning(f"GRBM_GUI_ACTIVE shape: {getattr(grbm_col, 'shape', 'No shape')}")
# console_warning(f"GRBM_GUI_ACTIVE values: {grbm_col}")
# console_warning("GRBM_GUI_ACTIVE index:",grbm_col.index)
# else:
# console_error("raw_pmc_df not found in local_expr_context.")

# # Print num_xcd
# num_xcd = local_expr_context.get('ammolite__num_xcd')
# console_warning(f"ammolite__num_xcd type: {type(num_xcd)}")
# console_warning(f"ammolite__num_xcd value: {num_xcd}")

Comment on lines +353 to +372

Copilot AI Dec 19, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment appears to contain commented-out code.

Suggested change
# console_warning("Local context keys:",local_expr_context)
# console_warning(f"=== EVAL DEBUG for: {expr} ===")
# if 'raw_pmc_df' in local_expr_context:
# pmc_df = local_expr_context['raw_pmc_df']
# console_warning(f"raw_pmc_df type: {type(pmc_df)}")
# grbm_col = pmc_df['pmc_perf']['GRBM_GUI_ACTIVE']
# console_warning(f"GRBM_GUI_ACTIVE type: {type(grbm_col)}")
# console_warning(f"GRBM_GUI_ACTIVE shape: {getattr(grbm_col, 'shape', 'No shape')}")
# console_warning(f"GRBM_GUI_ACTIVE values: {grbm_col}")
# console_warning("GRBM_GUI_ACTIVE index:",grbm_col.index)
# else:
# console_error("raw_pmc_df not found in local_expr_context.")
# # Print num_xcd
# num_xcd = local_expr_context.get('ammolite__num_xcd')
# console_warning(f"ammolite__num_xcd type: {type(num_xcd)}")
# console_warning(f"ammolite__num_xcd value: {num_xcd}")

Copilot uses AI. Check for mistakes.
eval_result = eval(
compile(expr, "<string>", "eval"),
{},
local_expr_context,
)

if eval_result is None or np.isnan(eval_result).any():
if 'denom' in expr:
console_warning(f"Evaluated expression '{expr}' with result: {eval_result}")

Comment on lines +378 to +380

Copilot AI Dec 19, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug console_warning statements should be removed before merging. These appear to be temporary debugging code left in the codebase.

Suggested change
if 'denom' in expr:
console_warning(f"Evaluated expression '{expr}' with result: {eval_result}")

Copilot uses AI. Check for mistakes.
if eval_result is None:
return "N/A"
else:
return eval_result
# Only check for NaN if eval_result is numeric (not string)
if isinstance(eval_result, (int, float, np.number, pd.Series, np.ndarray)):
if hasattr(eval_result, 'any'):
if np.isnan(eval_result).any():
return "N/A"
else:
if np.isnan(eval_result):
return "N/A"
return eval_result

except (TypeError, NameError, KeyError) as exception:

if "empirical_peak" in str(exception):
console_warning(f"Missing empirical peak data: {exception}.")
return "N/A"
else:
console_warning(f"Failed to evaluate expression '{expr}': {exception}.")
# console_warning(f"Failed to evaluate expression '{expr}': {exception}.")
return "N/A"

except AttributeError as attribute_error:

if str(attribute_error) == "'NoneType' object has no attribute 'get'":
console_warning(
f"Failed to evaluate expression '{expr}': {attribute_error}."
)
# console_warning(
# f"Failed to evaluate expression '{expr}': {attribute_error}."
# )
return "N/A"
else:
console_error("analysis", str(attribute_error))
return "N/A"

except pd.errors.IntCastingNaNError as exception:
console_warning(f"Missing data: {exception}. Using empty value.")
# console_warning(f"Missing data: {exception}. Using empty value.")
return ""


def build_eval_string(equation: str, coll_level: str, config: dict) -> str:
"""
Convert user defined equation string to eval executable string.
Expand Down Expand Up @@ -484,14 +524,19 @@ def update_denominator_string(equation: str, normal_unit: str) -> str:
"""
if not equation:
return ""

# console_warning(f"normal_unit in build_metric_value_string: {normal_unit}")
equation_string = str(equation)

if normal_unit in SUPPORTED_DENOM.keys():
equation_string = re.sub(
r"\$denom", SUPPORTED_DENOM[normal_unit], equation_string
)

else:
console_error(
f"Normalization unit '{normal_unit}' is not supported. "
"Skiped updating $denom."

Copilot AI Dec 19, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in error message: 'Skiped' should be 'Skipped'.

Suggested change
"Skiped updating $denom."
"Skipped updating $denom."

Copilot uses AI. Check for mistakes.
)
if 'denom' in equation_string:
console_error(f"Updated equation with denom:{equation} --> {equation_string}")
Comment on lines +538 to +539

Copilot AI Dec 19, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug console_error statement should be removed before merging. This appears to be temporary debugging code that logs every equation update with denom.

Suggested change
if 'denom' in equation_string:
console_error(f"Updated equation with denom:{equation} --> {equation_string}")

Copilot uses AI. Check for mistakes.
return equation_string


Expand Down Expand Up @@ -808,7 +853,7 @@ def build_metric_value_string(
for id, df in dfs.items():
if dfs_type[id] == "metric_table":
for expr in df.columns:
if expr in schema.SUPPORTED_FIELD:
if any(expr.lower() == field.lower() for field in schema.SUPPORTED_FIELD):
# NB: apply all build-in before building the whole string
df[expr] = df[expr].apply(
update_denominator_string, normal_unit=normal_unit
Expand Down Expand Up @@ -917,24 +962,26 @@ def calc_builtin_vars(

# First pass: calculate per-XCD values
for variable_key, variable_value in BUILD_IN_VARS.items():

if "PER_XCD" not in variable_key:
continue

# NB: assume all built-in vars from pmc_perf.csv for now
eval_string = build_eval_string(
variable_value, schema.PMC_PERF_FILE_PREFIX, config
)
try:
# Create temporary evaluator for this calculation
# Pass sys_vars so that $num_xcd and other system variables are available

temporary_evaluator = MetricEvaluator(raw_pmc_df, sys_vars, {})
calculation_result = temporary_evaluator.eval_expression(eval_string)
builtin_vars_collection[f"ammolite__{variable_key}"] = calculation_result
except (TypeError, NameError, KeyError, AttributeError):
except (TypeError, NameError, KeyError, AttributeError) as exception:
builtin_vars_collection[f"ammolite__{variable_key}"] = None

# Second pass: calculate remaining variables that depend on per-XCD values
for variable_key, variable_value in BUILD_IN_VARS.items():

if "PER_XCD" in variable_key:
continue

Expand All @@ -950,6 +997,7 @@ def calc_builtin_vars(
except (TypeError, NameError, KeyError, AttributeError):
builtin_vars_collection[f"ammolite__{variable_key}"] = None


return builtin_vars_collection


Expand Down Expand Up @@ -997,7 +1045,7 @@ def eval_metric(
if dfs_type[df_id] == "metric_table":
for row_id, row in df.iterrows():
for expr in df.columns:
if expr in schema.SUPPORTED_FIELD and expr.lower() != "alias":
if any(expr.lower() == field.lower() for field in schema.SUPPORTED_FIELD) and expr.lower() != "alias":
if row[expr]:
exprs_to_eval.append((df_id, row_id, expr, row[expr]))

Expand All @@ -1012,6 +1060,7 @@ def eval_metric(

for df_id, row_id, col, expr in exprs_to_eval:
eval_result = metric_evaluator.eval_expression(expr)
# console_warning(f"{expr} Evaluates to: {type(eval_result)}, value: {str(eval_result)}")
dfs[df_id].loc[row_id, col] = eval_result
# Check for metrics exceeding theoretical peak due to dual-issue
validate_dual_issue_metrics(dfs, dfs_type, sys_info, raw_pmc_df)
Expand Down
Loading