groebner

Groebner bases over F_p on the GPU, loadable through kernels. Degree-reverse-lexicographic order. Reference baselines: a classical single-pair Buchberger implementation compared element for element, with msolve and Singular std as the standard CPU systems.

A Groebner basis turns questions about polynomial systems, whether equations are solvable, whether a polynomial is a combination of others, what the solution set looks like, into mechanical division. Computing one is the bottleneck of computer algebra, and it has lived on the CPU. This kernel runs the linear-algebra core of the F4 algorithm, reduction of Macaulay matrices, as a GPU kernel, so basis computations over finite fields run on the same device as the rest of a modern pipeline.

Monomial points cascade below a glowing staircase as reduction steps eliminate leading terms, next to a live-computed basis

Reduction modulo a computed basis: a degree-12 polynomial's monomials (cyan) cascade below the staircase carved by the basis leading terms (orange) in 66 division steps, landing exactly on the kernel's normal_form, coefficient for coefficient. The cyclic-5 system's 20-element reduced basis computes in 919 ms with every S-polynomial verified to reduce to zero.

Usage

import torch
from kernels import get_kernel

gb = get_kernel("phanerozoic/groebner", version=1, trust_remote_code=True)

P = 32003
# cyclic-3: x+y+z, xy+yz+xz, xyz-1
system = [
    {(1, 0, 0): 1, (0, 1, 0): 1, (0, 0, 1): 1},
    {(1, 1, 0): 1, (0, 1, 1): 1, (1, 0, 1): 1},
    {(1, 1, 1): 1, (0, 0, 0): P - 1},
]

basis = gb.groebner_basis(system, nvars=3, prime=P)
assert gb.is_groebner_basis(basis, P)

version selects the release branch; trust_remote_code is required by kernels for publishers without the trusted-publisher mark.

Representation

A polynomial is a dict mapping exponent tuples to coefficients in F_p. The tuple (2, 0, 1) is x^2 z in three variables. Coefficients are reduced modulo the prime on entry. The returned basis is monic, fully interreduced, and sorted by descending leading monomial.

API

Symbol Purpose
groebner_basis(polys, nvars, prime) reduced Groebner basis of the ideal generated by polys
normal_form(f, basis, prime) full reduction of f modulo basis
spoly(f, g, prime) S-polynomial of two polynomials
is_groebner_basis(basis, prime) whether every S-polynomial reduces to zero
monomial_key(exps) ascending sort key for degree-reverse-lexicographic order

The prime must be odd and below 2^31.

Method

The algorithm is F4. Critical pairs whose lcm has minimal degree are processed as one batch. For each pair the two S-polynomial rows are formed, then symbolic preprocessing closes the row set: every monomial appearing in a row that is divisible by some leading monomial of the current basis contributes the corresponding reductor as a further row, repeated until no new monomials appear.

Those rows form a Macaulay matrix whose columns are the monomials in descending order. Reducing that matrix to reduced row echelon form performs every reduction in the batch simultaneously, and that reduction is the GPU kernel: Gauss-Jordan elimination over F_p with the pivot column of each step reported back. The prime stays below 2^31 so a product of residues fits in 62 bits and Barrett reduction needs one 64-bit high-multiply.

A reduced row becomes a new basis element when its leading monomial is not already divisible by a leading monomial of the basis. Pairs with coprime leading monomials are discarded by Buchberger's first criterion. The loop ends when no pairs remain, and the result is interreduced.

Measured

system vars basis size time
cyclic-5 5 20 919 ms
random dense (deg 4, 5) 2 5 under 100 ms

Verification

The reduced Groebner basis in a fixed monomial order is unique, so the suite compares element for element against a classical single-pair Buchberger run computed independently in Python with no GPU involvement, on cyclic-3, katsura-2, and smaller systems. Buchberger's criterion is checked directly on the returned basis, every input generator is confirmed to reduce to zero modulo it, and the unit ideal, the empty ideal, and already-reduced input are covered.

Requirements and limits

  • NVIDIA GPU with compute capability 8.0+.
  • Coefficients in F_p, prime odd and below 2^31; drevlex order only.
  • The Macaulay matrices of large systems grow quickly; cyclic-class systems beyond moderate size are research problems for every implementation.

References

Faugere, "A new efficient algorithm for computing Groebner bases (F4)" (1999); Buchberger's criterion; msolve and Singular as CPU references.

License

Apache-2.0.

Downloads last month
-
apache-2.0
Supported hardwares new
CUDA
8.08.68.99.010.012.0
GPU
B300
288GB
NVIDIA SXM
B200
192GB
NVIDIA SXM
H200
141GB
NVIDIA SXM
H100
80GB
GPU
H800
80GB
GPU
H20
96GB
GPU
L40s
48GB
GPU
L40
48GB
GPU
L20
48GB
GPU
L4
24GB
DGX Spark
GB10
128GB
GPU
RTX PRO 6000 WS
96GB
GPU
RTX PRO 6000 Max-Q
96GB
GPU
RTX PRO 5000
48GB
GPU
RTX PRO 4500 WS
32GB
GPU
RTX PRO 4000
24GB
GPU
RTX PRO 4000 SFF
24GB
GPU
RTX PRO 2000
16GB
GPU
RTX 6000 Ada
48GB
GPU
RTX 5880 Ada
48GB
RTX
RTX 5000 Ada
32GB
GPU
RTX 4500 Ada
24GB
RTX
RTX 4000 Ada
20GB
RTX
RTX 4000 SFF Ada
20GB
GPU
RTX 3500 Ada Mobile
12GB
GPU
RTX 2000 Ada
16GB
GPU
RTX A6000
48GB
GPU
RTX A5000
8GB
GPU
RTX A5000 Max-Q
16GB
GPU
RTX A5000 Mobile
16GB
GPU
RTX A4000
16GB
GPU
RTX A4000 Max-Q
8GB
GPU
RTX A4000 Mobile
8GB
GPU
RTX A3000 Mobile
6GB
GPU
RTX A2000
6GB
GPU
RTX A2000 Embedded
4GB
GPU
RTX A2000 Max-Q
4GB
GPU
RTX A2000 Mobile
4GB
GPU
A800
40GB
GPU
A100
80GB
GPU
A40
48GB
GPU
A30
24GB
GPU
A10
24GB
GPU
A2
16GB
RTX
RTX 5090
32GB
RTX
RTX 5090 D
32GB
RTX
RTX 5090 Mobile
24GB
RTX
RTX 5080
16GB
RTX
RTX 5080 Mobile
16GB
RTX
RTX 5070
12GB
RTX
RTX 5070 Mobile
8GB
RTX
RTX 5070 Ti
16GB
RTX
RTX 5070 Ti Mobile
12GB
RTX
RTX 5060 Ti
16GB
RTX
RTX 5060
8GB
RTX
RTX 5060 Mobile
8GB
RTX
RTX 5050
8GB
RTX
RTX 5050 Mobile
8GB
RTX
RTX 4090
24GB
RTX
RTX 4090D
24GB
RTX
RTX 4090 Mobile
16GB
RTX
RTX 4080 SUPER
16GB
RTX
RTX 4080
16GB
RTX
RTX 4080 Mobile
12GB
RTX
RTX 4070
12GB
RTX
RTX 4070 Mobile
8GB
RTX
RTX 4070 Ti
12GB
RTX
RTX 4070 Super
12GB
RTX
RTX 4070 Ti Super
16GB
RTX
RTX 4060
8GB
RTX
RTX 4060 Ti
8GB
RTX
RTX 4090 Laptop
16GB
RTX
RTX 4080 Laptop
12GB
RTX
RTX 4070 Laptop
8GB
RTX
RTX 4060 Laptop
8GB
RTX
RTX 4050 Laptop
6GB
RTX
RTX 3090
24GB
RTX
RTX 3090 Ti
24GB
RTX
RTX 3080
12GB
RTX
RTX 3080 Ti
12GB
RTX
RTX 3080 Mobile
16GB
RTX
RTX 3070
8GB
RTX
RTX 3070 Ti
8GB
RTX
RTX 3070 Ti Mobile
8GB
RTX
RTX 3060 Ti
8GB
RTX
RTX 3060
12GB
RTX
RTX 3060 Mobile
6GB
RTX
RTX 3050 Mobile
4GB
GPU
RTX 2050 Mobile
4GB
Jetson
Jetson AGX Orin 64GB
64GB
Jetson
Jetson AGX Orin 32GB
32GB
Jetson
Jetson Orin NX 16GB
16GB
Jetson
Jetson Orin NX 8GB
8GB
Jetson
Jetson Orin Nano 8GB
8GB
Jetson
Jetson Orin Nano 4GB
4GB
OS
linux
Arch
x86_64
Kernel Builder
19aaa64