@@ -248,6 +248,8 @@ std::vector<std::string> common_arg::get_env() const {
248248
249249// Helper function to parse tensor buffer override strings
250250static void parse_tensor_buffer_overrides (const std::string & value, std::vector<llama_model_tensor_buft_override> & overrides) {
251+ ggml_backend_load_all ();
252+
251253 std::map<std::string, ggml_backend_buffer_type_t > buft_list;
252254 for (size_t i = 0 ; i < ggml_backend_dev_count (); ++i) {
253255 auto * dev = ggml_backend_dev_get (i);
@@ -425,6 +427,10 @@ static bool parse_bool_value(const std::string & value) {
425427 }
426428}
427429
430+ [[noreturn]] static void arg_removed (const std::string & msg) {
431+ throw std::invalid_argument (" the argument has been removed. " + msg);
432+ }
433+
428434//
429435// CLI argument parsing functions
430436//
@@ -803,6 +809,7 @@ static std::vector<ggml_backend_dev_t> parse_device_list(const std::string & val
803809 if (dev_names.size () == 1 && dev_names[0 ] == " none" ) {
804810 devices.push_back (nullptr );
805811 } else {
812+ ggml_backend_load_all ();
806813 for (const auto & device : dev_names) {
807814 auto * dev = ggml_backend_dev_by_name (device.c_str ());
808815 if (!dev || ggml_backend_dev_type (dev) == GGML_BACKEND_DEVICE_TYPE_CPU ) {
@@ -820,6 +827,7 @@ static void add_rpc_devices(const std::string & servers) {
820827 if (rpc_servers.empty ()) {
821828 throw std::invalid_argument (" no RPC servers specified" );
822829 }
830+ ggml_backend_load_all ();
823831 ggml_backend_reg_t rpc_reg = ggml_backend_reg_by_name (" RPC" );
824832 if (!rpc_reg) {
825833 throw std::invalid_argument (" failed to find RPC backend" );
@@ -1016,9 +1024,6 @@ common_params_context common_params_parser_init(common_params & params, llama_ex
10161024
10171025 params.use_color = tty_can_use_colors ();
10181026
1019- // load dynamic backends
1020- ggml_backend_load_all ();
1021-
10221027 common_params_context ctx_arg (params);
10231028 ctx_arg.print_usage = print_usage;
10241029 ctx_arg.ex = ex;
@@ -2275,6 +2280,7 @@ common_params_context common_params_parser_init(common_params & params, llama_ex
22752280 {" --list-devices" },
22762281 " print list of available devices and exit" ,
22772282 [](common_params &) {
2283+ ggml_backend_load_all ();
22782284 std::vector<ggml_backend_dev_t > devices;
22792285 for (size_t i = 0 ; i < ggml_backend_dev_count (); ++i) {
22802286 auto * dev = ggml_backend_dev_get (i);
@@ -3715,35 +3721,35 @@ common_params_context common_params_parser_init(common_params & params, llama_ex
37153721 {" --draft" , " --draft-n" , " --draft-max" }, " N" ,
37163722 " the argument has been removed. use --spec-draft-n-max or --spec-ngram-mod-n-max" ,
37173723 [](common_params & /* params*/ , int /* value*/ ) {
3718- throw std::invalid_argument ( " the argument has been removed. use --spec-draft-n-max or --spec-ngram-mod-n-max" );
3724+ arg_removed ( " use --spec-draft-n-max or --spec-ngram-mod-n-max" );
37193725 }
37203726 ).set_spec ().set_examples ({LLAMA_EXAMPLE_SPECULATIVE , LLAMA_EXAMPLE_LOOKUP , LLAMA_EXAMPLE_SERVER , LLAMA_EXAMPLE_CLI }).set_env (" LLAMA_ARG_DRAFT_MAX" ));
37213727 add_opt (common_arg (
37223728 {" --draft-min" , " --draft-n-min" }, " N" ,
37233729 " the argument has been removed. use --spec-draft-n-min or --spec-ngram-mod-n-min" ,
37243730 [](common_params & /* params*/ , int /* value*/ ) {
3725- throw std::invalid_argument ( " the argument has been removed. use --spec-draft-n-min or --spec-ngram-mod-n-min" );
3731+ arg_removed ( " use --spec-draft-n-min or --spec-ngram-mod-n-min" );
37263732 }
37273733 ).set_spec ().set_examples ({LLAMA_EXAMPLE_SPECULATIVE , LLAMA_EXAMPLE_LOOKUP , LLAMA_EXAMPLE_SERVER , LLAMA_EXAMPLE_CLI }).set_env (" LLAMA_ARG_DRAFT_MIN" ));
37283734 add_opt (common_arg (
37293735 {" --spec-ngram-size-n" }, " N" ,
37303736 " the argument has been removed. use the respective --spec-ngram-*-size-n or --spec-ngram-mod-n-match" ,
37313737 [](common_params & /* params*/ , int /* value*/ ) {
3732- throw std::invalid_argument ( " the argument has been removed. use the respective --spec-ngram-*-size-n" );
3738+ arg_removed ( " use the respective --spec-ngram-*-size-n" );
37333739 }
37343740 ).set_spec ().set_examples ({LLAMA_EXAMPLE_SERVER }));
37353741 add_opt (common_arg (
37363742 {" --spec-ngram-size-m" }, " N" ,
37373743 " the argument has been removed. use the respective --spec-ngram-*-size-m" ,
37383744 [](common_params & /* params*/ , int /* value*/ ) {
3739- throw std::invalid_argument ( " the argument has been removed. use the respective --spec-ngram-*-size-m" );
3745+ arg_removed ( " use the respective --spec-ngram-*-size-m" );
37403746 }
37413747 ).set_spec ().set_examples ({LLAMA_EXAMPLE_SERVER }));
37423748 add_opt (common_arg (
37433749 {" --spec-ngram-min-hits" }, " N" ,
37443750 " the argument has been removed. use the respective --spec-ngram-*-min-hits" ,
37453751 [](common_params & /* params*/ , int /* value*/ ) {
3746- throw std::invalid_argument ( " the argument has been removed. use the respective --spec-ngram-*-min-hits" );
3752+ arg_removed ( " use the respective --spec-ngram-*-min-hits" );
37473753 }
37483754 ).set_spec ().set_examples ({LLAMA_EXAMPLE_SERVER }));
37493755
0 commit comments