Repository navigation
Compute elimination Groebner bases via a DRL Groebner basis - #408
Merged
Merged
Conversation
Contributor
Author
|
See also the discussion in #374 |
ederc
force-pushed
the
elim-drl
branch
2 times, most recently
from
November 20, 2026 14:23
3667278 to
9950939
Compare
For elimination orders F4 often reached very high degrees although the final basis is small: new basis elements got the maximal degree of all their terms, and the tails have a much higher degree than the leading terms. Thus their pairs were delayed and F4 walked down long chains of pairs one per round, e.g. for -e 5 on a system in 6 variables beyond degree 3000 without finishing. Thus a Groebner basis w.r.t. DRL is now computed first and the one w.r.t. the elimination order is computed from it. Over the rationals the DRL computation is traced and replayed for each prime like the elimination one. In this second step the new basis elements get the degree of the current round, which may even be lower than the degree of their leading term if the reduction made a tail term the leading one; the degree only steers the pair selection. Without the DRL step the degrees are computed as before, so the elimination is unchanged. The new option --elim-drl chooses when the DRL step is done: 0 never, 1 always, 2 (default) if there are at least as many equations as variables, since otherwise the ideal is positive-dimensional and the DRL basis is often as expensive as the elimination, and if more than one variable is eliminated, since then the direct computation is usually faster. On a benchmark of 74 eliminations of 25 systems the timeouts after 60 seconds drop from 23 to 0, some computations get several hundred times faster, the worst slowdown is a factor of 13. Assisted-by: Generative AI
Over the rationals the elimination step after the DRL Groebner basis built new meta data with the prime as its field characteristic for each prime. Thus it ran a full F4 without tracer for every prime and leaked the trace it learnt. Now the meta data of this step and its input of the first prime are kept: the tracer is learnt with the first prime and applied for the next ones. For the next primes the terms of the DRL basis are only looked up in the hash table of the input, which is therefore not changed, a missing term or other supports than for the first prime mark the prime as bad. Moreover the hash table of the DRL computation starts with a size depending on the number of terms of the input instead of the initial size of 2^17, it is copied for each prime. On the examples with elimination orders the computations get up to three times faster, e.g. cp-d3-n4-p2 with -e 2 in 6.9 instead of 26.1 seconds, henrion5 with -e 4 in 0.74 instead of 2.42 seconds. Assisted-by: Generative AI
Over the rationals the basis hash table is copied for each prime and the copy is freed afterwards. For large hash tables, e.g. of the default initial size 2^17, allocating them anew each time is expensive: glibc may give the memory back to the system and each prime then touches new pages, so the copy dominates the computation if there are many primes with small computations each. Now a copy remembers the hash table it is copied from and is kept in a list of spare copies of this hash table when it is freed. The next copy reuses it if the sizes still agree, only the data in use is copied. The spare copies are freed with the original hash table, thus a copy has to be freed before its original. For example, rand128 with -e 2 and many small modular computations takes 0.65 instead of 1.25 seconds, with -e 1 0.54 instead of 0.70 seconds. Assisted-by: Generative AI
The input files, the reference outputs and the shared script of the tests of the option --elim-drl were not listed in configure.ac, thus they were missing from the tarball and make distcheck failed. Assisted-by: Generative AI
In convert_sparse_matrix_rows_to_basis_elements the degree of the new basis elements was declared outside the parallel loop and was not private, thus with several threads an element could get the degree of another row. This did not make the results wrong since this degree only steers the pair selection, but it is now declared inside the loop. The check for a degree fall after the loop used the value left in this variable, i.e. of an arbitrary row with several threads, and an uninitialized one for an empty matrix. It now reads the degree of the last new basis element, as in a run with one thread, and is skipped if there is no new element. Assisted-by: Generative AI
mohabsafey
approved these changes
Nov 22, 2026
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.
For elimination orders F4 often reached very high degrees even when the final basis is small. A new basis element got the highest degree of all its terms, and the tails have a much higher degree than the leading terms. Its pairs were therefore postponed, and F4 worked through long chains of pairs, one per round.
This PR addresses that in two ways:
The new option
--elim-drlcontrols when the DRL step is done:0: never1: always2(default): if there are at least as many equations as variables and more than one variable is eliminatedReuse of hash table copies: over the rationals the basis hash table is copied for each prime and freed afterwards. For tables of the default initial size of 2^17 this allocation dominated computations with many primes and small modular computations each: glibc may give the memory back to the system, and each prime then touches new pages. A copy now remembers the table it was copied from. When freed it is kept in a list of spare copies of that table and reused by the next copy if the sizes still agree. The spare copies are freed with the original table, so a copy has to be freed before its original. This affects all multi-modular computations, not only elimination orders.
Benchmarks (seconds,
-g 2 -t 1 -e k; cases that take 0.1 s or less on both builds are left out):The rand128
-e 1case, which doesn't use the DRL step, shows the effect of reusing the hash table copies alone.Testing:
make checkpasses, also with an AddressSanitizer build.elim-drl-31andelim-drl-qqare added.--elim-drl 1Parts of this pull request were written with the assistance of generative AI.