Skip to content

Commit b96bbdc

Browse files
committed
kv-cache : revert the (n_swa + n_ubatch) change (for next PR)
ggml-ci
1 parent 3549dc8 commit b96bbdc

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
@@ -1713,14 +1713,14 @@ llama_kv_cache_unified_iswa::llama_kv_cache_unified_iswa(
17131713
bool swa_full,
17141714
uint32_t kv_size,
17151715
uint32_t n_seq_max,
1716-
uint32_t n_ubatch,
1716+
uint32_t n_batch,
17171717
uint32_t n_pad) : hparams(model.hparams) {
17181718
llama_kv_cache_unified::layer_filter_cb filter_base = [&](int32_t il) { return !model.hparams.is_swa(il); };
17191719
llama_kv_cache_unified::layer_filter_cb filter_swa = [&](int32_t il) { return model.hparams.is_swa(il); };
17201720

17211721
const uint32_t size_base = kv_size;
17221722

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

17251725
// when using full-size SWA cache, we set the SWA cache size to be equal to the base cache size
17261726
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
@@ -13234,7 +13234,7 @@ llama_memory_i * llama_model::create_memory(const llama_memory_params & params,
1323413234
params.swa_full,
1323513235
cparams.n_ctx,
1323613236
cparams.n_seq_max,
13237-
cparams.n_ubatch,
13237+
cparams.n_batch,
1323813238
padding);
1323913239
} else {
1324013240
GGML_ASSERT(!hparams.is_swa_any());

tools/server/server.cpp

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

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

3213-
if (slot.n_past > 0 && slot.n_past + 32 < (int) slot.cache_tokens.size()) {
3218+
if (slot.n_past > 0 && slot.n_past < (int) slot.cache_tokens.size()) {
32143219
const auto pos_min = llama_kv_self_seq_pos_min(ctx, slot.id);
32153220
if (pos_min > 0) {
32163221
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);
@@ -3424,10 +3429,11 @@ struct server_context {
34243429

34253430
// retry with half the batch size to try to find a free slot in the KV cache
34263431
n_batch /= 2;
3427-
i -= n_batch;
34283432

34293433
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);
34303434

3435+
i -= n_batch;
3436+
34313437
continue; // continue loop of n_batch
34323438
}
34333439

0 commit comments

Comments
 (0)