feat: add LigerMLP module - #1357
Conversation
Signed-off-by: pearblossom <3364870135@qq.com>
Signed-off-by: pearblossom <3364870135@qq.com>
425a4df to
6aee4dd
Compare
|
@Tcc0403 I have completed all the modifications, specifically:
|
Tcc0403
left a comment
There was a problem hiding this comment.
Overall lgtm, you can also check out how liger integrates with hf/transformers via monkey_patch.py as a follow-up PR. cc @vaibhavjindal I just noticed there's a new liger cute working project on MoE, I wonder if there's any upcoming change on integration method along with new kernels.
…; update tests to cosine‑similarity for all precision validations. Signed-off-by: pearblossom <3364870135@qq.com>
|
@Tcc0403 Thanks for the review! I'll consider this PR (add As a quick sanity check for that follow-up, I made a small-scale attempt on the Llama path — swapped Before I start that follow-up PR, a couple of scoping questions:
Happy to go whichever direction makes sense. |
Let's cover all at once
Keep LigerSwiGLUMLP for bwd-compatibility |
Signed-off-by: pearblossom <3364870135@qq.com>
|
@Tcc0403 I've just pushed new commits addressing your feedback. Could you please take another look when you have a moment? Thanks! What this change includes
Two points about the
|
Summary
Add LigerMLP, a Triton-based fused SwiGLU MLP that co-optimizes the complete forward and backward dataflow rather than only the element-wise SiLU-and-gating stage.
Linked issue: #1347
Details
When running
make test, anxfailoccurs. This is not due to an error in the operator implementation, but because intest_misaligned_intermediate_size_not_supported, theintermediate_sizeis set to 431, which does not satisfy Triton'sTensorDescriptorrequirement of 16‑byte alignment.Additionally, since this implementation uses
tl.dot, when the input data type isfp32,tl.dotperforms computations usingtf32internally, which differs from PyTorch's behavior of using purefp32for computation. As a result, the numerical error between this implementation and the reference implementation is relatively larger. Therefore, when the data type isfp32, the tolerance range is set to a larger value.Testing Done
make testto ensure correctnessmake checkstyleto ensure code stylemake test-convergenceto ensure convergence