Skip to content

Commit

Permalink
bugfix: avoid potential illegal memory access (#267)
Browse files Browse the repository at this point in the history
Followup of #266, add guard to mask array access.
  • Loading branch information
yzh119 authored May 28, 2024
1 parent 7304282 commit 79a2125
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions include/flashinfer/attention/prefill.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -573,11 +573,11 @@ __device__ __forceinline__ void mask_s(const uint32_t qo_idx_base, const uint32_
? (kv_idx > kv_len + q_idx - qo_len || (partition_kv && kv_idx >= chunk_end))
: kv_idx >= chunk_end);
s_frag[fx][fz][reg_id] =
out_of_boundary
? DTypeQKAccum(-5e4)
: s_frag[fx][fz][reg_id] + DTypeQKAccum(mask_mode == MaskMode::kCustom
? custom_mask[q_idx * kv_len + kv_idx]
: 0.f);
out_of_boundary ? DTypeQKAccum(-5e4)
: s_frag[fx][fz][reg_id] +
DTypeQKAccum((mask_mode == MaskMode::kCustom && q_idx < qo_len)
? custom_mask[q_idx * kv_len + kv_idx]
: 0.f);
}
}
}
Expand Down

0 comments on commit 79a2125

Please sign in to comment.