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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kernel Fusion using torch.jit #10

Open
3 tasks
xrsrke opened this issue Oct 25, 2023 · 3 comments
Open
3 tasks

Kernel Fusion using torch.jit #10

xrsrke opened this issue Oct 25, 2023 · 3 comments
Assignees
Labels
good first issue Good for newcomers

Comments

@xrsrke
Copy link
Owner

xrsrke commented Oct 25, 2023

Fuse some popular functions and automatically replace modules in an existing 馃 transformers model with their corresponding fusion module

APIs

from pipegoose.nn import fusion

# and other parallelism ...
model = TensorParallel(model, parallel_context).parallelize()
model.fuse()

# or selective kernel fusion
model.fuse([fusion.LayerNorm, fusion.Attention])

TODOs

  • Fuse bias addition and GeLU [link]
  • Fuse bias addition and dropout [link]
  • Use torch.fx to detect modules that can be fused and replace them with the fused version.

Reading (could be ignored)

@xrsrke xrsrke added help wanted Extra attention is needed good first issue Good for newcomers labels Oct 25, 2023
@xrsrke xrsrke assigned xrsrke and unassigned xrsrke Nov 14, 2023
@sami-bg
Copy link

sami-bg commented Nov 19, 2023

Can you assign this to me? I'd like to give this a shot

@sami-bg
Copy link

sami-bg commented Nov 19, 2023

#36

@xrsrke
Copy link
Owner Author

xrsrke commented Nov 19, 2023

@sami-bg Check out torch.fx. We could use it to detect modules in a transformers model that can be fused and replace them with the fused version: model.transformers.blocks[0].dropout = fused_dropout

But we don't do it manually. Check out this tutorial for how to use torch.fx: https://pytorch.org/tutorials/intermediate/fx_conv_bn_fuser.html

@xrsrke xrsrke removed the help wanted Extra attention is needed label Nov 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
Status: In Progress
Development

No branches or pull requests

2 participants