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

Refactor stacked version of FP8 Grouped Gemm for reduced overhead #3699

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jwfromm
Copy link
Contributor

@jwfromm jwfromm commented Feb 17, 2025

Summary:
X-link: https://github.com/facebookresearch/FBGEMM/pull/780

Currently, the stacked version of FP8 grouped gemm accepts lists of tensor inputs and produces a single tensor output. This reduces quite a bit of overhead when cuda graphs are used, but still requires splitting input tensors in prefill which can be costly. This diff updates the input types of stacked grouped gemm to support single tensors. Notably, since M varies across group and we do no padding, this change requires that we provide a new input tensor called M_offsets that indicates the row that each group begins at within in the first input. We create M_offsets by taking the cumulative sum of M for each group, which we may be able to further optimize.

Differential Revision: D69544396

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D69544396

Copy link

netlify bot commented Feb 17, 2025

Deploy Preview for pytorch-fbgemm-docs ready!

Name Link
🔨 Latest commit d8a3a6f
🔍 Latest deploy log https://app.netlify.com/sites/pytorch-fbgemm-docs/deploys/67b3c22c2dc6af000828002e
😎 Deploy Preview https://deploy-preview-3699--pytorch-fbgemm-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D69544396

jwfromm added a commit to jwfromm/FBGEMM that referenced this pull request Feb 17, 2025
…torch#3699)

Summary:
Pull Request resolved: pytorch#3699

X-link: facebookresearch/FBGEMM#780

Currently, the stacked version of FP8 grouped gemm accepts lists of tensor inputs and produces a single tensor output. This reduces quite a bit of overhead when cuda graphs are used, but still requires splitting input tensors in prefill which can be costly. This diff updates the input types of stacked grouped gemm to support single tensors. Notably, since M varies across group and we do no padding, this change requires that we provide a new input tensor called `M_offsets` that indicates the row that each group begins at within in the first input. We create M_offsets by taking the cumulative sum of M for each group, which we may be able to further optimize.

This diff also includes a long overdue refactor of grouped gemm setup for nvidia such that we only launch a single kernel rather than one per group. This should reduce overhead by quite a bit in some cases.

Differential Revision: D69544396
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D69544396

jwfromm added a commit to jwfromm/FBGEMM that referenced this pull request Feb 17, 2025
…torch#3699)

Summary:
Pull Request resolved: pytorch#3699

X-link: facebookresearch/FBGEMM#780

Currently, the stacked version of FP8 grouped gemm accepts lists of tensor inputs and produces a single tensor output. This reduces quite a bit of overhead when cuda graphs are used, but still requires splitting input tensors in prefill which can be costly. This diff updates the input types of stacked grouped gemm to support single tensors. Notably, since M varies across group and we do no padding, this change requires that we provide a new input tensor called `M_offsets` that indicates the row that each group begins at within in the first input. We create M_offsets by taking the cumulative sum of M for each group, which we may be able to further optimize.

This diff also includes a long overdue refactor of grouped gemm setup for nvidia such that we only launch a single kernel rather than one per group. This should reduce overhead by quite a bit in some cases.

Differential Revision: D69544396
…torch#3699)

Summary:
Pull Request resolved: pytorch#3699

X-link: facebookresearch/FBGEMM#780

Currently, the stacked version of FP8 grouped gemm accepts lists of tensor inputs and produces a single tensor output. This reduces quite a bit of overhead when cuda graphs are used, but still requires splitting input tensors in prefill which can be costly. This diff updates the input types of stacked grouped gemm to support single tensors. Notably, since M varies across group and we do no padding, this change requires that we provide a new input tensor called `M_offsets` that indicates the row that each group begins at within in the first input. We create M_offsets by taking the cumulative sum of M for each group, which we may be able to further optimize.

This diff also includes a long overdue refactor of grouped gemm setup for nvidia such that we only launch a single kernel rather than one per group. This should reduce overhead by quite a bit in some cases.

Differential Revision: D69544396
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D69544396

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants