diff --git a/tt_metal/impl/lightmetal/host_api_capture_helpers.hpp b/tt_metal/impl/lightmetal/host_api_capture_helpers.hpp index cb6075bfb299..f6b8844ec31c 100644 --- a/tt_metal/impl/lightmetal/host_api_capture_helpers.hpp +++ b/tt_metal/impl/lightmetal/host_api_capture_helpers.hpp @@ -126,6 +126,14 @@ inline void CaptureCreateBuffer(std::shared_ptr buffer, const Interleave inline void CaptureDeallocateBuffer(Buffer* buffer) { auto& ctx = LightMetalCaptureContext::Get(); + // TODO (kmabee) - Workaround for now. Program Binaries buffer is created via Buffer::create() but can be + // deallocated on Program destruction while capturing is still enabled depending on test structure (scope). + // If we avoid recursively tracing host APIs this could go away. + if (!ctx.IsInMap(buffer)) { + log_warning(tt::LogMetalTrace, "Cannot capture DeallocateBuffer() without CreateBuffer() - ignoring."); + return; + } + auto buffer_global_id = ctx.GetGlobalId(buffer); log_debug(