⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content
Open
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
4 changes: 3 additions & 1 deletion nsight/transformation.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ def convert_non_sortable_columns(dframe: pd.DataFrame) -> pd.DataFrame:
)

# Compute relative standard deviation as a percentage
agg_df["RelativeStdDevPct"] = (agg_df["StdDev"] / agg_df["AvgValue"]) * 100
agg_df["RelativeStdDevPct"] = (
agg_df["StdDev"] / agg_df["AvgValue"].replace(0, np.nan)
) * 100

# Flag measurements as stable if relative stddev is less than 2%
agg_df["StableMeasurement"] = agg_df["RelativeStdDevPct"] < 2.0
Expand Down
17 changes: 17 additions & 0 deletions tests/test_profiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1068,6 +1068,13 @@ def profiled_func(x: int, y: int) -> None:
"invalid_multiple",
id="invalid_multiple",
),
pytest.param(
[
"sm__idc_divergent_instructions.avg",
],
"valid_single_zero",
id="valid_single_zero",
),
],
)
def test_parameter_metrics(metrics: Sequence[str], expected_result: str) -> None:
Expand Down Expand Up @@ -1099,6 +1106,16 @@ def profiled_func(x: int, y: int) -> None:
assert (
df["AvgValue"].notna() & df["AvgValue"] > 0
).all(), f"Invalid AvgValue for metric {metrics}"
elif expected_result == "valid_single_zero":
profile_output = profiled_func()
df = profile_output.to_dataframe()

# Verify that zero values are handled correctly
# For sm__idc_divergent_instructions, the value should be zero
# since simple add operations don't have divergent instructions
assert (
df["AvgValue"] == 0
).all(), f"Expected zero value for metric {metrics[0]} in simple kernels, got {df['AvgValue'].tolist()}"
elif expected_result == "invalid_multiple":
with pytest.raises(
ValueError,
Expand Down