Skip to content

metal : optimize multi-sequence FA vec kernel #13493

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

Merged
merged 2 commits into from
May 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 5 additions & 0 deletions ggml/src/ggml-metal/ggml-metal.metal
Original file line number Diff line number Diff line change
Expand Up @@ -3887,6 +3887,11 @@ kernel void kernel_flash_attn_ext_vec(
sm[tiisg] = pm[ic + tiisg];
}

// skip -INF blocks
if (simd_max(sm[tiisg]) == -INFINITY) {
continue;
}

// Q*K^T
{
// each simdgroup processes 1 query and NE (NW/NL) head elements
Expand Down
4 changes: 2 additions & 2 deletions tools/batched-bench/batched-bench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ int main(int argc, char ** argv) {

common_batch_clear(batch);

for (int i = 0; i < pp; ++i) {
for (int j = 0; j < (is_pp_shared ? 1 : pl); ++j) {
for (int j = 0; j < (is_pp_shared ? 1 : pl); ++j) {
for (int i = 0; i < pp; ++i) {
common_batch_add(batch, 0, i, { j }, false);
}
}
Expand Down
Loading