Skip to content

Commit f719cb9

Browse files
committed
Do not warn about imatrix requirement if imatrix is provided
1 parent a6089d5 commit f719cb9

File tree

1 file changed

+30
-26
lines changed

1 file changed

+30
-26
lines changed

examples/cli/main.cpp

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ void print_usage(int argc, const char* argv[]) {
262262
void parse_args(int argc, const char** argv, SDParams& params) {
263263
bool invalid_arg = false;
264264
std::string arg;
265+
std::string type = "";
265266
for (int i = 1; i < argc; i++) {
266267
arg = argv[i];
267268

@@ -367,32 +368,7 @@ void parse_args(int argc, const char** argv, SDParams& params) {
367368
invalid_arg = true;
368369
break;
369370
}
370-
std::string type = argv[i];
371-
bool found = false;
372-
std::string valid_types = "";
373-
for (size_t i = 0; i < SD_TYPE_COUNT; i++) {
374-
auto trait = ggml_get_type_traits((ggml_type)i);
375-
std::string name(trait->type_name);
376-
if (name == "f32" || trait->to_float && trait->type_size) {
377-
if (i)
378-
valid_types += ", ";
379-
valid_types += name;
380-
if (type == name) {
381-
if (ggml_quantize_requires_imatrix((ggml_type)i)) {
382-
printf("\033[35;1m[WARNING]\033[0m: type %s requires imatrix to work properly. A dummy imatrix will be used, expect poor quality.\n", trait->type_name);
383-
}
384-
params.wtype = (enum sd_type_t)i;
385-
found = true;
386-
break;
387-
}
388-
}
389-
}
390-
if (!found) {
391-
fprintf(stderr, "error: invalid weight format %s, must be one of [%s]\n",
392-
type.c_str(),
393-
valid_types.c_str());
394-
exit(1);
395-
}
371+
type = argv[i];
396372
} else if (arg == "--lora-model-dir") {
397373
if (++i >= argc) {
398374
invalid_arg = true;
@@ -659,6 +635,34 @@ void parse_args(int argc, const char** argv, SDParams& params) {
659635
exit(1);
660636
}
661637
}
638+
if (type != "") {
639+
bool found = false;
640+
std::string valid_types = "";
641+
for (size_t i = 0; i < SD_TYPE_COUNT; i++) {
642+
auto trait = ggml_get_type_traits((ggml_type)i);
643+
std::string name(trait->type_name);
644+
if (name == "f32" || trait->to_float && trait->type_size) {
645+
if (i)
646+
valid_types += ", ";
647+
valid_types += name;
648+
if (type == name) {
649+
if (ggml_quantize_requires_imatrix((ggml_type)i) && params.imatrix_in.size() == 0) {
650+
printf("\033[35;1m[WARNING]\033[0m: type %s requires imatrix to work properly. A dummy imatrix will be used, expect poor quality.\n", trait->type_name);
651+
}
652+
params.wtype = (enum sd_type_t)i;
653+
found = true;
654+
break;
655+
}
656+
}
657+
}
658+
if (!found) {
659+
fprintf(stderr, "error: invalid weight format %s, must be one of [%s]\n",
660+
type.c_str(),
661+
valid_types.c_str());
662+
exit(1);
663+
}
664+
}
665+
662666
if (invalid_arg) {
663667
fprintf(stderr, "error: invalid parameter for argument: %s\n", arg.c_str());
664668
print_usage(argc, argv);

0 commit comments

Comments
 (0)