Skip to content

Commit 8f1aa78

Browse files
committed
Remove activation_statistics() option
1 parent 70dd25b commit 8f1aa78

File tree

2 files changed

+8
-16
lines changed

2 files changed

+8
-16
lines changed

common/arg.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2758,16 +2758,9 @@ common_params_context common_params_parser_init(common_params & params, llama_ex
27582758
params.show_statistics = true;
27592759
}
27602760
).set_examples({LLAMA_EXAMPLE_IMATRIX}));
2761-
add_opt(common_arg(
2762-
{"--activation-statistics"},
2763-
string_format("generate data to compute activation-based statistics (default: %s)", params.show_statistics ? "true" : "false"),
2764-
[](common_params & params) {
2765-
params.activation_statistics = true;
2766-
}
2767-
).set_examples({LLAMA_EXAMPLE_IMATRIX}));
27682761
add_opt(common_arg(
27692762
{"--parse-special"},
2770-
string_format("prase special tokens (chat, tool, etc) (default: %s)", params.parse_special ? "true" : "false"),
2763+
string_format("parse special tokens (chat, tool, etc) (default: %s)", params.parse_special ? "true" : "false"),
27712764
[](common_params & params) {
27722765
params.parse_special = true;
27732766
}

tools/imatrix/imatrix.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ static void print_usage(int, char ** argv) {
3030
" -m model.gguf -f some-text.txt [-o imatrix.gguf] [--output-format {gguf,dat}] [--no-ppl] \\\n"
3131
" [--process-output] [--chunk 123] [--save-frequency 0] [--output-frequency 10] \\\n"
3232
" [--in-file imatrix-prev-0.gguf --in-file imatrix-prev-1.gguf ...] [--parse-special] \\\n"
33-
" [--output-format gguf|dat] [--activation-statistics] [--show-statistics] [...]\n" , argv[0]);
33+
" [--output-format gguf|dat] [--show-statistics] [...]\n" , argv[0]);
3434
LOG("\n");
3535
}
3636

@@ -63,7 +63,6 @@ class IMatrixCollector {
6363
public:
6464
IMatrixCollector() = default;
6565
void set_params(common_params params) { m_params = std::move(params); }
66-
bool activation_statistics() const { return m_params.activation_statistics; }
6766
bool collect_imatrix(struct ggml_tensor * t, bool ask, void * user_data);
6867
void save_imatrix_legacy(int32_t ncall = -1) const;
6968
void save_imatrix(int32_t n_chunk = -1) const;
@@ -434,7 +433,7 @@ bool IMatrixCollector::collect_imatrix(struct ggml_tensor * t, bool ask, void *
434433
e.counts.resize(n_as, e.counts[0]);
435434
}
436435
if (e.values.empty()) {
437-
if (activation_statistics()) { e.activations.resize(src1->ne[0]*n_as, 0); }
436+
e.activations.resize(src1->ne[0]*n_as, 0);
438437
e.values.resize(src1->ne[0]*n_as, 0);
439438
e.counts.resize(n_as, 0);
440439
}
@@ -466,7 +465,7 @@ bool IMatrixCollector::collect_imatrix(struct ggml_tensor * t, bool ask, void *
466465
e.counts[ex]++;
467466

468467
for (int64_t j = 0; j < src1->ne[0]; ++j) {
469-
if (activation_statistics()) { e.activations[e_start + j] += x[j]; }
468+
e.activations[e_start + j] += x[j];
470469
e.values[e_start + j] += x[j] * x[j];
471470
if (!std::isfinite((float)e.values[e_start + j])) {
472471
LOG_ERR("%f detected in %s\n", (float)e.values[e_start + j], wname.c_str());
@@ -506,7 +505,7 @@ bool IMatrixCollector::collect_imatrix(struct ggml_tensor * t, bool ask, void *
506505
}
507506
}
508507
if (e.values.empty()) {
509-
if (activation_statistics()) { e.activations.resize(src1->ne[0] * n_mat, 0); }
508+
e.activations.resize(src1->ne[0] * n_mat, 0);
510509
e.values.resize(src1->ne[0] * n_mat, 0);
511510
e.counts.resize(1, 0);
512511
}
@@ -525,7 +524,7 @@ bool IMatrixCollector::collect_imatrix(struct ggml_tensor * t, bool ask, void *
525524
for (int64_t row = 0; row < src1->ne[1]; ++row) {
526525
const float * x = (const float *) (data + row * src1->nb[1] + i2 * src1->nb[2] + i3 * src1->nb[3]);
527526
for (int64_t j = 0; j < src1->ne[0]; ++j) {
528-
if (activation_statistics()) { e.activations[mat_start + j] += x[j]; }
527+
e.activations[mat_start + j] += x[j];
529528
e.values[mat_start + j] += x[j] * x[j];
530529
if (!std::isfinite((float)e.values[j])) {
531530
LOG_ERR("%f detected in %s\n", (float)e.values[j], wname.c_str());
@@ -707,7 +706,7 @@ void IMatrixCollector::save_imatrix(int32_t n_chunk) const {
707706
}
708707

709708
to_store.push_back(kv.first);
710-
if (activation_statistics()) { data_size += GGML_PAD(ggml_tensor_overhead() + sizeof(float) * kv.second.activations.size(), GGML_MEM_ALIGN); }
709+
data_size += GGML_PAD(ggml_tensor_overhead() + sizeof(float) * kv.second.activations.size(), GGML_MEM_ALIGN);
711710
data_size += GGML_PAD(ggml_tensor_overhead() + sizeof(float) * kv.second.values.size(), GGML_MEM_ALIGN);
712711
data_size += GGML_PAD(ggml_tensor_overhead() + sizeof(float) * kv.second.counts.size(), GGML_MEM_ALIGN);
713712
}
@@ -761,7 +760,7 @@ void IMatrixCollector::save_imatrix(int32_t n_chunk) const {
761760
gguf_add_tensor(ctx_gguf, in_sum2);
762761
gguf_add_tensor(ctx_gguf, counts);
763762

764-
if (!stat.activations.empty() && activation_statistics()) {
763+
if (!stat.activations.empty()) {
765764
const int32_t nact = (int32_t) stat.activations.size();
766765
struct ggml_tensor * in_sum = ggml_new_tensor_2d(ctx, GGML_TYPE_F32, nact / nmat, nmat);
767766
ggml_format_name(in_sum, "%s.in_sum", name.c_str());

0 commit comments

Comments
 (0)