Repository navigation
Speedup f4 - #390
Open
ederc wants to merge 3 commits into
Open
Speedup f4#390ederc wants to merge 3 commits into
ederc wants to merge 3 commits into
Conversation
Port several optimizations of the fast F4 implementation to neogb. Symbolic preprocessing and pair selection: reducers are chosen as the shortest divisor (the newest one among equally long ones), the columns are processed in waves whose reducer searches run in parallel, and the multiplied rows are built by parallel hash table lookups followed by a serial insertion of the missing monomials in row order, so the hash table is the same as for a serial run. Linear algebra: modular reductions use Barrett reduction, the known pivot rows are copied into one block in the order of their lead terms, very sparse rows are reduced via a heap of their nonzero columns instead of a dense row over all columns, and if the rows to be reduced are dense on the new columns their remainders are echelonized as dense rows with an AVX2 kernel. The unused statistics updates in the kernels are removed. Pair update: the new elements of a round are handled in bulk parallel steps with the same result as the element by element Gebauer-Moeller update, and only the lcms of the remaining pairs are inserted into the hash table. The computed bases are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When the multi-modular computation over the rationals applies the learned trace for further primes, every prime rebuilt the same matrix structure: hashing the multiplied rows, converting monomials to columns and sorting them. Only the coefficients differ between primes. The first application now stores each round's matrix in column form together with the exponent vectors of its new columns. Later primes copy the cached rows if the supports of the basis elements used in that round agree with the ones recorded for the trace; after the first mismatch the cache is disabled for the rest of that prime. Entries and references are published with compare-and-swap, since the solver applies the trace for several primes in parallel. On a cache hit the reducer rows are handed to the linear algebra as one block. This speeds up the tracer phase by 1.2-1.4x on one thread and up to 2.3x on eight threads for application-dominated systems, at the cost of additional memory for the cached matrices. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The matrices cached when applying the tracer over the rationals stored every column index as a full word, which increased the peak memory usage considerably, e.g. from 198 MB to 426 MB for eco13. The rows are now stored as varints: the header entries directly and the column indices as zigzag encoded differences to the previous column index of the row, most of which fit into a single byte. The start of each row is stored as well, so that the rows can be decompressed in parallel when the cached matrix is reused. This reduces the additional memory usage of the cache by about 70% (eco13 now needs 256 MB) while the running time increases by only about 1-2%. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
This PR speeds up F4 over finite fields and the application of the tracer in the multi-modular computations over QQ. The computed bases and all outputs are unchanged.
Changes
Speed up F4 with optimizations taken from fast
Cache traced matrices when applying the tracer over QQ
When the learned trace is applied to further primes, each prime rebuilt the same matrix structure: it hashed the multiplied rows, converted monomials to columns and sorted them. Only the coefficients differ between primes.
Compress the matrices stored in the trace cache
Benchmarks
Times are in seconds.
Finite fields, F4 only
QQ,
-g 2The "before" times are from master. The "after" times and the memory column are measured with the compressed cache.
Systems that need only a few primes are dominated by learning and stay roughly unchanged (bayes148-qq, mayr42-qq).
Testing
make check: 71/71 pass.input_fileswith several option sets: no differences.-g 2and-P 1, with 1–3 threads): no differences.Parts of this PR were written with the assistance of generative AI (Claude Code). The commits carry the corresponding co-author lines.