We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9307b2a commit 6a40e1cCopy full SHA for 6a40e1c
mlx/backend/metal/kernels/steel/attn/kernels/steel_attention.h
@@ -237,6 +237,7 @@ template <
237
if (do_causal) {
238
int q_max = (tid.x + 1) * BQ + params->qL_off;
239
kb_lim = (q_max + BK - 1) / BK;
240
+ kb_lim = min(params->NK, kb_lim);
241
}
242
243
// Loop over KV seq length
@@ -290,7 +291,7 @@ template <
290
291
292
293
// Mask out if causal
- if (do_causal && kb >= (kb_lim - (BQ + BK - 1) / BK - int(!align_K))) {
294
+ if (do_causal && kb >= (kb_lim - ((BQ + BK - 1) / BK) - int(!align_K))) {
295
using stile_t = decltype(Stile);
296
using selem_t = typename stile_t::elem_type;
297
constexpr auto neg_inf = -metal::numeric_limits<selem_t>::infinity();
0 commit comments