Skip to content

Commit f281d76

Browse files
committed
bring back non-causal attention
1 parent 1549493 commit f281d76

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

llama.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4849,7 +4849,6 @@ struct llm_build_context {
48494849
const int32_t n_orig_ctx;
48504850

48514851
const bool do_rope_shift;
4852-
const bool causal_attn;
48534852
const bool do_pooling;
48544853

48554854
const llm_build_cb & cb;
@@ -4894,7 +4893,6 @@ struct llm_build_context {
48944893
kv_head (worst_case ? n_ctx - n_tokens : kv_self.head),
48954894
n_orig_ctx (cparams.n_yarn_orig_ctx),
48964895
do_rope_shift (worst_case || kv_self.has_shift),
4897-
causal_attn (hparams.causal_attn),
48984896
do_pooling (hparams.pooling_layer && cparams.do_pooling),
48994897
cb (cb),
49004898
buf_compute_meta (lctx.buf_compute_meta) {
@@ -7361,7 +7359,8 @@ static void llama_set_inputs(llama_context & lctx, const llama_batch & batch) {
73617359

73627360
for (int i = 0; i < n_kv; ++i) {
73637361
float f;
7364-
if (!lctx.kv_self.cells[i].has_seq_id(seq_id) || lctx.kv_self.cells[i].pos > pos) {
7362+
if (!lctx.kv_self.cells[i].has_seq_id(seq_id) ||
7363+
(hparams.causal_attn && lctx.kv_self.cells[i].pos > pos)) {
73657364
f = -INFINITY;
73667365
} else {
73677366
f = 0;

0 commit comments

Comments
 (0)