Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
47a1fd0
server : speculative decoding using checkpoints
srogmann Feb 9, 2026
9586727
server : fix draft check with checkpoints
srogmann Feb 10, 2026
da87251
server : rename spec vars
srogmann Feb 10, 2026
81038a6
server : log levels
srogmann Feb 10, 2026
71e50c8
server : refactored spec logic to speculative.cpp
srogmann Feb 24, 2026
21ae577
server : renamed spec checkpoints option
srogmann Feb 24, 2026
e6fa5ee
server : fix spec checkpoints, logging
srogmann Mar 1, 2026
951aca0
speculative : checkpoints with draft model, logging
srogmann Mar 8, 2026
9245c24
server : n_tokens_cur and create_checkpoint in draft
srogmann Mar 10, 2026
e62e74d
server : fix server_speculative_callback (slot.id)
srogmann Mar 11, 2026
29d8410
spec : fix ngram-map/begin idx_last_check
srogmann Mar 11, 2026
0a79738
spec : init ckpt (begin() wasn't called)
srogmann Mar 13, 2026
a086c1b
tests : add extra_args support to ServerProcess
petter-b Mar 21, 2026
e4cd6a4
tests : add regression test for spec decoding KV cache leak
petter-b Mar 21, 2026
801bf74
server : fix attention KV leak after checkpoint restore
petter-b Mar 21, 2026
50245db
spec : clean up attention KV entries in rewind for hybrid models
petter-b Mar 21, 2026
613649f
tests : add f16 checkpoint determinism test for hybrid model
petter-b Mar 21, 2026
177c1e8
tests : add grammar sampler state test for spec checkpoints
petter-b Mar 21, 2026
dff7d35
server : save and restore sampler state in spec checkpoints
petter-b Mar 21, 2026
4a85599
tests : add crash regression test for spec decode KV exhaustion
petter-b Mar 21, 2026
57d5b7a
server : fix crash on decode failure during speculative draft
petter-b Mar 21, 2026
88cadd3
server : disable spec checkpoints for standard KV cache
petter-b Mar 21, 2026
4b836fd
server : warn when quantized V cache is used with spec checkpoints
petter-b Mar 21, 2026
8b997d9
tests : add CI-compatible spec checkpoint determinism test
petter-b Mar 21, 2026
33430cc
speculative : move post-restore KV cleanup into speculative layer
petter-b Mar 21, 2026
4c74035
server : add diagnostic counters for speculation debugging
petter-b Mar 23, 2026
0f8e49c
kv : add duplicate cell detection and seq_rm toggle for debugging
petter-b Mar 23, 2026
6b38caf
kv : write duplicate detection to file for container retrieval
petter-b Mar 23, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions common/arg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3525,6 +3525,20 @@ common_params_context common_params_parser_init(common_params & params, llama_ex
params.speculative.ngram_min_hits = value;
}
).set_examples({LLAMA_EXAMPLE_SERVER}));
add_opt(common_arg(
{"--spec-use-checkpoints"}, "[on|off|auto]",
string_format("use checkpoints to rewind token history in recurrent models ('on', 'off', or 'auto', default: %s)",
params.speculative.use_checkpoints ? "on" : "off"),
[](common_params & params, const std::string & value) {
if (is_truthy(value) || is_autoy(value)) {
params.speculative.use_checkpoints = true;
} else if (is_falsey(value)) {
params.speculative.use_checkpoints = false;
} else {
throw std::invalid_argument("invalid value for --spec-use-checkpoints");
}
}
).set_examples({LLAMA_EXAMPLE_SERVER}));
add_opt(common_arg(
{"-ctkd", "--cache-type-k-draft"}, "TYPE",
string_format(
Expand Down
2 changes: 2 additions & 0 deletions common/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,8 @@ struct common_params_speculative {
uint16_t ngram_size_n = 12; // ngram size for lookup
uint16_t ngram_size_m = 48; // mgram size for speculative tokens
uint16_t ngram_min_hits = 1; // minimum hits at ngram/mgram lookup for mgram to be proposed
bool use_checkpoints = false; // use checkpoints to rewind in token history of recurrent models


std::shared_ptr<common_ngram_mod> ngram_mod;

Expand Down
8 changes: 4 additions & 4 deletions common/ngram-map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ void common_ngram_map_begin(
count_keys, count_keys_del, count_values_del, count_map_entries_upd);
}

map.idx_last_check = (map.size_last_begin > 0) ? map.size_last_begin - 1 : 0;
map.idx_last_check = size_begin;
map.size_last_begin = size_begin;
}

Expand All @@ -231,7 +231,7 @@ void common_ngram_map_draft(common_ngram_map & map,
GGML_ABORT("%s: cur_len exceeds UINT32_MAX: %zu", __func__, cur_len);
}

if (map.idx_last_check > cur_len) {
if (map.idx_last_check > cur_len) {
// Should not happen because of common_ngram_map_begin().
GGML_ABORT("%s: map.idx_last_check > cur_len: %zu > %zu", __func__, map.idx_last_check, cur_len);
}
Expand Down Expand Up @@ -386,7 +386,7 @@ void common_ngram_map_draft(common_ngram_map & map,
LOG_DBG("%s: key_idx = %zu, key_offset = %zu, key_num = %d, draft.size = %zu\n", __func__,
curr_key.key_idx, key_offset, curr_key.key_num, draft.size());

map.last_draft_created = false;
map.last_draft_created = true;
map.last_draft_key_idx = key_offset;
map.last_draft_value_idx = 0; // value 0 is used for simple mode
return;
Expand Down Expand Up @@ -524,7 +524,7 @@ void common_ngram_map_accept(common_ngram_map & map, uint16_t n_accepted) {
struct common_ngram_map_value & curr_value = curr_key.values[val_idx]; // value used for draft generation.

// update the value statistics
LOG_INF("common_ngram_map_send_accepted: n_accepted = %d, prev value_num = %d\n",
LOG_DBG("common_ngram_map_send_accepted: n_accepted = %d, prev value_num = %d\n",
n_accepted, curr_value.n_accepted);
curr_value.n_accepted = n_accepted;
}
Loading