Skip to content

Commit 750579f

Browse files
authored
common: Refactoring sampler parameters (ggml-org#20429) (ggml-org#22233)
This change refactors the reasoning_budget_message parameter from the common params into the sampling parameters specifically. It also removes the reasoning_budget common parameter and standardizes on the existing reasoning_budget_tokens parameter in the sampling configuration. Issue: ggml-org#20429 Original PR: ggml-org#20297
1 parent 134d6e5 commit 750579f

4 files changed

Lines changed: 7 additions & 8 deletions

File tree

common/arg.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3122,14 +3122,14 @@ common_params_context common_params_parser_init(common_params & params, llama_ex
31223122
"token budget for thinking: -1 for unrestricted, 0 for immediate end, N>0 for token budget (default: -1)",
31233123
[](common_params & params, int value) {
31243124
if (value < -1) { throw std::invalid_argument("invalid value"); }
3125-
params.reasoning_budget = value;
3125+
params.sampling.reasoning_budget_tokens = value;
31263126
}
31273127
).set_examples({LLAMA_EXAMPLE_SERVER, LLAMA_EXAMPLE_COMPLETION, LLAMA_EXAMPLE_CLI}).set_env("LLAMA_ARG_THINK_BUDGET"));
31283128
add_opt(common_arg(
31293129
{"--reasoning-budget-message"}, "MESSAGE",
31303130
"message injected before the end-of-thinking tag when reasoning budget is exhausted (default: none)",
31313131
[](common_params & params, const std::string & value) {
3132-
params.reasoning_budget_message = value;
3132+
params.sampling.reasoning_budget_message = value;
31333133
}
31343134
).set_examples({LLAMA_EXAMPLE_SERVER, LLAMA_EXAMPLE_COMPLETION, LLAMA_EXAMPLE_CLI}).set_env("LLAMA_ARG_THINK_BUDGET_MESSAGE"));
31353135
add_opt(common_arg(

common/common.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ struct common_params_sampling {
274274
std::vector<llama_token> reasoning_budget_start; // start tag token sequence
275275
std::vector<llama_token> reasoning_budget_end; // end tag token sequence
276276
std::vector<llama_token> reasoning_budget_forced; // forced sequence (message + end tag)
277+
std::string reasoning_budget_message; // message injected before end tag when budget exhausted
277278

278279
bool backend_sampling = false;
279280

@@ -581,8 +582,6 @@ struct common_params {
581582
bool force_pure_content_parser = false;
582583
common_reasoning_format reasoning_format = COMMON_REASONING_FORMAT_DEEPSEEK;
583584
int enable_reasoning = -1; // -1 = auto, 0 = disable, 1 = enable
584-
int reasoning_budget = -1;
585-
std::string reasoning_budget_message; // message injected before end tag when budget exhausted
586585
bool prefill_assistant = true; // if true, any trailing assistant message will be prefilled into the response
587586
int sleep_idle_seconds = -1; // if >0, server will sleep after this many seconds of idle time
588587

tools/cli/cli.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ struct cli_context {
7777
// defaults.return_progress = true; // TODO: show progress
7878

7979
verbose_prompt = params.verbose_prompt;
80-
reasoning_budget = params.reasoning_budget;
81-
reasoning_budget_message = params.reasoning_budget_message;
80+
reasoning_budget = params.sampling.reasoning_budget_tokens;
81+
reasoning_budget_message = params.sampling.reasoning_budget_message;
8282
}
8383

8484
std::string generate_completion(result_timings & out_timings) {

tools/server/server-context.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,8 +1045,8 @@ struct server_context_impl {
10451045
/* allow_image */ mctx ? mtmd_support_vision(mctx) : false,
10461046
/* allow_audio */ mctx ? mtmd_support_audio (mctx) : false,
10471047
/* enable_thinking */ enable_thinking,
1048-
/* reasoning_budget */ params_base.reasoning_budget,
1049-
/* reasoning_budget_msg */ params_base.reasoning_budget_message,
1048+
/* reasoning_budget */ params_base.sampling.reasoning_budget_tokens,
1049+
/* reasoning_budget_msg */ params_base.sampling.reasoning_budget_message,
10501050
/* media_path */ params_base.media_path,
10511051
/* force_pure_content */ params_base.force_pure_content_parser
10521052
};

0 commit comments

Comments
 (0)