-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Skeleton for Attention(23) on CUDA #25684
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can commit the suggested changes from lintrunner.
T* output_qk // Q*K output | ||
) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
T* output_qk // Q*K output | |
) { | |
T* output_qk // Q*K output | |
) { |
template class NaiveAttention<T>; \ | ||
template void ComputeAttentionProbs<T>(cudaStream_t stream, T * attention_probs, const T* Q, const T* K, const Tensor* mask_index, \ | ||
const AttentionParameters& parameters, const T* past_key, T* present_key, \ | ||
T* output_qk); \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
T* output_qk); \ | |
T* output_qk); \ |
@@ -0,0 +1,420 @@ | |||
/* |
Check warning
Code scanning / lintrunner
CLANGFORMAT/format Warning
Run lintrunner -a to apply this patch.
MultiHeadAttention cuda implementation is close to onnx Attention definition. |
Description
Draft for Attention(23) on CUDA.
Two directions for the implementations.
contribops
As it is, it does not seem to support SoftCap options and all the modes for the qk output. What about bfloat16?
cublasLtMatMul
Follows the same implementation the one made on CPU, relies on cublasLtMatMul, it should handle all types (bfloat16, float8). It misses cuda code for the cache copy and softcap.