tenstorrent / tt-metal

:metal: TT-NN operator library, and TT-Metalium low level kernel programming model.
Apache License 2.0
372 stars 43 forks source link

Move Transformers #9751

Closed ayerofieiev-tt closed 1 week ago

ayerofieiev-tt commented 2 months ago

tt_eager --> ttnn per op plan

We propose next order to breakdown this work into smaller pieces:

  1. Replace usage of a given op in C++ with ttnn analog (example)
  2. Replace usage in Python [Models, Demos, Examples, tests] (example)
  3. Remove tt_lib bindings and entries from docs (bindings, docs)
  4. Restructure op consolidating code in ttnn (see new structure)

Replacing usage in C++

Each of such usage should be replaced with a ttnn analog. For example repeat --> ttnn::repeat. This should be done for each operation. Missing operations should be added to ttnn.

Replacing usage in Python

For every unary op, look for next entries in Tests/Sweeps, Demos, Models, Examples:

⚠️ tt_lib operations might sometimes have a slightly different interface

Testing

For the best coverage, I recommend to run these workflows. If some of them fails, check if it is the same fail as on main:

Scope of Work for Transformers

There are two sets of files to move which contain two sets of ops: any variation of split qkv heads and concat heads.

eyonland commented 1 month ago

@TT-BrianLiu , is this work you could pick up here?

TT-BrianLiu commented 1 month ago

Yea, I can take a look

TT-BrianLiu commented 1 month ago

I have scoped out the work required for moving these ops (see the updated description). I will likely start with tt_eager/tt_dnn/op_library/transformer_tms/transformer_tms.hpp, then take it op by op for the ones in tt_eager/tt_dnn/op_library/nlp_tms/nlp_tms.hpp. At the end, tt_eager/tt_dnn/op_library/transformer_tms/transformer_tms.hpp will still exist since it contains other custom models ops that are completely unrelated but tt_eager/tt_dnn/op_library/transformer_tms/transformer_tms.hpp should be completely gone.

I plan to move everything into ttnn::experimental::transformer