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

layer normalization after Linear #1150

Closed
ftgreat opened this issue Aug 30, 2024 · 2 comments
Closed

layer normalization after Linear #1150

ftgreat opened this issue Aug 30, 2024 · 2 comments
Labels
question Further information is requested

Comments

@ftgreat
Copy link

ftgreat commented Aug 30, 2024

Is there any module for layer normalization after linear transformation? Thanks.

@timmoon10
Copy link
Collaborator

timmoon10 commented Aug 30, 2024

We're not aware of any kernel fusions that would help this pattern, so there's no harm in putting a LayerNorm module after the linear:

linear = te.Linear(...)
norm = te.LayerNorm(...)
y = norm(linear(x))

Using the operation-based API (see #1033), this could be:

layer = te.ops.Sequential(
    te.ops.Linear(...),
    te.ops.LayerNorm(...),
)
y = layer(x)

If we do find some kernel fusions, we would probably implement it using the operation-based API instead of implementing a new module.

@timmoon10 timmoon10 added the question Further information is requested label Aug 30, 2024
@ftgreat ftgreat closed this as completed Sep 3, 2024
@ftgreat ftgreat reopened this Sep 5, 2024
@ftgreat
Copy link
Author

ftgreat commented Sep 5, 2024

Hello, @timmoon10

I am working on a two-layer MLP setup within a tensor parallelism context (e.g., tp=2), which consists of a TEColumnParallelLinear followed by a TERowParallelLinear. I’m looking to perform a LayerNorm operation right after the output from TEColumnParallelLinear, and importantly, I want each tensor parallel split (tp slice) to have its own independent LayerNorm.

Could you provide any suggestions on whether there is an existing module that supports this, or how one might go about adding this functionality? Thank you for your assistance!

@ftgreat ftgreat closed this as completed Sep 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants