Skip to content

Commit 99653c3

Browse files
committed
kv-cache : revert the (n_swa + n_ubatch) change (for next PR)
ggml-ci
1 parent 582792b commit 99653c3

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

src/llama-kv-cache.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1721,14 +1721,14 @@ llama_kv_cache_unified_iswa::llama_kv_cache_unified_iswa(
17211721
bool swa_full,
17221722
uint32_t kv_size,
17231723
uint32_t n_seq_max,
1724-
uint32_t n_ubatch,
1724+
uint32_t n_batch,
17251725
uint32_t n_pad) : hparams(model.hparams) {
17261726
llama_kv_cache_unified::layer_filter_cb filter_base = [&](int32_t il) { return !model.hparams.is_swa(il); };
17271727
llama_kv_cache_unified::layer_filter_cb filter_swa = [&](int32_t il) { return model.hparams.is_swa(il); };
17281728

17291729
const uint32_t size_base = kv_size;
17301730

1731-
uint32_t size_swa = std::min(size_base, GGML_PAD(hparams.n_swa*n_seq_max + n_ubatch, n_pad));
1731+
uint32_t size_swa = std::min(size_base, GGML_PAD(hparams.n_swa*n_seq_max + n_batch, n_pad));
17321732

17331733
// when using full-size SWA cache, we set the SWA cache size to be equal to the base cache size
17341734
if (swa_full) {

src/llama-kv-cache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ class llama_kv_cache_unified_iswa : public llama_kv_cache {
252252
bool swa_full,
253253
uint32_t kv_size,
254254
uint32_t n_seq_max,
255-
uint32_t n_ubatch,
255+
uint32_t n_batch,
256256
uint32_t n_pad);
257257

258258
~llama_kv_cache_unified_iswa() = default;

src/llama-model.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13228,7 +13228,7 @@ llama_memory_i * llama_model::create_memory(const llama_memory_params & params,
1322813228
params.swa_full,
1322913229
cparams.n_ctx,
1323013230
cparams.n_seq_max,
13231-
cparams.n_ubatch,
13231+
cparams.n_batch,
1323213232
padding);
1323313233
} else {
1323413234
GGML_ASSERT(!hparams.is_swa_any());

tools/server/server.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2019,6 +2019,11 @@ struct server_context {
20192019
params_base.n_cache_reuse = 0;
20202020
SRV_WRN("%s\n", "cache_reuse is not supported by this context, it will be disabled");
20212021
}
2022+
2023+
if (!params_base.speculative.model.path.empty()) {
2024+
SRV_ERR("%s\n", "err: speculative decode is not supported by this context");
2025+
return false;
2026+
}
20222027
}
20232028

20242029
return true;
@@ -3211,7 +3216,7 @@ struct server_context {
32113216
slot.cache_tokens.clear(); // TODO: not needed, will be cleared later via "keep_first()"
32123217
}
32133218

3214-
if (slot.n_past > 0 && slot.n_past + 32 < (int) slot.cache_tokens.size()) {
3219+
if (slot.n_past > 0 && slot.n_past < (int) slot.cache_tokens.size()) {
32153220
const auto pos_min = llama_kv_self_seq_pos_min(ctx, slot.id);
32163221
if (pos_min > 0) {
32173222
SLT_WRN(slot, "n_past = %d, cache_tokens.size() = %d, seq_id = %d, pos_min = %d\n", slot.n_past, (int) slot.cache_tokens.size(), slot.id, pos_min);
@@ -3425,10 +3430,11 @@ struct server_context {
34253430

34263431
// retry with half the batch size to try to find a free slot in the KV cache
34273432
n_batch /= 2;
3428-
i -= n_batch;
34293433

34303434
SRV_WRN("failed to find free space in the KV cache, retrying with smaller batch size - try increasing it via the context size or enable defragmentation, i = %d, n_batch = %d, ret = %d\n", i, n_batch, ret);
34313435

3436+
i -= n_batch;
3437+
34323438
continue; // continue loop of n_batch
34333439
}
34343440

0 commit comments

Comments
 (0)