FerQ: Fermat Quotient Reformulation of High-Order Binary Optimisation

Nam Nguyen, Seng Loke, Anil Prabhakar, Son N. TranNeurIPS 2026

TL;DR

Minimizing equations with complex, multi-variable binary interactions is a foundational bottleneck in both machine learning and quantum computing. By reaching into 17th-century number theory and leveraging Fermat's Little Theorem, the authors introduce FerQ: an exact, universal way to rewrite high-order binary equations using simple variable sums and zero extra helper variables. For physical quantum hardware that strictly requires pairwise interactions, they also introduce a companion encoding (FerQ-Bc) that drastically slashes qubit overhead for complex problems.

What Problem Does This Paper Address?

Many tough problems in computer vision, neuro-symbolic reasoning, and quantum physics boil down to minimizing an "energy function" over binary variables ($0$s and $1$s). When variables only interact in pairs (like $x_1 x_2$), we call it Quadratic Unconstrained Binary Optimization (QUBO)—the native language of today's quantum annealers and specialized solvers.

However, nature and data rarely stop at pairs. When three or more variables interact simultaneously (like $x_1 x_2 x_3 x_4$), you enter the realm of High-Order Binary Optimization (HOBO). Solving HOBO directly is computationally brutal, and physical quantum hardware simply doesn't have the wiring for multi-way couplers. The standard workaround is "quadratization": breaking high-order terms down into pairs by introducing fake "auxiliary" (or ancilla) variables and penalty terms. Unfortunately, this inflates the search space exponentially, introduces fake local minima, and burns through precious qubits.

Methods

The authors forge a clever bridge between combinatorial optimization and classical number theory with two tools:

  1. FerQ (Auxiliary-Free Reformulation): Instead of tracking the product of $d$ binary variables, what if we just tracked their simple integer sum, $A_S = \sum x_i$? By Fermat’s Little Theorem, for any prime $p$, the expression $(A_S - A_S^p)/p$—known as the Fermat quotient—is guaranteed to be an exact integer. The authors prove that any high-order binary product can be written as an exact linear combination of Fermat quotients evaluated on that simple sum, using $d-1$ distinct primes. You find the exact rational weights via a single, offline matrix inversion. No structural assumptions, no penalties, and zero auxiliary variables.
Comparison of computation graphs showing how traditional methods require auxiliary variables and penalties, whereas FerQ uses scalar aggregates and Fermat quotients with zero auxiliary variables.
  1. FerQ-Bc (Quantum Hardware Encoder): Because FerQ preserves the polynomial's mathematical degree, quantum annealers still need a translation to pairwise QUBO form. Because FerQ proves the integer sum holds all the interaction info, FerQ-Bc just tracks that sum using a hybrid hardware chain (a domain-wall chain for $\le 5$ variables, and a binary-counter chain for $> 5$). This collapses any massive high-order term into a single quadratic coupler, requiring a number of ancilla qubits that grows only logarithmically with the interaction size.

Datasets

The authors benchmark their methods against 12 established transformation techniques across:

  • Boolean Satisfiability ($k$-SAT & Max-$k$-SAT): Standard logical benchmarks from SATLIB, the tougher SAT Competition 2023–2025 (SATCOM23-25), MSE2024, and HAMLIB.
  • Physics Simulations: Synthetic instances of random $p$-spin glass models and $k$-local Hamiltonians, as well as 10,000 random high-degree polynomials (up to degree 43) to stress-test qubit overhead. No new datasets were introduced.

Key Insights and Ideas

  • Sums secretly encode products: Over binary variables, a massive multi-way product ($x_1 x_2 \dots x_d$) only equals $1$ when its constituent variables sum to $d$. Fermat quotients provide the exact algebraic machinery to isolate that top-level interaction purely from the scalar sum.
  • Preserving the landscape: Because FerQ adds zero auxiliary variables, a 4-variable problem stays a $2^4$ search space—completely sidestepping the distorted energy landscapes and penalty-tuning headaches of substitution methods.
  • High-degree quantum efficiency: Below degree 8, traditional pairwise tricks are plenty qubit-efficient. Above degree 8, FerQ-Bc's logarithmic scaling shines, turning intractable multi-body physics problems into compact circuits.

Key Results

  • Top Accuracy, Lowest Runtime: Across all four SAT and Max-SAT benchmarks, FerQ achieved the highest satisfaction and weighted satisfaction rates while clocking the fastest CPU runtimes (staying well below $10^5$ ms at the median on SAT tasks, while competitors frequently hit $10^5\text{--}10^6$ ms).
Figure 2: Experimental results in solving kSAT using SATLIB (#samples = 24) and SATCOM 23-25 (#samples = 30)
  • Physics Benchmarks: On $k$-local Hamiltonians, FerQ hit a 100% optimal recovery rate with zero spectral error. On random $p$-spin glasses, it achieved a 99.6% optimal rate (tying top auxiliary-heavy methods while using zero extra variables).
  • Massive Qubit Savings: For extreme high-degree polynomials (degrees 31 to 43), FerQ-Bc needed only 150 auxiliary variables compared to 350–500 for the seven least efficient baselines—a 57%–70% reduction in ancilla overhead.
  • GPU Parallelism: A custom CUDA implementation (FerQ-Gpu) lags the CPU at low read counts due to data-transfer overhead, but achieves a 5.4$\times$ to 12.0$\times$ speedup when handling parallel batches of 2,048 reads.

Limitations and Future Work

  • The 64-Bit Ceiling: FerQ currently hits a practical ceiling at degree 43 because the internal combinatorial numbers grow super-exponentially and overflow standard 64-bit integer precision. Arbitrary-precision math can bypass this, though at the cost of speed.
  • Matrix Inversion Bottleneck: Computing the combination weights requires inverting a matrix of size $(d-1)\times(d-1)$. Though done only once offline per degree, very high degrees will require symbolic precomputation.
  • Degree Preservation: FerQ simplifies the structure of high-order terms without lowering their polynomial degree, making the secondary FerQ-Bc step mandatory for current 2-local quantum annealers.
  • What's Next: The authors envision co-designing FerQ with next-generation quantum hardware, extending Fermat quotient machinery to non-binary discrete variables, and exploring continuous relaxations so gradient-based deep learning optimizers can join the party.

Summary updated

BibTeX
@inproceedings{nguyen2026ferq,
  author = {Nam Nguyen and Seng Loke and Anil Prabhakar and Son N. Tran},
  title = {{FerQ: Fermat Quotient Reformulation of High-Order Binary Optimisation}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=W4U6AMYhfN},
}
Figure