From 6662b2f538f4577846aa863e6c163842967a41ba Mon Sep 17 00:00:00 2001 From: Brian Coutinho Date: Wed, 28 May 2025 12:39:36 -0700 Subject: [PATCH] Fix CUPTI Range Profiler test Summary: Simple fix that was causing a test failure earlier. The test mocks the object but the destructor calls CUDA deinit() API. This should have been fused out basically. https://github.com/pytorch/kineto/blob/main/libkineto/src/CuptiRangeProfilerApi.cpp#L716-L719 Differential Revision: D75494874 --- libkineto/src/CuptiRangeProfilerApi.cpp | 3 ++- libkineto/src/CuptiRangeProfilerApi.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/libkineto/src/CuptiRangeProfilerApi.cpp b/libkineto/src/CuptiRangeProfilerApi.cpp index 6f28ac02c..c9d717782 100644 --- a/libkineto/src/CuptiRangeProfilerApi.cpp +++ b/libkineto/src/CuptiRangeProfilerApi.cpp @@ -336,6 +336,7 @@ CuptiRBProfilerSession::CuptiRBProfilerSession( // used in unittests only if (opts.unitTest) { initSuccess_ = true; + unitTest_ = true; profiler_map[deviceId_] = this; return; } @@ -714,7 +715,7 @@ bool CuptiRBProfilerSession::createCounterDataImage() { } CuptiRBProfilerSession::~CuptiRBProfilerSession() { - if (initSuccess_) { + if (initSuccess_ && !unitTest_) { CuptiRBProfilerSession::deInitCupti(); } } diff --git a/libkineto/src/CuptiRangeProfilerApi.h b/libkineto/src/CuptiRangeProfilerApi.h index 2227a27eb..e6058bf7e 100644 --- a/libkineto/src/CuptiRangeProfilerApi.h +++ b/libkineto/src/CuptiRangeProfilerApi.h @@ -209,6 +209,7 @@ class CuptiRBProfilerSession { bool initSuccess_ = false; bool profilingActive_ = false; + bool unitTest_ = false; friend void __trackCudaKernelLaunch(CUcontext ctx, const char* kernelName); };