You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TransformerLayer implementation is overly complex and difficult to follow #2903
I understand that you want to implement a single TransformerLayer class to support various model architectures.
However, this design leads to an issue: the code inside the TransformerLayer class has become overly complex, with too many parameters and a large number of if-else statements. For beginners, it is really difficult to figure out how to configure the parameters to fit their own model structures.
Thanks for the feedback — that's a very fair point. Historically TransformerLayer grew as a single configurable layer to cover standard Transformer variants, while TE focused primarily on lower-level building blocks.
We agree that model-specific implementations are much easier to read and configure (similar to Hugging Face transformers/models), and we're moving in that direction by introducing a transformer_engine.pytorch.models namespace with dedicated per-model layers. The first PR introducing this structure — with DeepSeekV3Layer (MultiLatentAttention + DeepSeekV3MoE) under transformer_engine/pytorch/models/deepseek_v3/ — is already open here: #3471.
Activity
pggPL commentedon Dec 1, 2026
Thanks for the feedback — that's a very fair point. Historically
TransformerLayergrew as a single configurable layer to cover standard Transformer variants, while TE focused primarily on lower-level building blocks.We agree that model-specific implementations are much easier to read and configure (similar to Hugging Face
transformers/models), and we're moving in that direction by introducing atransformer_engine.pytorch.modelsnamespace with dedicated per-model layers. The first PR introducing this structure — withDeepSeekV3Layer(MultiLatentAttention+DeepSeekV3MoE) undertransformer_engine/pytorch/models/deepseek_v3/— is already open here: #3471.