Refactor lagrange_penalty()

This commit is contained in:
Ed Addario 2025-09-21 16:22:00 +01:00
parent 9a1656eb97
commit 0d5f18303e
No known key found for this signature in database
GPG Key ID: E7875815A3230993
1 changed files with 7 additions and 7 deletions

View File

@ -1288,21 +1288,21 @@ static std::unordered_map<std::string, ggml_type> target_bpw_type(
bytes = 0;
err = 0.0;
for (size_t i = 0; i < all.size(); ++i) {
const auto & cand = all[i].candidate;
const auto & candidate = all[i].candidate;
int best_j = 0;
double best_val = infinity;
for (int j = 0; j < (int)cand.size(); ++j) {
const double bits = (double)cand[j].bytes * 8.0;
const double val = cand[j].error + mu * bits;
if (val < best_val - epsilon || (std::abs(val - best_val) <= epsilon && cand[j].bytes < cand[best_j].bytes)) {
for (int j = 0; j < (int)candidate.size(); ++j) {
const double bits = (double)candidate[j].bytes * 8.0;
const double val = candidate[j].error + mu * bits;
if (val < best_val - epsilon || (std::abs(val - best_val) <= epsilon && candidate[j].bytes < candidate[best_j].bytes)) {
best_val = val;
best_j = j;
}
}
choice[i] = best_j;
bytes += cand[best_j].bytes;
err += cand[best_j].error;
bytes += candidate[best_j].bytes;
err += candidate[best_j].error;
}
};