Skip to content

Commit

Permalink
Forbid merging small number of repeated groups
Browse files Browse the repository at this point in the history
  • Loading branch information
smirnov-alexey committed Nov 20, 2024
1 parent c821d30 commit 295a5b0
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,15 @@ std::shared_ptr<Repeated> Snapshot::tryMergeTriangles(const std::vector<Group::G
return {};
}

if (prods.size() < m_ctx.keep_blocks) {
// In some cases (specifically mixed precision) we could have merged
// a small number of huge groups which consumed other legit repeated blocks
// due to having a different repeated tag due to unique weights precision combination
// from the rest of the model.
// This check was added to prevent that and shouldn't affect other models.
return {};
}

// In this special case we only assume
// our vector of N repeating consumer groups
// 1. has the same size
Expand Down Expand Up @@ -945,6 +954,15 @@ std::shared_ptr<Repeated> Snapshot::tryMergeRepeating(const std::vector<Group::G
}
}

if (prods.size() < m_ctx.keep_blocks) {
// In some cases (specifically mixed precision) we could have merged
// a small number of huge groups which consumed other legit repeated blocks
// due to having a different repeated tag due to unique weights precision combination
// from the rest of the model.
// This check was added to prevent that and shouldn't affect other models.
return {};
}

std::shared_ptr<Repeated> new_rep = std::make_shared<Repeated>();

for (size_t i = 0; i < conss.size(); ++i) {
Expand Down

0 comments on commit 295a5b0

Please sign in to comment.