From 83c705cb61729f9b23ad3e1c1839023eea259711 Mon Sep 17 00:00:00 2001 From: Nick Smith <127986401+nsmithtt@users.noreply.github.com> Date: Thu, 8 Aug 2024 13:31:18 -0700 Subject: [PATCH] Upgrade tt-metal to f6a2e5cb2b857bf4c72401bea68adf98c25bbe47 (#328) --- lib/SharedLib/CMakeLists.txt | 2 +- runtime/include/tt/runtime/detail/ttmetal.h | 6 ++++++ runtime/include/tt/runtime/detail/ttnn.h | 16 ++++++++++++---- runtime/lib/CMakeLists.txt | 1 + runtime/lib/ttmetal/CMakeLists.txt | 2 ++ runtime/lib/ttnn/CMakeLists.txt | 2 ++ runtime/lib/ttnn/program.cpp | 21 +++++---------------- runtime/test/CMakeLists.txt | 3 +-- third_party/CMakeLists.txt | 12 ++++++------ 9 files changed, 36 insertions(+), 29 deletions(-) diff --git a/lib/SharedLib/CMakeLists.txt b/lib/SharedLib/CMakeLists.txt index 318197947..81eeb5ae5 100644 --- a/lib/SharedLib/CMakeLists.txt +++ b/lib/SharedLib/CMakeLists.txt @@ -2,7 +2,7 @@ set(TTNN_RUNTIME_LIBS TTRuntime TTRuntimeTTNN TTBinary) # Dependency libs from tt-metal/ttnn project for ttnn runtime -set(TTNN_LIBS TTMETAL_LIBRARY TTEAGER_LIBRARY TTNN_LIBRARY) +set(TTNN_LIBS TTMETAL_LIBRARY TTNN_LIBRARY) # Libs from tt-mlir project set(TTMLIR_LIBS diff --git a/runtime/include/tt/runtime/detail/ttmetal.h b/runtime/include/tt/runtime/detail/ttmetal.h index b8c72d13f..b4516ae1b 100644 --- a/runtime/include/tt/runtime/detail/ttmetal.h +++ b/runtime/include/tt/runtime/detail/ttmetal.h @@ -32,6 +32,12 @@ #pragma clang diagnostic ignored "-Wunused-function" #pragma clang diagnostic ignored "-Wpessimizing-move" #pragma clang diagnostic ignored "-Wparentheses" +#pragma clang diagnostic ignored "-Wdeprecated-volatile" +#pragma clang diagnostic ignored "-Wdeprecated-this-capture" +#pragma clang diagnostic ignored "-Wc++23-extensions" +#pragma clang diagnostic ignored "-Wunused-but-set-variable" +#pragma clang diagnostic ignored "-Wlogical-op-parentheses" +#pragma clang diagnostic ignored "-Wundefined-inline" #define FMT_HEADER_ONLY #include "tt_metal/host_api.hpp" #pragma clang diagnostic pop diff --git a/runtime/include/tt/runtime/detail/ttnn.h b/runtime/include/tt/runtime/detail/ttnn.h index 5c7c348d9..0d8d68a75 100644 --- a/runtime/include/tt/runtime/detail/ttnn.h +++ b/runtime/include/tt/runtime/detail/ttnn.h @@ -33,14 +33,22 @@ #pragma clang diagnostic ignored "-Wunused-function" #pragma clang diagnostic ignored "-Wpessimizing-move" #pragma clang diagnostic ignored "-Wparentheses" +#pragma clang diagnostic ignored "-Wdeprecated-volatile" +#pragma clang diagnostic ignored "-Wdeprecated-this-capture" +#pragma clang diagnostic ignored "-Wc++23-extensions" +#pragma clang diagnostic ignored "-Wunused-but-set-variable" +#pragma clang diagnostic ignored "-Wlogical-op-parentheses" +#pragma clang diagnostic ignored "-Wundefined-inline" #define FMT_HEADER_ONLY #include "ttnn/device.hpp" -#include "ttnn/operations/binary.hpp" #include "ttnn/operations/copy.hpp" -#include "ttnn/operations/core.hpp" +#include "ttnn/operations/core/core.hpp" #include "ttnn/operations/creation.hpp" -#include "ttnn/operations/matmul.hpp" -#include "ttnn/operations/normalization.hpp" +#include "ttnn/operations/data_movement/permute/permute.hpp" +#include "ttnn/operations/eltwise/binary/binary.hpp" +#include "ttnn/operations/eltwise/unary/unary.hpp" +#include "ttnn/operations/matmul/matmul.hpp" +#include "ttnn/operations/normalization/softmax/softmax.hpp" #include "ttnn/operations/reduction/generic/generic_reductions.hpp" #pragma clang diagnostic pop diff --git a/runtime/lib/CMakeLists.txt b/runtime/lib/CMakeLists.txt index 3238ca7b7..4a52d4eef 100644 --- a/runtime/lib/CMakeLists.txt +++ b/runtime/lib/CMakeLists.txt @@ -20,6 +20,7 @@ endif() message(STATUS "TT_RUNTIME_ENABLE_TTNN: ${TT_RUNTIME_ENABLE_TTNN} ${TT_RUNTIME_ENABLE_TTMETAL}") add_library(TTRuntime STATIC runtime.cpp) +set_property(TARGET TTRuntime PROPERTY CXX_STANDARD 20) if (TTMLIR_ENABLE_RUNTIME AND TT_RUNTIME_ENABLE_TTNN) target_compile_definitions(TTRuntime PUBLIC TT_RUNTIME_ENABLE_TTNN) endif() diff --git a/runtime/lib/ttmetal/CMakeLists.txt b/runtime/lib/ttmetal/CMakeLists.txt index a8d02fa34..3c2488049 100644 --- a/runtime/lib/ttmetal/CMakeLists.txt +++ b/runtime/lib/ttmetal/CMakeLists.txt @@ -3,6 +3,8 @@ add_library(TTRuntimeTTMetal runtime.cpp command_queue.cpp ) +# We have to set the C++ standard to 20 because tt-metal requires it +set_property(TARGET TTRuntimeTTMetal PROPERTY CXX_STANDARD 20) target_include_directories(TTRuntimeTTMetal PUBLIC ${PROJECT_SOURCE_DIR}/runtime/include ${PROJECT_BINARY_DIR}/include/ttmlir/Target/Common diff --git a/runtime/lib/ttnn/CMakeLists.txt b/runtime/lib/ttnn/CMakeLists.txt index 01ec4d9ce..ad2542456 100644 --- a/runtime/lib/ttnn/CMakeLists.txt +++ b/runtime/lib/ttnn/CMakeLists.txt @@ -3,6 +3,8 @@ add_library(TTRuntimeTTNN runtime.cpp program.cpp ) +# We have to set the C++ standard to 20 because tt-metal requires it +set_property(TARGET TTRuntimeTTNN PROPERTY CXX_STANDARD 20) target_compile_options(TTRuntimeTTNN PRIVATE -mavx -mavx2) target_include_directories(TTRuntimeTTNN PUBLIC ${PROJECT_SOURCE_DIR}/runtime/include diff --git a/runtime/lib/ttnn/program.cpp b/runtime/lib/ttnn/program.cpp index 37e0d8494..fb5e89be9 100644 --- a/runtime/lib/ttnn/program.cpp +++ b/runtime/lib/ttnn/program.cpp @@ -15,16 +15,6 @@ #include "ttmlir/Target/TTNN/Target.h" #include "ttmlir/Version.h" -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wignored-qualifiers" -// Including this in ttnn.h causes multiple definition linker error -// due to non-inlined function definitions -#include "ttnn/operations/unary.hpp" -#pragma clang diagnostic ignored "-Wsign-compare" -#pragma clang diagnostic ignored "-Wunused-variable" -#include "ttnn/operations/data_movement.hpp" -#pragma clang diagnostic pop - // It seems like `ttnn::to_layout` cannot be called inside of the // `tt::runtime::ttnn` namespace. TTNN uses a lot of metaprogramming and for // some reason a static_assert fails when this is called from within our @@ -56,7 +46,7 @@ static ::ttnn::Tensor convertDataType(const ::ttnn::Tensor &input, } return ::ttnn::typecast(input, targetDataType); } else { - throw runtime_error("Unsupported storage type"); + throw std::runtime_error("Unsupported storage type"); } } @@ -288,7 +278,7 @@ run(::tt::target::ttnn::TransposeOp const *op, ::ttnn::device::Device &device, int32_t dimension1 = op->dimension1(); int32_t dimension2 = op->dimension2(); auto input_rank = in.get_shape().rank(); - std::vector dimensionOrder(input_rank); + std::vector dimensionOrder(input_rank); std::iota(dimensionOrder.begin(), dimensionOrder.end(), 0); if (dimension1 < 0) { dimension1 += input_rank; @@ -297,8 +287,7 @@ run(::tt::target::ttnn::TransposeOp const *op, ::ttnn::device::Device &device, dimension2 += input_rank; } std::swap(dimensionOrder[dimension1], dimensionOrder[dimension2]); - tensorPool.push_back( - ::ttnn::operations::data_movement::permute(in, dimensionOrder)); + tensorPool.push_back(::ttnn::permute(in, dimensionOrder)); liveTensors.try_emplace(op->out()->global_id(), &tensorPool.back()); } @@ -309,8 +298,8 @@ run(::tt::target::ttnn::MatmulOp const *op, ::ttnn::Device &device, std::list<::ttnn::Tensor> &tensorPool) { auto &lhs = *liveTensors.at(op->in0()->global_id()); auto &rhs = *liveTensors.at(op->in1()->global_id()); - tensorPool.push_back( - ::ttnn::operations::matmul::matmul(lhs, rhs, std::nullopt)); + tensorPool.push_back(::ttnn::operations::matmul::matmul( + lhs, rhs, std::nullopt, ::tt::operations::primary::Matmul{})); liveTensors.try_emplace(op->out()->global_id(), &tensorPool.back()); } // ANCHOR_END: adding_an_op_matmul_runtime diff --git a/runtime/test/CMakeLists.txt b/runtime/test/CMakeLists.txt index 584f1ab18..e3a48c925 100644 --- a/runtime/test/CMakeLists.txt +++ b/runtime/test/CMakeLists.txt @@ -24,7 +24,7 @@ if (NOT FLATBUFFERS_LIB) endif() add_library(TTRuntimeTEST INTERFACE) -add_dependencies(TTRuntimeTEST TTRuntimeTTNN TTRuntimeTTMetal TTRuntime TTEAGER_LIBRARY TTMETAL_LIBRARY) +add_dependencies(TTRuntimeTEST TTRuntimeTTNN TTRuntimeTTMetal TTRuntime TTMETAL_LIBRARY) target_include_directories(TTRuntimeTEST INTERFACE ${PROJECT_SOURCE_DIR}/runtime/include ${PROJECT_BINARY_DIR}/include/ttmlir/Target/Common @@ -32,7 +32,6 @@ target_include_directories(TTRuntimeTEST INTERFACE ) target_link_libraries(TTRuntimeTEST INTERFACE - TTEAGER_LIBRARY TTMETAL_LIBRARY TTBinary TTRuntime diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt index aa00ebb45..bb1ff8729 100644 --- a/third_party/CMakeLists.txt +++ b/third_party/CMakeLists.txt @@ -22,6 +22,7 @@ endif() set(TTMETAL_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/third_party/tt-metal/src/tt-metal/ttnn/cpp + ${PROJECT_SOURCE_DIR}/third_party/tt-metal/src/tt-metal/ttnn/cpp/ttnn/deprecated ${PROJECT_SOURCE_DIR}/third_party/tt-metal/src/tt-metal ${PROJECT_SOURCE_DIR}/third_party/tt-metal/src/tt-metal/tt_metal ${PROJECT_SOURCE_DIR}/third_party/tt-metal/src/tt-metal/tt_metal/third_party/umd @@ -31,18 +32,17 @@ set(TTMETAL_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/third_party/tt-metal/src/tt-metal/tt_metal/hw/inc/${ARCH_EXTRA_DIR} ${PROJECT_SOURCE_DIR}/third_party/tt-metal/src/tt-metal/tt_metal/third_party/umd/src/firmware/riscv/${ARCH_NAME} ${PROJECT_SOURCE_DIR}/third_party/tt-metal/src/tt-metal/tt_eager + ${PROJECT_SOURCE_DIR}/third_party/tt-metal/src/tt-metal/.cpmcache/reflect/e75434c4c5f669e4a74e4d84e0a30d7249c1e66f PARENT_SCOPE ) set(TTMETAL_LIBRARY_DIR ${PROJECT_SOURCE_DIR}/third_party/tt-metal/src/tt-metal-build/lib) set(TTNN_LIBRARY_PATH ${TTMETAL_LIBRARY_DIR}/_ttnn.so) set(TTMETAL_LIBRARY_PATH ${TTMETAL_LIBRARY_DIR}/libtt_metal.so) -set(TTEAGER_LIBRARY_PATH ${TTMETAL_LIBRARY_DIR}/libtt_eager.so) set(TTMETAL_LIBRARY_DIR ${TTMETAL_LIBRARY_DIR} PARENT_SCOPE) set(TTNN_LIBRARY_PATH ${TTNN_LIBRARY_PATH} PARENT_SCOPE) set(TTMETAL_LIBRARY_PATH ${TTMETAL_LIBRARY_PATH} PARENT_SCOPE) -set(TTEAGER_LIBRARY_PATH ${TTEAGER_LIBRARY_PATH} PARENT_SCOPE) ExternalProject_Add( tt-metal @@ -55,15 +55,15 @@ ExternalProject_Add( -DCMAKE_CXX_COMPILER_LAUNCHER=${CMAKE_CXX_COMPILER_LAUNCHER} -DTRACY_ENABLE=${TT_RUNTIME_ENABLE_PERF_TRACE} GIT_REPOSITORY https://github.com/tenstorrent/tt-metal.git - GIT_TAG v0.49.0 + GIT_TAG f6a2e5cb2b857bf4c72401bea68adf98c25bbe47 GIT_PROGRESS ON - BUILD_BYPRODUCTS ${TTNN_LIBRARY_PATH} ${TTMETAL_LIBRARY_PATH} ${TTEAGER_LIBRARY_PATH} + BUILD_BYPRODUCTS ${TTNN_LIBRARY_PATH} ${TTMETAL_LIBRARY_PATH} ) set_target_properties(tt-metal PROPERTIES EXCLUDE_FROM_ALL TRUE) -list(APPEND library_names TTNN_LIBRARY TTMETAL_LIBRARY TTEAGER_LIBRARY) -list(APPEND library_paths ${TTNN_LIBRARY_PATH} ${TTMETAL_LIBRARY_PATH} ${TTEAGER_LIBRARY_PATH}) +list(APPEND library_names TTNN_LIBRARY TTMETAL_LIBRARY) +list(APPEND library_paths ${TTNN_LIBRARY_PATH} ${TTMETAL_LIBRARY_PATH}) foreach(lib_name lib_path IN ZIP_LISTS library_names library_paths) add_library(${lib_name} SHARED IMPORTED GLOBAL)