Commit e01c9f187 for llama.cpp
commit e01c9f1875e8a96674756ed144aa9701498b83dd
Author: CC <65151926+realMoana@users.noreply.github.com>
Date: Mon Nov 9 06:32:27 2026 -0500
metal : prevent out-of-bounds writes to the Metal FA output buffer (#31662)
Co-authored-by: Zhuomin Chen <moanachen@Mac.attlocal.net>
diff --git a/ggml/src/ggml-metal/kernels/fa_vec_common.metal b/ggml/src/ggml-metal/kernels/fa_vec_common.metal
index c81e4d09b..1a96c6f7e 100644
--- a/ggml/src/ggml-metal/kernels/fa_vec_common.metal
+++ b/ggml/src/ggml-metal/kernels/fa_vec_common.metal
@@ -131,9 +131,11 @@ kernel void kernel_flash_attn_ext_vec(
}
// zero out so
- for (short qq = 0; qq < Q; ++qq) {
- for (short i = 0; i < DV4/NL; ++i) {
- so4[qq*DV4 + i*NL] = (o4_t) 0.0f;
+ if ((DV4/NL % NW == 0) || tiisg < NL) {
+ for (short qq = 0; qq < Q; ++qq) {
+ for (short i = 0; i < DV4/NL; ++i) {
+ so4[qq*DV4 + i*NL] = (o4_t) 0.0f;
+ }
}
}