Skip to content

Commit e2d4f08

Browse files
committed
llama-cli : fix dangling reference to sampler config
1 parent d0bea21 commit e2d4f08

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

common/common.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -976,8 +976,6 @@ struct common_init_result common_init_context_from_model(
976976
const llama_vocab * vocab = llama_model_get_vocab(model);
977977

978978
auto cparams = common_context_params_to_llama(params);
979-
cparams.samplers = params.backend_samplers;
980-
cparams.n_samplers = params.n_backend_samplers;
981979

982980
llama_context * lctx = llama_init_from_model(model, cparams);
983981
if (lctx == NULL) {
@@ -1247,6 +1245,9 @@ struct llama_context_params common_context_params_to_llama(const common_params &
12471245
cparams.type_k = params.cache_type_k;
12481246
cparams.type_v = params.cache_type_v;
12491247

1248+
cparams.samplers = params.backend_samplers;
1249+
cparams.n_samplers = params.n_backend_samplers;
1250+
12501251
return cparams;
12511252
}
12521253

tools/main/main.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,9 @@ int main(int argc, char ** argv) {
146146

147147
// Configure backend sampler if configured
148148
llama_sampler * backend_sampler = common_sampler_backend_init(model, sparams);
149+
llama_sampler_seq_config sampler_config = { 0, backend_sampler };
150+
149151
if (backend_sampler) {
150-
llama_sampler_seq_config sampler_config = { 0, backend_sampler };
151152
params.backend_samplers = &sampler_config;
152153
params.n_backend_samplers = 1;
153154
}

0 commit comments

Comments
 (0)