Optimise find_optimal_atomics#221
Merged
Merged
Conversation
d60ec72 to
eba02b9
Compare
connorjward
requested changes
Feb 9, 2026
connorjward
approved these changes
Feb 9, 2026
connorjward
left a comment
There was a problem hiding this comment.
I can have a think about further optimisations as a separate piece of work. Think this is fine to go.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The sum factorization algorithm involves finding the optimal set of common subexpressions via a brute-force search. Previously, the search spent most of the time comparing sets of "atomic"
gem.Nodeinstances (the so-called monomials). The set comparisons were hashing the samegem.Nodeinstances over and over again. Instead, we make sure that the hashing only occurs when preprocessing all unique atomics into a list, and we solve the optimisation problem using the index into that list.We also introduce a better initial guess by recursively sorting the subset of monomials that intersect with each other.
As a benchmark, we generate code for assembling
Notice that the (div, div) term is not integrated with dx(degree=0).
Before: 143 seconds

After: 79 seconds
