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

Faster Custom Paged Attention kernels #372

Merged
merged 15 commits into from
Jan 30, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
lint
sanyalington committed Jan 23, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 52a0b95ba5002b1bdc505cc6ac8dddcc7490936b
8 changes: 4 additions & 4 deletions csrc/rocm/attention.cu
Original file line number Diff line number Diff line change
@@ -706,13 +706,13 @@ __launch_bounds__(NUM_THREADS, 5) void paged_attention_ll4mi_QKV_mfma16_kernel(
// write logits to shared mem
for (int token_depth = 0; token_depth < TLOOP; token_depth++) {
dout[token_depth] *= inv_sum_scale;
if constexpr(LOGITS_RTZ_CONVERSION) {
if constexpr (LOGITS_RTZ_CONVERSION) {
// use rtz conversion for performance, with no visible impact on accuracy
shared_logits[warpid][token_depth][lane16id][rowid] =
from_floatx4_rtz<scalar_t>(dout[token_depth]);
from_floatx4_rtz<scalar_t>(dout[token_depth]);
} else {
shared_logits[warpid][token_depth][lane16id][rowid] =
from_floatx4<scalar_t>(dout[token_depth]);
from_floatx4<scalar_t>(dout[token_depth]);
}
}
// write out partition max_logits and exp_sum
@@ -1231,7 +1231,7 @@ __launch_bounds__(NUM_THREADS) void paged_attention_ll4mi_QKV_mfma4_kernel(
// are 4x16 tokens across warp
_B16x4 logits[QHLOOP];
for (int h = 0; h < QHLOOP; h++) {
if constexpr(LOGITS_RTZ_CONVERSION) {
if constexpr (LOGITS_RTZ_CONVERSION) {
// use rtz for faster performance with no perceivable accuracy loss
logits[h] = from_floatx4_rtz<scalar_t>(dout[h]);
} else {