Skip to content

sparse-FGLM early termination - #413

Open
jerebertho wants to merge 3 commits into
algebraic-solving:masterfrom
jerebertho:sparse-early-termination
Open

jerebertho wants to merge 3 commits into
algebraic-solving:masterfrom
jerebertho:sparse-early-termination

Conversation

@jerebertho

@jerebertho jerebertho commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Early termination of Berlekamp-Massey in sparse-FGLM

This PR stops the scalar sequence of sparse-FGLM as soon as its minimal polynomial is
known with high probability, instead of always computing 2D terms, where D is the
degree of the ideal. It does not change the outputs.

Sparse-FGLM computes the scalar sequence s_i = <1, M_n^i r>, for r random, and runs
Berlekamp-Massey on it. Berlekamp-Massey is now fed while the sequence is computed and
checked every max(16, npts/64) points: as soon as the linear complexity L of the
sequence is less than D and npts >= 2L + m, the sequence stops. The minimal polynomial
is then read from the Berlekamp-Massey object already filled. When the minimal
polynomial has degree d < D (e.g. non-radical ideals or ideals whose quotient is not
cyclic), the cost of the sequence drops from 2D to about 2d + m matrix-vector products.

There is no fallback if the stop is wrong, so the margin is large: m = 128.
Heuristically, if the full sequence has linear complexity > L, a check with
npts >= 2L + m stops wrongly with probability about p^-m. With at most about 2^10
checks for D < 2^31, the total probability is at most 2^-118, even for p = 2.

Over QQ, the degree of the minimal polynomial modulo the first prime sets the first
check on the other primes, at 2 deg + m points; if the degree differs modulo a prime,
the usual checks follow. Moreover, primes already rejected in the multi-modular loop no
longer run sparse-FGLM on the matrix of a previous prime.

There is no new option and the verbose output is unchanged.

Over a prime field whose characteristic is a 31-bit prime, -l 44 -P 2 (timing and memory overall)

Random Degree deg. elim. pol. master (s) this PR (s) master (MB) this PR (MB)
shape 4096 4096 7.3 7.3 200 200
shape 16384 16384 320 320 2700 2700
2-thick 4096 3072 20 18 210 210
2-thick 8192 6144 160 130 730 730
10-thick 4096 44 19 8.4 210 210
11-thick 8192 48 150 40 730 730
12-thick 4096 13 15 3.6 140 140
13-thick 8192 14 120 18 440 440

Over QQ, -P 2 (timing and memory overall)

Random Degree deg. elim. pol. master (s) this PR (s) master (MB) this PR (MB)
shape 1024 1024 130 130 100 100
2-thick 1024 768 30 27 40 40
9-thick 2048 40 46 29 79 78
11-thick 2048 12 13 7.1 47 47
12-thick 4096 13 150 48 170 170

The outputs are identical to those of master on the test
suite and on additional systems over prime fields of characteristic 251, 257, 65521 and 2^30+3 and over QQ,
with the default call, -P 1, -P 2 and -P 2 -t 2.

PR #401 uses the same early termination when sparse-FGLM is tried before classical
FGLM, with a margin of 32 since classical FGLM is the fallback there.

Use of generative AI
AI-assisted code writing, debugging and testing.

@jerebertho
jerebertho force-pushed the sparse-early-termination branch from aefe167 to f501973 Compare November 24, 2026 23:32
@jerebertho
jerebertho marked this pull request as ready for review November 24, 2026 23:32
@jerebertho jerebertho changed the title Sparse early termination sparse-FGLM early termination Nov 25, 2026
@jerebertho
jerebertho force-pushed the sparse-early-termination branch from f501973 to 3b9b14b Compare November 25, 2026 14:52
jerebertho and others added 3 commits November 28, 2026 13:45
The scalar sequence of sparse-FGLM stops as soon as its linear
complexity L satisfies L < D and npts >= 2 L + m, checked every
max(16, npts / 64) points, instead of always computing 2 D terms. The
minimal polynomial is then read from the Berlekamp-Massey object already
filled. There is no fallback, so the margin is
m = max(32, ceil(74 / floor(log2 p))): a wrong stop has probability
about p^-m per check.

Over Q, the degree of the minimal polynomial on the first prime sets the
first check (2 deg + m points) on the next primes; if the degree differs,
the usual checks follow. Primes already rejected in
secondary_modular_steps no longer run FGLM on the matrix of a previous
prime.

With -P 2 -l 44 -t 1 on a dense system with D = 4096 and an eliminating
polynomial of degree 13, msolve takes 3.3 s instead of 14.2 s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jerebertho
jerebertho force-pushed the sparse-early-termination branch from 3b9b14b to c962431 Compare November 28, 2026 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant