mirror of
https://github.com/ikawrakow/ik_llama.cpp.git
synced 2026-04-29 19:01:47 +00:00
Fix adaptive p sampler bug with string ban (#1287)
* adaptive p: upadte internal state only if not rewinding * adaptive p: conditional update for speculative decoding * adaptive p: refactor to rewind instead of update * adaptive p fix: better comments * fix rewind check * add record to handle multi-token rewind * better comment
This commit is contained in:
@@ -142,6 +142,16 @@ void common_sampler_reset(common_sampler * ctx) {
|
||||
llama_sampler_dry_reset(ctx->smpl);
|
||||
}
|
||||
|
||||
void common_sampler_review(common_sampler * ctx) {
|
||||
const bool record = ctx->record_samplers;
|
||||
const bool rewind = ctx->rewind_samplers;
|
||||
|
||||
llama_review_adaptive_p(ctx->adapt_p_ctx, record, rewind);
|
||||
|
||||
ctx->record_samplers = false;
|
||||
ctx->rewind_samplers = false;
|
||||
}
|
||||
|
||||
void llama_sampling_set_rng_seed(struct common_sampler * ctx, uint32_t seed) {
|
||||
if (seed == LLAMA_DEFAULT_SEED) {
|
||||
seed = std::random_device{}();
|
||||
|
||||
@@ -134,6 +134,9 @@ struct common_sampler {
|
||||
llama_token_data_array cur_p; // current candidates
|
||||
|
||||
std::mt19937 rng;
|
||||
|
||||
bool record_samplers = false; // record current state for stateful samplers
|
||||
bool rewind_samplers = false; // rewind stateful samplers to last recorded
|
||||
};
|
||||
|
||||
|
||||
@@ -148,6 +151,11 @@ void common_sampler_free(struct common_sampler * ctx);
|
||||
// - reset grammar
|
||||
void common_sampler_reset(common_sampler * ctx);
|
||||
|
||||
// Review stateful samplers
|
||||
// | record current state for rewinding
|
||||
// | rewind to last recorded state
|
||||
void common_sampler_review(common_sampler * ctx);
|
||||
|
||||
// Set the sampler seed
|
||||
void llama_sampling_set_rng_seed(struct common_sampler * ctx, uint32_t seed);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user