Skip to content

Commit 76d4f99

Browse files
committed
Do not warn about imatrix requirement if imatrix is provided
1 parent 934710b commit 76d4f99

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
@@ -295,6 +295,7 @@ void print_usage(int argc, const char* argv[]) {
295295
void parse_args(int argc, const char** argv, SDParams& params) {
296296
bool invalid_arg = false;
297297
std::string arg;
298+
std::string type = "";
298299
for (int i = 1; i < argc; i++) {
299300
arg = argv[i];
300301

@@ -400,32 +401,7 @@ void parse_args(int argc, const char** argv, SDParams& params) {
400401
invalid_arg = true;
401402
break;
402403
}
403-
std::string type = argv[i];
404-
bool found = false;
405-
std::string valid_types = "";
406-
for (size_t i = 0; i < SD_TYPE_COUNT; i++) {
407-
auto trait = ggml_get_type_traits((ggml_type)i);
408-
std::string name(trait->type_name);
409-
if (name == "f32" || trait->to_float && trait->type_size) {
410-
if (i)
411-
valid_types += ", ";
412-
valid_types += name;
413-
if (type == name) {
414-
if (ggml_quantize_requires_imatrix((ggml_type)i)) {
415-
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);
416-
}
417-
params.wtype = (enum sd_type_t)i;
418-
found = true;
419-
break;
420-
}
421-
}
422-
}
423-
if (!found) {
424-
fprintf(stderr, "error: invalid weight format %s, must be one of [%s]\n",
425-
type.c_str(),
426-
valid_types.c_str());
427-
exit(1);
428-
}
404+
type = argv[i];
429405
} else if (arg == "--lora-model-dir") {
430406
if (++i >= argc) {
431407
invalid_arg = true;
@@ -749,6 +725,34 @@ void parse_args(int argc, const char** argv, SDParams& params) {
749725
exit(1);
750726
}
751727
}
728+
if (type != "") {
729+
bool found = false;
730+
std::string valid_types = "";
731+
for (size_t i = 0; i < SD_TYPE_COUNT; i++) {
732+
auto trait = ggml_get_type_traits((ggml_type)i);
733+
std::string name(trait->type_name);
734+
if (name == "f32" || trait->to_float && trait->type_size) {
735+
if (i)
736+
valid_types += ", ";
737+
valid_types += name;
738+
if (type == name) {
739+
if (ggml_quantize_requires_imatrix((ggml_type)i) && params.imatrix_in.size() == 0) {
740+
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);
741+
}
742+
params.wtype = (enum sd_type_t)i;
743+
found = true;
744+
break;
745+
}
746+
}
747+
}
748+
if (!found) {
749+
fprintf(stderr, "error: invalid weight format %s, must be one of [%s]\n",
750+
type.c_str(),
751+
valid_types.c_str());
752+
exit(1);
753+
}
754+
}
755+
752756
if (invalid_arg) {
753757
fprintf(stderr, "error: invalid parameter for argument: %s\n", arg.c_str());
754758
print_usage(argc, argv);

0 commit comments

Comments
 (0)