Skip to content

Commit 342e701

Browse files
committed
imatrix : only warn about suffix when output format is unspecified
1 parent afa43e1 commit 342e701

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

common/arg.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2649,10 +2649,10 @@ common_params_context common_params_parser_init(common_params & params, llama_ex
26492649
).set_examples({LLAMA_EXAMPLE_IMATRIX}));
26502650
add_opt(common_arg(
26512651
{"--output-format"}, "{gguf,dat}",
2652-
string_format("output format for imatrix file (default: %s)", params.imat_dat ? "dat" : "gguf"),
2652+
string_format("output format for imatrix file (default: %s)", params.imat_dat > 0 ? "dat" : "gguf"),
26532653
[](common_params & params, const std::string & value) {
2654-
/**/ if (value == "gguf") { params.imat_dat = false; }
2655-
else if (value == "dat") { params.imat_dat = true; }
2654+
/**/ if (value == "gguf") { params.imat_dat = -1; }
2655+
else if (value == "dat") { params.imat_dat = 1; }
26562656
else { throw std::invalid_argument("invalid output format"); }
26572657
}
26582658
).set_examples({LLAMA_EXAMPLE_IMATRIX}));

common/common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ struct common_params {
439439
int32_t n_out_freq = 10; // output the imatrix every n_out_freq iterations
440440
int32_t n_save_freq = 0; // save the imatrix every n_save_freq iterations
441441
int32_t i_chunk = 0; // start processing from this chunk
442-
bool imat_dat = false; // whether the legacy imatrix.dat format should be output
442+
int8_t imat_dat = 0; // whether the legacy imatrix.dat format should be output (gguf <= 0 < dat)
443443

444444
bool process_output = false; // collect data for the output tensor
445445
bool compute_ppl = true; // whether to compute perplexity

tools/imatrix/imatrix.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -506,14 +506,14 @@ void IMatrixCollector::save_imatrix_legacy(int32_t ncall) const {
506506

507507
void IMatrixCollector::save_imatrix(int32_t n_chunk) const {
508508
auto fname = m_params.out_file;
509-
bool use_legacy_format = m_params.imat_dat;
509+
int8_t use_legacy_format = m_params.imat_dat;
510510

511-
if (use_legacy_format) {
511+
if (use_legacy_format > 0) {
512512
this->save_imatrix_legacy(n_chunk);
513513
return;
514514
}
515-
if (!string_ends_with(fname, ".gguf")) {
516-
// allowed, but hopefully this raises awareness
515+
// only warn when `--output-format gguf` is not specified
516+
if (use_legacy_format == 0 && !string_ends_with(fname, ".gguf")) {
517517
LOG_WRN("\n%s: saving imatrix using GGUF format with a different suffix than .gguf\n", __func__);
518518
LOG_WRN("%s: if you want the previous imatrix format, use --output-format dat\n", __func__);
519519
}

0 commit comments

Comments
 (0)