Skip to content

Commit

Permalink
tt-mlir uplift contains LLVM uplift.
Browse files Browse the repository at this point in the history
Added torch-mlir as a third-party which we now build.

This version of torch-mlir will be included in the wheel.

Add cxxABI torch as a dependency

.
  • Loading branch information
LPanosTT committed Feb 24, 2025
1 parent f4b1b71 commit cc054de
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ results/*.xlsx
third_party/toolchain
third_party/tt-mlir
third_party/vision
third_party/torch-mlir
2 changes: 1 addition & 1 deletion env/activate
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ else
export TT_METAL_HOME="$(pwd)/third_party/tt-mlir/src/tt-mlir/third_party/tt-metal/src/tt-metal"
fi

export PYTHONPATH="$(pwd):$(pwd)/env/venv:$(pwd)/env/venv/lib:$(pwd)/install/lib:$(pwd)/.local/toolchain/python_packages/mlir_core:${TT_METAL_HOME}:${TT_METAL_HOME}/tt_eager:${TT_METAL_BUILD_HOME}/tools/profiler/bin"
export PYTHONPATH="$(pwd):$(pwd)/env/venv:$(pwd)/env/venv/lib:$(pwd)/install/lib:$(pwd)/install:$(pwd)/.local/toolchain/python_packages/mlir_core:${TT_METAL_HOME}:${TT_METAL_HOME}/tt_eager:${TT_METAL_BUILD_HOME}/tools/profiler/bin"
export ARCH_NAME="${ARCH_NAME:-wormhole_b0}"
export TT_METAL_LOGGER_LEVEL="ERROR"
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
torch-mlir
torch@https://download.pytorch.org/whl/cpu-cxx11-abi/torch-2.5.0%2Bcpu.cxx11.abi-cp311-cp311-linux_x86_64.whl
-f https://github.com/llvm/torch-mlir-release/releases/expanded_assets/dev-wheels
black
mdutils
ninja
Expand Down Expand Up @@ -36,3 +34,4 @@ opencv-contrib-python
setuptools
wheel
scikit-build
nanobind
8 changes: 6 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# SPDX-License-Identifier: Apache-2.0
from skbuild import setup
import os
import glob
from skbuild.command.install_lib import install_lib
import glob
from setuptools import find_namespace_packages
import sys

Expand Down Expand Up @@ -51,10 +51,14 @@ def run(self):
author_email="[email protected]",
license="Apache-2.0",
homepage="https://github.com/tenstorrent/tt-torch",
packages=find_namespace_packages(include=["tt_torch.*"]),
packages=find_namespace_packages(include=["tt_torch*"])
+ find_namespace_packages(
where="third_party/torch-mlir/src/torch-mlir-build/python_packages/torch_mlir"
),
description="TT PyTorch FrontEnd",
long_description=long_description,
long_description_content_type="text/markdown",
include_package_data=True,
cmake_args=cmake_args,
cmdclass={
"install_lib": install_metal_libs,
Expand Down
40 changes: 39 additions & 1 deletion third_party/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
# SPDX-License-Identifier: Apache-2.0
#

set(TT_MLIR_VERSION "a566e0e41f0b7bb5742785e5df8d4341a7d98698")
set(TT_MLIR_VERSION "1d937da293bcd621cd34a204465f185c4ab4996d")
set(TORCH_MLIR_VERSION "a265d283357f572c5437f9217ea85fa9770d374c")

if (BUILD_TOOLCHAIN)
cmake_minimum_required(VERSION 3.20)
Expand Down Expand Up @@ -74,4 +75,41 @@ else()

install(DIRECTORY ${TTMLIR_INSTALL_PREFIX}/ DESTINATION "${CMAKE_INSTALL_PREFIX}" USE_SOURCE_PERMISSIONS)

# torch-mlir build

set(TORCH_MLIR_PREFIX ${TTTORCH_SOURCE_DIR}/third_party/torch-mlir)
set(TORCH_MLIR_INSTALL_PREFIX ${TORCH_MLIR_PREFIX}/install)

set(TORCH_MLIR_BUILD_DIR ${TORCH_MLIR_PREFIX}/src/torch-mlir-build)
ExternalProject_Add(
torch-mlir
PREFIX ${TORCH_MLIR_PREFIX}
INSTALL_COMMAND ${CMAKE_COMMAND} --install ${TORCH_MLIR_BUILD_DIR}
CMAKE_GENERATOR Ninja
CMAKE_ARGS
-DCMAKE_BUILD_TYPE=Release
-DPython3_FIND_VIRTUALENV=ONLY
-DMLIR_DIR=${TTMLIR_TOOLCHAIN_DIR}/lib/cmake/mlir/
-DLLVM_DIR=${TTMLIR_TOOLCHAIN_DIR}/lib/cmake/llvm/
-DCMAKE_C_COMPILER=clang-17
-DCMAKE_CXX_COMPILER=clang++-17
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
-DTORCH_MLIR_ENABLE_STABLEHLO=ON
-DMLIR_ENABLE_BINDINGS_PYTHON=ON
-DLLVM_TARGETS_TO_BUILD=host
-DLLVM_ENABLE_ZSTD=OFF
-DTORCH_MLIR_ENABLE_LTC=ON
-DCMAKE_VISIBILITY_INLINES_HIDDEN=ON
-DCMAKE_C_VISIBILITY_PRESET=hidden
-DCMAKE_CXX_VISIBILITY_PRESET=hidden
-DCMAKE_INSTALL_PREFIX=${TORCH_MLIR_INSTALL_PREFIX}

GIT_SUBMODULES "externals/stablehlo"
GIT_PROGRESS ON
GIT_REPOSITORY https://github.com/tenstorrent/llvm-torch-mlir.git
GIT_TAG ${TORCH_MLIR_VERSION}
)

install(DIRECTORY ${TORCH_MLIR_INSTALL_PREFIX}/python_packages/torch_mlir/torch_mlir DESTINATION "${CMAKE_INSTALL_PREFIX}" USE_SOURCE_PERMISSIONS)

endif()

0 comments on commit cc054de

Please sign in to comment.