feat: add LigerMLP module - #1357
Conversation
Signed-off-by: pearblossom <[email protected]>
Signed-off-by: pearblossom <[email protected]>
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 <[email protected]>
|
@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 <[email protected]>
|
@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
|
Signed-off-by: ma-jh <[email protected]>
Signed-off-by: ma-jh <[email protected]>
|
@Tcc0403 Since the testing methodology for fp32 convergence tests on the fused kernel still needs further discussion (see #1383), I've reverted the monkey patch changes for now so they don't block this PR from being merged. This PR is now scoped to just the core kernel implementations:
The monkey patch integration will move to a follow-up PR once we've settled on an fp32 testing methodology. Also, it looks like a workflow run is waiting on approval in the Checks tab — would you mind approving it when you get a chance? |
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