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

Split TTNN into C++ library and Python binding #16418

Closed
marty1885 opened this issue Jan 3, 2025 · 2 comments
Closed

Split TTNN into C++ library and Python binding #16418

marty1885 opened this issue Jan 3, 2025 · 2 comments

Comments

@marty1885
Copy link
Contributor

Is your feature request related to a problem? Please describe.
GGML requires minimal dependency. However currently TTNN built the Python binding into the same shared object as the rest of TTNN. Forcing any programs linked against TTNN to also depend on Python. Which I expect to cause trouble while upstreaming the GGML backend.

Currently the only way to get rid of the Python dependency is via an undocumented flag WITH_PYTHON_BINDINGS in CMake. Which is a stop gap implemented early on. But forces 2 builds of TTNN if users wish to also develop in Python and there is no way in GGML to detect if TTNN wants to link against Python from outside.

Describe the solution you'd like
Split TTNN into 2 components. A C++ library and a Python binding.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

@marty1885 marty1885 added the feature-request External feature request label Jan 3, 2025
@ayerofieiev-tt ayerofieiev-tt self-assigned this Jan 3, 2025
@ayerofieiev-tt ayerofieiev-tt changed the title [Feature Request] Split TTNN into C++ library and Python binding Split TTNN into C++ library and Python binding Jan 31, 2025
@ayerofieiev-tt ayerofieiev-tt removed their assignment Feb 1, 2025
@ayerofieiev-tt ayerofieiev-tt removed the feature-request External feature request label Feb 1, 2025
@ayerofieiev-tt ayerofieiev-tt changed the title Split TTNN into C++ library and Python binding [CMake] Split TTNN into C++ library and Python binding Feb 1, 2025
@ayerofieiev-tt ayerofieiev-tt changed the title [CMake] Split TTNN into C++ library and Python binding Split TTNN into C++ library and Python binding Feb 1, 2025
@dgomezTT dgomezTT self-assigned this Feb 7, 2025
@dgomezTT
Copy link
Contributor

dgomezTT commented Feb 7, 2025

I'll check this one @ayerofieiev-tt

dgomezTT added a commit that referenced this issue Mar 1, 2025
Now we will have to libraries, ttnncpp and ttnn, where ttnncpp will work
as c++ backend while the tin library is the wrapper for python

### Ticket
#16418

### Problem description
Our implementation of ttnn was coupled to python, so if anybody wanted
to use the api directly from cpp, it could generate some linking issues.

### What's changed
With ttnn divided in two, a user could link to the cpp backend without
having to link to python, or use the python wrapper, depending on the
use case. This gives more flexibility to our users to decide the way
they decide to interact with the backend

### Checklist
- [x] [All post
commit](https://github.com/tenstorrent/tt-metal/actions/workflows/all-post-commit-workflows.yaml)
CI passes
- [x] [Blackhole Post
commit](https://github.com/tenstorrent/tt-metal/actions/workflows/blackhole-post-commit.yaml)
CI passes (if applicable)
- [X ] [Model
regression](https://github.com/tenstorrent/tt-metal/actions/workflows/perf-models.yaml)
CI passes (if applicable)
- [x] [Device performance
regression](https://github.com/tenstorrent/tt-metal/actions/workflows/perf-device-models.yaml)
CI passes (if applicable)
- [ ] **(For models and ops writers)** Full [new models
tests](https://github.com/tenstorrent/tt-metal/actions/workflows/full-new-models-suite.yaml)
CI passes (if applicable)
- [ ] New/Existing tests provide coverage for changes
@dgomezTT
Copy link
Contributor

dgomezTT commented Mar 1, 2025

#17957

Added a division between python and C++, If you want to compile only without python, you can use the flag --without-python-bindings (which is documented now) and it will generate a ttnncpp library. Otherwise you will get the classical ttnn library. If you want to push this forward, you can change the type of ttnncpp to be dynamic and link to the library you need.

@dgomezTT dgomezTT closed this as completed Mar 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants