@@ -69,7 +69,6 @@ static void write_file(const std::string & fname, const std::string & content) {
6969bool common_params_load_from_yaml (const std::string & config_file, common_params & params) {
7070 try {
7171 YAML::Node config = YAML::LoadFile (config_file);
72-
7372 // Model parameters
7473 if (config[" model" ]) {
7574 if (config[" model" ][" path" ]) {
@@ -85,7 +84,7 @@ bool common_params_load_from_yaml(const std::string & config_file, common_params
8584 params.model .hf_file = config[" model" ][" hf_file" ].as <std::string>();
8685 }
8786 }
88-
87+
8988 // Basic parameters
9089 if (config[" n_predict" ]) params.n_predict = config[" n_predict" ].as <int32_t >();
9190 if (config[" n_ctx" ]) params.n_ctx = config[" n_ctx" ].as <int32_t >();
@@ -98,23 +97,21 @@ bool common_params_load_from_yaml(const std::string & config_file, common_params
9897 if (config[" n_gpu_layers" ]) params.n_gpu_layers = config[" n_gpu_layers" ].as <int32_t >();
9998 if (config[" main_gpu" ]) params.main_gpu = config[" main_gpu" ].as <int32_t >();
10099 if (config[" verbosity" ]) params.verbosity = config[" verbosity" ].as <int32_t >();
101-
102100 // String parameters
103101 if (config[" prompt" ]) params.prompt = config[" prompt" ].as <std::string>();
104102 if (config[" system_prompt" ]) params.system_prompt = config[" system_prompt" ].as <std::string>();
105103 if (config[" prompt_file" ]) params.prompt_file = config[" prompt_file" ].as <std::string>();
106104 if (config[" input_prefix" ]) params.input_prefix = config[" input_prefix" ].as <std::string>();
107105 if (config[" input_suffix" ]) params.input_suffix = config[" input_suffix" ].as <std::string>();
108106 if (config[" hf_token" ]) params.hf_token = config[" hf_token" ].as <std::string>();
109-
110107 // Float parameters
111108 if (config[" rope_freq_base" ]) params.rope_freq_base = config[" rope_freq_base" ].as <float >();
112109 if (config[" rope_freq_scale" ]) params.rope_freq_scale = config[" rope_freq_scale" ].as <float >();
113110 if (config[" yarn_ext_factor" ]) params.yarn_ext_factor = config[" yarn_ext_factor" ].as <float >();
114111 if (config[" yarn_attn_factor" ]) params.yarn_attn_factor = config[" yarn_attn_factor" ].as <float >();
115112 if (config[" yarn_beta_fast" ]) params.yarn_beta_fast = config[" yarn_beta_fast" ].as <float >();
116113 if (config[" yarn_beta_slow" ]) params.yarn_beta_slow = config[" yarn_beta_slow" ].as <float >();
117-
114+
118115 // Boolean parameters
119116 if (config[" interactive" ]) params.interactive = config[" interactive" ].as <bool >();
120117 if (config[" interactive_first" ]) params.interactive_first = config[" interactive_first" ].as <bool >();
@@ -129,7 +126,7 @@ bool common_params_load_from_yaml(const std::string & config_file, common_params
129126 if (config[" multiline_input" ]) params.multiline_input = config[" multiline_input" ].as <bool >();
130127 if (config[" cont_batching" ]) params.cont_batching = config[" cont_batching" ].as <bool >();
131128 if (config[" flash_attn" ]) {
132- params.flash_attn_type = config[" flash_attn" ].as <bool >() ?
129+ params.flash_attn_type = config[" flash_attn" ].as <bool >() ?
133130 LLAMA_FLASH_ATTN_TYPE_ENABLED : LLAMA_FLASH_ATTN_TYPE_DISABLED;
134131 }
135132 if (config[" no_perf" ]) params.no_perf = config[" no_perf" ].as <bool >();
@@ -142,15 +139,15 @@ bool common_params_load_from_yaml(const std::string & config_file, common_params
142139 if (config[" no_kv_offload" ]) params.no_kv_offload = config[" no_kv_offload" ].as <bool >();
143140 if (config[" warmup" ]) params.warmup = config[" warmup" ].as <bool >();
144141 if (config[" check_tensors" ]) params.check_tensors = config[" check_tensors" ].as <bool >();
145-
142+
146143 // CPU parameters
147144 if (config[" cpuparams" ]) {
148145 const auto & cpu_config = config[" cpuparams" ];
149146 if (cpu_config[" n_threads" ]) params.cpuparams .n_threads = cpu_config[" n_threads" ].as <int >();
150147 if (cpu_config[" strict_cpu" ]) params.cpuparams .strict_cpu = cpu_config[" strict_cpu" ].as <bool >();
151148 if (cpu_config[" poll" ]) params.cpuparams .poll = cpu_config[" poll" ].as <uint32_t >();
152149 }
153-
150+
154151 // Sampling parameters
155152 if (config[" sampling" ]) {
156153 const auto & sampling_config = config[" sampling" ];
@@ -184,15 +181,15 @@ bool common_params_load_from_yaml(const std::string & config_file, common_params
184181 if (sampling_config[" timing_per_token" ]) params.sampling .timing_per_token = sampling_config[" timing_per_token" ].as <bool >();
185182 if (sampling_config[" grammar" ]) params.sampling .grammar = sampling_config[" grammar" ].as <std::string>();
186183 if (sampling_config[" grammar_lazy" ]) params.sampling .grammar_lazy = sampling_config[" grammar_lazy" ].as <bool >();
187-
184+
188185 if (sampling_config[" dry_sequence_breakers" ]) {
189186 params.sampling .dry_sequence_breakers .clear ();
190187 for (const auto & breaker : sampling_config[" dry_sequence_breakers" ]) {
191188 params.sampling .dry_sequence_breakers .push_back (breaker.as <std::string>());
192189 }
193190 }
194191 }
195-
192+
196193 // Speculative parameters
197194 if (config[" speculative" ]) {
198195 const auto & spec_config = config[" speculative" ];
@@ -202,7 +199,7 @@ bool common_params_load_from_yaml(const std::string & config_file, common_params
202199 if (spec_config[" n_gpu_layers" ]) params.speculative .n_gpu_layers = spec_config[" n_gpu_layers" ].as <int32_t >();
203200 if (spec_config[" p_split" ]) params.speculative .p_split = spec_config[" p_split" ].as <float >();
204201 if (spec_config[" p_min" ]) params.speculative .p_min = spec_config[" p_min" ].as <float >();
205-
202+
206203 if (spec_config[" model" ]) {
207204 const auto & model_config = spec_config[" model" ];
208205 if (model_config[" path" ]) params.speculative .model .path = model_config[" path" ].as <std::string>();
@@ -211,14 +208,14 @@ bool common_params_load_from_yaml(const std::string & config_file, common_params
211208 if (model_config[" hf_file" ]) params.speculative .model .hf_file = model_config[" hf_file" ].as <std::string>();
212209 }
213210 }
214-
211+
215212 if (config[" antiprompt" ]) {
216213 params.antiprompt .clear ();
217214 for (const auto & antiprompt : config[" antiprompt" ]) {
218215 params.antiprompt .push_back (antiprompt.as <std::string>());
219216 }
220217 }
221-
218+
222219 return true ;
223220 } catch (const YAML::Exception & e) {
224221 LOG_ERR (" Error parsing YAML config file '%s': %s\n " , config_file.c_str (), e.what ());
@@ -392,8 +389,7 @@ static bool curl_perform_with_retry(const std::string & url, CURL * curl, int ma
392389
393390 CURLcode res = curl_easy_perform (curl);
394391 if (res == CURLE_OK) {
395- return true ;
396- }
392+ return true ;}
397393
398394 int exponential_backoff_delay = std::pow (retry_delay_seconds, max_attempts - remaining_attempts) * 1000 ;
399395 LOG_WRN (" %s: curl_easy_perform() failed: %s, retrying after %d milliseconds...\n " , __func__, curl_easy_strerror (res), exponential_backoff_delay);
@@ -1391,20 +1387,20 @@ bool common_params_parse(int argc, char ** argv, common_params & params, llama_e
13911387 ctx_arg.params = params_org;
13921388 return false ;
13931389 }
1394-
1390+
13951391 // Load YAML config if specified
13961392 if (!ctx_arg.params .config_file .empty ()) {
13971393 if (!common_params_load_from_yaml (ctx_arg.params .config_file , ctx_arg.params )) {
13981394 ctx_arg.params = params_org;
13991395 return false ;
14001396 }
1401-
1397+
14021398 if (!common_params_parse_ex (argc, argv, ctx_arg)) {
14031399 ctx_arg.params = params_org;
14041400 return false ;
14051401 }
14061402 }
1407-
1403+
14081404 if (ctx_arg.params .usage ) {
14091405 common_params_print_usage (ctx_arg);
14101406 if (ctx_arg.print_usage ) {
0 commit comments