Skip to content

Enable fast FP8 GEMM for memory bound (resubmit) #3608

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

Closed
wants to merge 1 commit into from

Conversation

jiawenliu64
Copy link
Member

Summary:
This Diff (resubmit from D68193920) enables fast FP8 gemm for memory bound with adding TRT-LLM FP8 cuda gemm to fbgemm. In addition to the original kernel, this Diff extends the kernel to:

  • Support pytorch operations
  • Support cuda graph with handling scale as tensor
  • Support smaller dim M for much faster compilation time
  • Support benchmark/unittest

For decode attn linear shapes:

  • When BS=1, TRT-LLM FP8 gemm brings 2x speedup compared to BF16, while FP8 cutlass gemm’s perf is similar to BF16
  • When BS>4, TRT-LLM FP8 gemm does not bring perf gain
  • This TRT-LLM kernel is based on tensorwise quantization not rowwise.

Note: As M>4 does not bring perf gain in our use cases, we only instantiate 4 template instances to reduce compilation time (10 mins -> 2.5 mins). If we would like to increase instances for larger M in the future, we could tradeoff acceptable compilation time or dedicate cuda file to each instance with compile in parallel

Differential Revision: D68568596

Summary:
This Diff (resubmit from D68193920) enables fast FP8 gemm for memory bound with adding TRT-LLM FP8 cuda gemm to fbgemm. In addition to the original kernel, this Diff extends the kernel to:

- Support pytorch operations
- Support cuda graph with handling scale as tensor
- Support smaller dim M for much faster compilation time
- Support benchmark/unittest

For decode attn linear shapes:
- When BS=1, TRT-LLM FP8 gemm brings 2x speedup compared to BF16, while FP8 cutlass gemm’s perf is similar to BF16
- When BS>4, TRT-LLM FP8 gemm does not bring perf gain
- This TRT-LLM kernel is based on tensorwise quantization not rowwise.

Note: As M>4 does not bring perf gain in our use cases, we only instantiate 4 template instances to reduce compilation time (10 mins -> 2.5 mins). If we would like to increase instances for larger M in the future, we could tradeoff acceptable compilation time or dedicate cuda file to each instance with compile in parallel

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

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

Copy link

netlify bot commented Jan 23, 2025

Deploy Preview for pytorch-fbgemm-docs ready!

Name Link
🔨 Latest commit 4ed19bf
🔍 Latest deploy log https://app.netlify.com/sites/pytorch-fbgemm-docs/deploys/67928bd4cfc09a00088dcaf2
😎 Deploy Preview https://deploy-preview-3608--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 has been merged in 5754ce7.

q10 pushed a commit to q10/FBGEMM that referenced this pull request Apr 10, 2025
Summary:
X-link: pytorch#3608

Pull Request resolved: facebookresearch/FBGEMM#686

This Diff (resubmit from D68193920) enables fast FP8 gemm for memory bound with adding TRT-LLM FP8 cuda gemm to fbgemm. In addition to the original kernel, this Diff extends the kernel to:

- Support pytorch operations
- Support cuda graph with handling scale as tensor
- Support smaller dim M for much faster compilation time
- Support benchmark/unittest

For decode attn linear shapes:
- When BS=1, TRT-LLM FP8 gemm brings 2x speedup compared to BF16, while FP8 cutlass gemm’s perf is similar to BF16
- When BS>4, TRT-LLM FP8 gemm does not bring perf gain
- This TRT-LLM kernel is based on tensorwise quantization not rowwise.

Note: As M>4 does not bring perf gain in our use cases, we only instantiate 4 template instances to reduce compilation time (10 mins -> 2.5 mins). If we would like to increase instances for larger M in the future, we could tradeoff acceptable compilation time or dedicate cuda file to each instance with compile in parallel

Reviewed By: q10, jwfromm

Differential Revision: D68568596

fbshipit-source-id: ba8b565a564533717deb29f9d701550d99a8c759
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.

3 participants