spec : fix the check-rate logic of ngram-simple (#19261)

* spec : fix the check-rate logic of ngram-simple

* cont : refactor + fix checks
This commit is contained in:
Georgi Gerganov
2026-02-04 10:39:53 +02:00
committed by GitHub
parent 25f40ca65f
commit d838c22bb3
3 changed files with 18 additions and 33 deletions
+1 -15
View File
@@ -27,23 +27,9 @@ struct common_ngram_simple_config {
uint16_t check_rate; // check for speculative decoding without draft model for each check_rate token
};
// current state (and config) of n-gram simple.
struct common_ngram_simple_state {
common_ngram_simple_config config;
size_t idx_last_check = 0; // index of last check in context history (mutable)
common_ngram_simple_state(const common_ngram_simple_config & config)
: config(config) {}
};
// Searches for a n-gram in the history and checks whether a draft sequence should be generated.
// state: the ngram simple state to search in.
// inp: the tokens generated so far.
// sampled: the token that was just sampled.
// draft: vector to store the draft tokens, initially empty.
llama_tokens common_ngram_simple_draft(
common_ngram_simple_state & state,
const common_ngram_simple_config & config,
const llama_tokens & tokens, llama_token sampled);