From 09d809cf6119ae5fa82a97bcf0806a7d8ae3faa4 Mon Sep 17 00:00:00 2001 From: Chris Ashton Date: Mon, 6 Apr 2026 18:45:27 -0500 Subject: [PATCH] Enable perf_counters tool for GPU profiles The perf_counters tool availability check only searched TPU planes for kCounterValue stats, so GPU range profiling data never triggered the tool to appear in the xprof dropdown. Search GPU planes as well. --- xprof/convert/xplane_to_tool_names.cc | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/xprof/convert/xplane_to_tool_names.cc b/xprof/convert/xplane_to_tool_names.cc index d5599989f..f74cf7e5e 100644 --- a/xprof/convert/xplane_to_tool_names.cc +++ b/xprof/convert/xplane_to_tool_names.cc @@ -93,9 +93,18 @@ absl::StatusOr GetAvailableToolNames( has_dcn_collective_stats = has_dcn_collective_stats || HasDcnCollectiveStatsInXSpace(*xspace); - std::vector tpu_planes = tsl::profiler::FindPlanesWithPrefix( - *xspace, tsl::profiler::kTpuPlanePrefix); - for (const XPlane* plane : tpu_planes) { + // Check both TPU and GPU planes for perf counter data. + std::vector device_planes = + tsl::profiler::FindPlanesWithPrefix(*xspace, + tsl::profiler::kTpuPlanePrefix); + { + std::vector gpu_planes = + tsl::profiler::FindPlanesWithPrefix(*xspace, + tsl::profiler::kGpuPlanePrefix); + device_planes.insert(device_planes.end(), gpu_planes.begin(), + gpu_planes.end()); + } + for (const XPlane* plane : device_planes) { tsl::profiler::XPlaneVisitor visitor = tsl::profiler::CreateTfXPlaneVisitor(plane); visitor.ForEachLine([&](const tsl::profiler::XLineVisitor& line) {