From 1894f37e5b330d741d24d1c06e4c81371127d6a6 Mon Sep 17 00:00:00 2001 From: andrewwhitecdw Date: Wed, 12 Aug 2026 14:38:20 -0500 Subject: [PATCH] fix: set_kernel_name returns None for unexpected activity kinds Signed-off-by: andrewwhitecdw --- src/sol_execbench/core/bench/cupti_utils.py | 4 ++- tests/core/bench/test_cupti_utils.py | 28 +++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 tests/core/bench/test_cupti_utils.py diff --git a/src/sol_execbench/core/bench/cupti_utils.py b/src/sol_execbench/core/bench/cupti_utils.py index a8852452..c4997210 100644 --- a/src/sol_execbench/core/bench/cupti_utils.py +++ b/src/sol_execbench/core/bench/cupti_utils.py @@ -80,7 +80,9 @@ def set_kernel_name(activity): return "MEMCPY" if activity.kind == cupti.ActivityKind.MEMSET: return "MEMSET" - return None + # Activities such as RUNTIME or DRIVER may not provide a name. Fall + # back to a stable string so callers always receive a `str`. + return getattr(activity, "name", None) or str(activity.kind) @staticmethod def get_bytes(activity): diff --git a/tests/core/bench/test_cupti_utils.py b/tests/core/bench/test_cupti_utils.py new file mode 100644 index 00000000..09ae3957 --- /dev/null +++ b/tests/core/bench/test_cupti_utils.py @@ -0,0 +1,28 @@ +# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +"""Tests for CUPTI activity normalization helpers.""" + +import types +import pytest + +from sol_execbench.core.bench.cupti_utils import CuptiKernelInfo + + +def test_kernel_string_for_activity_without_name(): + """Unexpected activity kinds without a name must still produce a string identity.""" + activity = types.SimpleNamespace( + kind="RUNTIME", + name=None, + start=0.0, + end=1.0, + correlation_id=0, + bytes=0, + copy_kind=0, + value=0, + ) + info = CuptiKernelInfo.from_activity(activity) + assert isinstance(info.name, str) + assert info.kernel_string() == "RUNTIME_0_0_0_RUNTIME" + +