[WIP] Enable fp8 attention for triton unified attention#2235
Draft
[WIP] Enable fp8 attention for triton unified attention#2235
Conversation
Contributor
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
|
Contributor
|
Hello, However, the current implementation actually covers this case. When q and k/v are all in fp8, the dot product will also be in fp8, no descaling doesnt apply to that case. |
Author
|
Hi @cagrikymk, In the workload test for gpt-oss-120b, we see kernel level improved by 10-15% and e2e improved by 2-8%. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Triton unified attention already has the capability for doing fp8 compute, especially when using fp8 KV-cache.
However, due to the limitation of Q's precision, the attention is often computed in fp16 even when kv-cache is in fp8. The fp16 route is computational inefficient as it involves two upcasting steps for K and V and computing attention in fp16, instead of fp8.
Technical Details
In this PR, we plan to enable fp8 unified attention when all of the below are checked
When both conditions are met, we down cast Q during the load step, which gives the best perf.
Test Plan
Test Result
Submission Checklist