Skip to content

Commit 5e16f31

Browse files
committed
imatrix: skip if activations are not finite
1 parent cf6baf8 commit 5e16f31

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

imatrix.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,16 @@ bool IMatrixCollector::collect_imatrix(struct ggml_tensor* t, bool ask, void* us
134134
for (int row = 0; row < (int)src1->ne[1]; ++row) {
135135
const float* x = data + row * src1->ne[0];
136136
for (int j = 0; j < (int)src1->ne[0]; ++j) {
137-
e.values[j] += x[j] * x[j];
138-
e.counts[j]++;
139-
if (!std::isfinite(e.values[j])) {
140-
LOG_WARN("%f detected in %s\n", e.values[j], wname.c_str());
141-
exit(1);
137+
if (std::isfinite(x[j])) {
138+
e.values[j] += x[j] * x[j];
139+
e.counts[j]++;
140+
if (!std::isfinite(e.values[j])) {
141+
LOG_WARN("%f detected in %s\n", e.values[j], wname.c_str());
142+
e.values[j] = FLT_MAX;
143+
}
144+
}else{
145+
// Likely something from an attention mask?
146+
// LOG_WARN("%f detected in %s INPUT\n", x[j], wname.c_str());
142147
}
143148
}
144149
}

0 commit comments

Comments
 (0)