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:
dungquixote42
2026-02-20 01:11:36 -05:00
committed by GitHub
parent b855bf92de
commit 0f411b02e2
7 changed files with 71 additions and 16 deletions

View File

@@ -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{}();