From 1fde6dfc4da385d5ed6fd1be52a92980501c2ef4 Mon Sep 17 00:00:00 2001 From: Aleks Knezevic Date: Wed, 18 Sep 2024 01:54:24 +0000 Subject: [PATCH] WIP CI --- .github/Dockerfile.ci | 28 ---------------------------- .github/workflows/build-and-test.yml | 6 +++--- CMakeLists.txt | 3 +++ src/tt/CMakeLists.txt | 12 +++++++----- tests/TTIR/test_mnist.py | 2 +- tests/conftest.py | 2 +- third_party/CMakeLists.txt | 12 +++++++++--- 7 files changed, 24 insertions(+), 41 deletions(-) diff --git a/.github/Dockerfile.ci b/.github/Dockerfile.ci index 4449880..26f35f8 100644 --- a/.github/Dockerfile.ci +++ b/.github/Dockerfile.ci @@ -26,34 +26,6 @@ RUN cmake -B toolchain -DTOOLCHAIN=ON third_party/ && \ cmake -B env/build env && \ cmake --build env/build -# Self-test - -# Build project to test the container -RUN source env/activate && \ - cmake -G Ninja \ - -B build \ - -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_C_COMPILER=clang \ - -DCMAKE_CXX_COMPILER=clang++ \ - -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ - -DTTMLIR_ENABLE_RUNTIME=ON \ - -DTTMLIR_ENABLE_RUNTIME_TESTS=ON \ - -DTTMLIR_ENABLE_STABLEHLO=ON - -RUN source env/activate && \ - cmake --build build --config Release - -RUN source env/activate && \ - cmake --build build -- ttrt - -# Run clang-tidy -RUN source env/activate && \ - cmake --build build -- clang-tidy - -# Run the tests -RUN source env/activate && \ - cmake --build build -- check-ttmlir - # Final stage FROM ghcr.io/tenstorrent/tt-xla/tt-xla-base-ubuntu-22-04:${FROM_TAG} AS ci diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 58eab69..cc15163 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -45,7 +45,7 @@ jobs: run: | source venv/activate cmake -G Ninja \ - -B ${{ steps.strings.outputs.build-output-dir }} + -B ${{ steps.strings.outputs.build-output-dir }} \ -S ${{ steps.strings.outputs.work-dir }} - name: Build @@ -60,14 +60,14 @@ jobs: # https://github.com/actions/upload-artifact?tab=readme-ov-file#permission-loss - name: 'Tar install directory' shell: bash - working-directory: ${{ steps.strings.outputs.install-output-dir }} + working-directory: ${{ steps.strings.outputs.build-output-dir }} run: tar cvf artifact.tar . - name: Upload install folder to archive uses: actions/upload-artifact@v4 with: name: install-artifacts - path: ${{ steps.strings.outputs.install-output-dir }}/artifact.tar + path: ${{ steps.strings.outputs.build-output-dir }}/artifact.tar - name: Get the latest tag shell: bash diff --git a/CMakeLists.txt b/CMakeLists.txt index e2193c6..904a467 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,9 @@ set(CMAKE_CXX_STANDARD 17) set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti") +set(CMAKE_INSTALL_PREFIX ${TTPJRT_SOURCE_DIR}/install) +set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib) + # set(ASAN_FLAGS "-fsanitize=address -fno-omit-frame-pointer") # set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ASAN_FLAGS}") if(CMAKE_BUILD_TYPE STREQUAL "Debug") diff --git a/src/tt/CMakeLists.txt b/src/tt/CMakeLists.txt index 20a509d..0a9cef8 100644 --- a/src/tt/CMakeLists.txt +++ b/src/tt/CMakeLists.txt @@ -27,12 +27,14 @@ target_link_libraries(TTPJRTTTDylib PUBLIC TTPJRTTT) # # Output to the project wide python binary directory tree. set_target_properties(TTPJRTTTDylib - PROPERTIES - PREFIX "" # Disable "lib" prefix. - LIBRARY_OUTPUT_NAME pjrt_plugin_tt - RUNTIME_OUTPUT_DIRECTORY "${_NATIVE_PYTHON_DIR}" - LIBRARY_OUTPUT_DIRECTORY "${_NATIVE_PYTHON_DIR}" +PROPERTIES +PREFIX "" # Disable "lib" prefix. +LIBRARY_OUTPUT_NAME pjrt_plugin_tt +# RUNTIME_OUTPUT_DIRECTORY "${_NATIVE_PYTHON_DIR}" +# LIBRARY_OUTPUT_DIRECTORY "${_NATIVE_PYTHON_DIR}" +INSTALL_RPATH_USE_LINK_PATH TRUE ) +install(TARGETS TTPJRTTTDylib DESTINATION lib) target_link_options(TTPJRTTTDylib PRIVATE "-Wl,--no-undefined") diff --git a/tests/TTIR/test_mnist.py b/tests/TTIR/test_mnist.py index af7205c..619a7ba 100644 --- a/tests/TTIR/test_mnist.py +++ b/tests/TTIR/test_mnist.py @@ -30,7 +30,7 @@ def module_relu(a): verify_module(module_relu, [(32, 32)]) -# @pytest.mark.xfail +@pytest.mark.xfail def test_softmax(): def module_softmax(a): return jax.nn.softmax(a) diff --git a/tests/conftest.py b/tests/conftest.py index bc27a72..5382bb5 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -4,7 +4,7 @@ import jax._src.xla_bridge as xb def initialize(): - path = os.path.join(os.path.dirname(__file__), "../build/src/tt/pjrt_plugin_tt.so") + path = os.path.join(os.path.dirname(__file__), "../install/lib/pjrt_plugin_tt.so") if not os.path.exists(path): raise FileNotFoundError(f"Could not find tt_pjrt C API plugin at {path}, have you compiled the project?") diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt index dde70f6..a44c57e 100644 --- a/third_party/CMakeLists.txt +++ b/third_party/CMakeLists.txt @@ -1,4 +1,4 @@ -set(TT_MLIR_VERSION "f955a08e8836e41a3333ca20a3bbe193ce91b2a0") +set(TT_MLIR_VERSION "a4628f8e8fe900ec64bd96565d80a487b76f5755") set(LOGURU_VERSION "4adaa185883e3c04da25913579c451d3c32cfac1") if (TOOLCHAIN STREQUAL "ON") @@ -19,7 +19,7 @@ if (TOOLCHAIN STREQUAL "ON") else() include(ExternalProject) add_subdirectory(pjrt_c_api) - set(TTMLIR_LIB_DIR ${PROJECT_SOURCE_DIR}/third_party/tt-mlir/src/tt-mlir-build/lib/SharedLib) + set(TTMLIR_LIB_DIR ${TTPJRT_SOURCE_DIR}/install) ExternalProject_Add( tt-mlir PREFIX ${TTPJRT_SOURCE_DIR}/third_party/tt-mlir @@ -31,12 +31,18 @@ else() -DTT_RUNTIME_ENABLE_TTNN=ON -DTTMLIR_ENABLE_STABLEHLO=ON -DTTMLIR_ENABLE_RUNTIME=ON + -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} GIT_REPOSITORY git@github.com:tenstorrent/tt-mlir.git GIT_TAG ${TT_MLIR_VERSION} GIT_PROGRESS ON - INSTALL_COMMAND "" ) + # #TODO: Remove this once we have a proper install target + # message(STATUS "Copying ttmetal libraries from ${PROJECT_SOURCE_DIR}/third_party/tt-mlir/src/tt-mlir/third_party/tt-metal/src/tt-metal-build/lib to ${TTMLIR_LIB_DIR}/lib") + # execute_process( + # COMMAND /bin/bash -c "mkdir -p ${TTMLIR_LIB_DIR}/lib/ && cp ${PROJECT_SOURCE_DIR}/third_party/tt-mlir/src/tt-mlir/third_party/tt-metal/src/tt-metal-build/lib/* ${TTMLIR_LIB_DIR}/lib/" + # ) + set_target_properties(tt-mlir PROPERTIES EXCLUDE_FROM_ALL TRUE) # Link to all TTMLIR libraries in ${TTMLIR_INSTALL_DIR}/install/lib