Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dependencies for onnx-mlir to tt-mlir project linked aga… #261

Closed
wants to merge 3 commits into from

Conversation

uazizTT
Copy link
Contributor

@uazizTT uazizTT commented Jul 31, 2024

…inst a specific version of llvm

@uazizTT uazizTT requested a review from nsmithtt as a code owner July 31, 2024 16:42
@@ -6,3 +6,4 @@ wheel
setuptools
black
pre-commit
onnx
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

onnx is a dependency for onnx-mlir project

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not listed as a dependency in their project requirements. They really require python to run their optimizer driver?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is something I found by building it that it requires onnx at least for Mac OSX build, I suspect they forgot to mention in the project requirements.

GIT_TAG ${ONNX_MLIR_VERSION}
GIT_SUBMODULES_RECURSE true
DEPENDS python-venv
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ExternalProject_Add should be moved to the third_party subdirectory. I think we should:

git mv third_party/CMakeLists.txt third_party/tt-metal.cmake

You should create third_party/onnx-mlir.cmake along with a new CMakeLists.txt:

include(tt-metal)
if (TTMLIR_ENABLE_ONNX_MLIR)
include(onnx-mlir)
endif

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok got it, let me update with the changes.

Copy link
Contributor

@nsmithtt nsmithtt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@uazizTT, this is awesome! A few requests inline. The env and third_party directories are a bit confusing, but generally I split it up this way:

  • env: Hard dependencies of tt-mlir, infrequently update. Should be thought of as the toolchain needed to do any development with tt-mlir.
  • third_party: Soft dependencies that add functionality to tt-mlir, potentially frequently updated.

Another reason, is that the idea for env is that it could be cached (and it is in GitHub CI). If any file changes under env/ then the hash changes, so we really want to be deliberate in adding / updating files in this area because llvm is relatively expensive to rebuild.

@uazizTT
Copy link
Contributor Author

uazizTT commented Jul 31, 2024

Ok thanks for the breakdown. I don't think onnx-mlir will be updated frequently but yes we can categorize it as a soft dependency. Let me move it to third-party directory.

-DCMAKE_CXX_COMPILER=/usr/bin/c++
-DPython3_ROOT_DIR=$pythonLocation
-DMLIR_DIR=${TTMLIR_TOOLCHAIN_DIR}/llvm-project/build/lib/cmake/mlir
-DCMAKE_INSTALL_PREFIX=${TTMLIR_TOOLCHAIN_DIR}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also add -DONNX_MLIR_BUILD_TESTS=OFF -DONNX_MLIR_ENABLE_JAVA=OFF?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since build tests are disable, so package onnx is not required anymore, so I removed it from dependencies.

Copy link
Contributor Author

@uazizTT uazizTT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated with requested changes.

@@ -6,3 +6,4 @@ wheel
setuptools
black
pre-commit
onnx
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not listed as a dependency in their project requirements. They really require python to run their optimizer driver?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps it's just the way that GitHub renders the PR, but this should be a git mv third_party/CMakeLists.txt third_party/tt-metal.cmake so that the blame and history remains intact.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, I am moving content from CMakeLists to tt-metal.cmake and at the same time adding new content to CMakeLists, so that's why it is not recognizing it as a move.

@@ -1,73 +1,6 @@
include(ExternalProject)
option(TTMLIR_ENABLE_ONNX_MLIR "Enable ONNX MLIR support" OFF)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should move this option to the top level CMakeLists.txt and also enable it in the "Configure CMake" step of .github/workflows/build.yml so that CI can test onnx conversion.

Copy link
Contributor Author

@uazizTT uazizTT Jul 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure I can move it to CMakeLists.txt. I will add it to build.yml in order to guard against any future changes to LLVM versions that might break the onnx-mlir build.

@uazizTT uazizTT requested a review from vmilosevic as a code owner July 31, 2024 22:11
@uazizTT uazizTT requested a review from AleksKnezevic July 31, 2024 22:11
Copy link
Contributor Author

@uazizTT uazizTT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the changes

Copy link
Contributor Author

@uazizTT uazizTT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the requested changes

@uazizTT uazizTT closed this Jul 31, 2024
@uazizTT uazizTT reopened this Jul 31, 2024
@rpavlovicTT
Copy link
Contributor

Nice changes, please fix the PR title and description. Same goes for the first commit. Here is a guide I usually follow.

PREFIX ${TTMLIR_TOOLCHAIN_DIR}
CMAKE_GENERATOR Ninja
CMAKE_ARGS
-DCMAKE_CXX_COMPILER=/usr/bin/c++
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be ${CMAKE_CXX_COMPILER}?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per the onnx build docs they suggest using this compiler on macOS, I think it's just clang, but in some kind of compatibility mode. That said we should see test we really need it, might be sufficient to use regular clang.

@uazizTT uazizTT force-pushed the integrate-onnx-mlir-project-to-tt-mlir branch from 96a7c41 to 2e7b420 Compare August 2, 2024 01:32
CMAKE_GENERATOR Ninja
CMAKE_ARGS
-DCMAKE_CXX_COMPILER=/usr/bin/c++
-DPython3_ROOT_DIR=$pythonLocation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this line is legal cmake syntax. I think $pythonLocation refers to some environment variable the suggest setting in their build docs, but they were running a bash command, I think this line gets evaluated by cmake before it constructs the underlying shell string.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit, this should be a git mv

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did use 'git mv' for this but it doesn't show as such, probably because I am not just moving content from CMakeLists to tt-metal.cmake but also adding new content to CMakeLists at the same time.

@uazizTT uazizTT force-pushed the integrate-onnx-mlir-project-to-tt-mlir branch from 2e7b420 to c5d652b Compare August 2, 2024 01:47
@uazizTT uazizTT changed the title Add dependencies for onnx and onnx-mlir to tt-mlir project linked aga… Add dependencies for onnx-mlir to tt-mlir project linked aga… Aug 2, 2024
@uazizTT uazizTT closed this Aug 2, 2024
@uazizTT uazizTT reopened this Aug 2, 2024
…tor third_party build to accomodate multiple soft dependencies.
@uazizTT uazizTT force-pushed the integrate-onnx-mlir-project-to-tt-mlir branch from c5d652b to 3b19a4d Compare August 2, 2024 13:53
@uazizTT uazizTT force-pushed the integrate-onnx-mlir-project-to-tt-mlir branch from c49499d to d213074 Compare August 3, 2024 00:50
@uazizTT uazizTT force-pushed the integrate-onnx-mlir-project-to-tt-mlir branch from d213074 to 1a321b6 Compare August 3, 2024 03:53
@@ -45,6 +45,7 @@ ExternalProject_Add(
-DPython3_EXECUTABLE=${TTMLIR_TOOLCHAIN_DIR}/venv/bin/python
-DCMAKE_INSTALL_PREFIX=${TTMLIR_TOOLCHAIN_DIR}
-DLLVM_ENABLE_PROJECTS=mlir
-DLLVM_ENABLE_RTTI=ON
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooof, this sucks :(

Ok this is actually in deal breaker territory, let's meet next week to discuss our options. I'll also file an issue on onnx-mlir to see if they ever plan on removing this requirement: onnx/onnx-mlir#2897

@uazizTT uazizTT closed this Aug 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants