File tree 2 files changed +7
-6
lines changed 2 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -590,6 +590,7 @@ int32_t llama_kv_cache_unified::find_slot(const llama_ubatch & ubatch) const {
590
590
591
591
bool found = true ;
592
592
for (uint32_t i = 0 ; i < n_tokens; i++) {
593
+ const llama_pos pos = ubatch.pos [i];
593
594
const llama_seq_id seq_id = ubatch.seq_id [i][0 ];
594
595
595
596
// can we use this cell? either:
@@ -598,10 +599,12 @@ int32_t llama_kv_cache_unified::find_slot(const llama_ubatch & ubatch) const {
598
599
const bool can_use =
599
600
cells.is_empty (head_cur + i) ||
600
601
(
601
- cells.pos_get (head_cur + i) <= ubatch.pos [i] && // causal mask
602
- cells.seq_has (head_cur + i, seq_id) && // sequence mask
603
- cells.seq_count (head_cur + i) == 1 &&
604
- is_masked_swa (cells.pos_get (head_cur + i), ubatch.seq_pos_min [seq_id]) // SWA mask
602
+ cells.seq_has (head_cur + i, seq_id) && // sequence mask
603
+ cells.seq_count (head_cur + i) == 1 &&
604
+ (
605
+ cells.pos_get (head_cur + i) >= pos || // causal mask
606
+ is_masked_swa (cells.pos_get (head_cur + i), ubatch.seq_pos_min [seq_id]) // SWA mask
607
+ )
605
608
);
606
609
607
610
if (!can_use) {
Original file line number Diff line number Diff line change @@ -33,7 +33,6 @@ struct llama_kv_cache : public llama_memory_i {
33
33
// process any pending defrag/shift/etc. operations
34
34
// optionally call once before processing a new batch
35
35
// return true if any operations were performed
36
- // will reserve a new worst-case graph if needed
37
36
virtual bool update (llama_context & lctx) = 0;
38
37
39
38
// schedule a defrag if the fragmentation threshold is exceeded. otherwise, do nothing
@@ -244,7 +243,6 @@ class llama_kv_cache_unified : public llama_kv_cache {
244
243
245
244
// utilizes two instances of llama_kv_cache_unified
246
245
// the first instance is for the non-SWA layers of the model and the second instance is for the SWA layers
247
- // upon successful processing of the batch, the SWA cache removes old tokens outside the n_swa window
248
246
249
247
class llama_kv_cache_unified_iswa : public llama_kv_cache {
250
248
public:
You can’t perform that action at this time.
0 commit comments