Skip to content

Commit 5ec41a1

Browse files
committed
fix asan error
1 parent 18842b6 commit 5ec41a1

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/llama-kv-cache.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1256,8 +1256,9 @@ void llama_kv_cache::set_input_kq_mask(ggml_tensor * dst, const llama_ubatch * u
12561256
const llama_pos p1 = ubatch->pos[i];
12571257

12581258
// for M-RoPE
1259-
llama_pos p1_x = ubatch->pos[i + ubatch->n_tokens*2];
1260-
llama_pos p1_y = ubatch->pos[i + ubatch->n_tokens];
1259+
const bool is_2d = ubatch->is_pos_2d();
1260+
const llama_pos p1_x = is_2d ? ubatch->pos[i + ubatch->n_tokens*2] : 0;
1261+
const llama_pos p1_y = is_2d ? ubatch->pos[i + ubatch->n_tokens] : 0;
12611262

12621263
const uint64_t idst = n_kv*(h*n_stream*n_tps_pad + s*n_tps_pad + ii);
12631264

@@ -1279,7 +1280,7 @@ void llama_kv_cache::set_input_kq_mask(ggml_tensor * dst, const llama_ubatch * u
12791280
}
12801281

12811282
// M-RoPE causal mask
1282-
if (causal_attn && ubatch->is_pos_2d() && p0 == p1) {
1283+
if (causal_attn && is_2d && p0 == p1) {
12831284
const auto & p0_ext = cells.ext_get(j);
12841285
if (p0_ext.is_2d_gt(p1_x, p1_y)) {
12851286
continue;

0 commit comments

Comments
 (0)