Continuous Optimization for p-adic Models

Julian Salazar, Dimitri Kanevsky, Matt Harvey, Pascal Getreuer, Lucas DixonNeurIPS 2026

TL;DR

Standard machine learning lives in continuous Euclidean space, making it clumsy at representing strict hierarchies or modular arithmetic—domains where the exotic, tree-like geometry of $p$-adic numbers naturally shines. However, $p$-adic space is a totally disconnected "dust" where traditional calculus fails and loss landscapes are completely flat. By embedding $p$-adic numbers into a continuous, path-connected geometric tree called the Berkovich affine line, the authors invent the first native gradient descent, backpropagation, and Adam optimizers for $p$-adic machine learning models.

What Problem Does This Paper Address?

Almost all of deep learning assumes parameters live in real space ($\mathbb{R}^n$). Yet for data with strict hierarchical structures or modular rules, Euclidean geometry is a poor fit: embedding $N$ hierarchical points without distorting distances requires at least $N-1$ real dimensions.

Enter the $p$-adic numbers ($\mathbb{Q}_p$), an alternative number system from number theory where distance isn't about magnitude, it's about divisibility by a prime $p$. Two numbers are "close" in $\mathbb{Q}_p$ if their difference is divisible by a high power of $p$ (meaning they share a long base-$p$ suffix). For example, in 2-adic space ($\mathbb{Q}_2$), all even numbers are closer to each other than to any odd number—allowing a single linear equation to separate evens from odds, an XOR-like feat impossible for a real-valued linear classifier!

So why aren't we training $p$-adic neural networks? Because $\mathbb{Q}_p$ is totally path-disconnected. You cannot slide smoothly from one number to another, and natural $p$-adic loss functions are locally constant ("flat") away from their minima, yielding zero gradients everywhere. Consequently, training native $p$-adic models has historically required discrete, combinatorial methods like beam search or random walks, which scale poorly and lack gradient guidance.

Figure 1: Left: the disconnected field Q3, clustered by 3-adic distance. Right: its path-connected hull Γ3 within the Berkovich affine line. Infinitely many vertices between the leaves and ζ0,1 are omitted.

Methods

To do continuous calculus on a disconnected space, the authors borrow a tool from non-Archimedean analytic geometry: the Berkovich affine line. Think of it as building continuous "bridges" (an infinite metric tree) connecting the isolated dust of $p$-adic numbers.

  • The $p$-adic Hull ($\Gamma_p$): Parameters are lifted into $\Gamma_p$, the convex hull of $\mathbb{Q}_p$ inside the Berkovich space. Every point $\zeta_{x,r}$ in this tree is defined by a $p$-adic center $x$ and a continuous real radius $r \ge 0$, representing a disk of uncertainty. Ordinary $p$-adic numbers sit at the leaves ($r=0$), while moving "up" the tree ($r > 0$) uncommits base-$p$ digits, letting parameters travel continuously across branches via their least common ancestors.
  • Continuous Losses & Backpropagation: Model operations (addition, multiplication, Taylor series) extend cleanly onto these disks. Crucially, the authors relax standard flat $p$-adic error into a continuous direct loss ($\ell_d = \max(|\hat{y}-y|_p, \hat{r}) - \hat{r}/2$), and define continuous valuation logits for softmax classification. Because the loss varies smoothly with radius $r$, they can formulate stage-by-stage backpropagation—where radius propagation turns out to behave like tropical max-plus algebra (akin to ReLU networks).
  • Tree Optimizers & Grouped Descent: The authors formulate native Gradient Descent, Momentum, and Adam on the metric tree $\Gamma_p^d$, moving parameters along tree edges and clipping steps at vertices where branches split. Since checking all branch combinations across $d$ parameters at vertices could scale exponentially as $(p+1)^d$, they introduce coupled parameter groups, updating one coordinate per interacting group to keep optimization fast.
Figure 2: Left: one parameter learning y = 23 on Γ3 from ζ14, 2·3−3 with learning rate 8 · 3−4 ; steps are clipped at vertices (Section 4.1). The line toward y = 23 represents infinitely many clipped updates, with radius tending to zero. Right: along that path, the center’s p-adic error |c −y|3 changes only when a digit is chosen, while the direct loss ℓd falls throughout.

Datasets

The authors evaluate their optimizers across three tasks (no brand-new external datasets are introduced, though existing $p$-adic tasks are newly adapted for gradient-based training):

  • Synthetic 3-adic Regression: 3D affine targets and a restricted 4-input, two-layer quadratic network ($z^2$ activation) in $\mathbb{Q}_3$ with noise added at digit depth 5.
  • Modulo Classification: Classifying integers by $x \bmod 4$ and $x \bmod 9$—a task previously solved analytically in $p$-adic ML literature, here trained end-to-end via gradients.
  • Quillian Semantic Network: A classic 1,680-proposition hierarchical knowledge benchmark (adapted from Martins, 2025) predicting 28 binary properties of entities encoded with hand-designed $\mathbb{Q}_2$ prefixes.

Key Insights and Ideas

  • Uncertainty creates slopes: Moving up the tree (increasing radius $r$, temporarily making a parameter less precise) actually lowers the relaxed direct loss when a parameter is stuck on the wrong branch. This allows momentum and Adam to climb out of bad digit commitments ("local minima") and descend down the right branch!
  • Geometry replaces depth for modular math: A simple linear classifier in $\mathbb{Q}_2$ or $\mathbb{Q}_3$ effortlessly learns $\bmod\ 4$ and $\bmod\ 9$ arithmetic, whereas a real-valued linear model on raw scalars fails completely. However, this magic depends strictly on matching the prime $p$ to the data's structure.
  • Tropical algebra connection: Propagating log-radii through $p$-adic Taylor expansions reduces to tropical max-plus operations, linking $p$-adic backpropagation directly to classical Viterbi backtracking and ReLU geometry.

Key Results

  • Drastic Sample Efficiency in Regression: On 3-adic linear regression, approximate gradient descent, Momentum, and Adam recover the exact target parameters (to depth 5) in ~1.0$\times N$ example evaluations, compared to 36$\times N$ for width-5 beam search. When initialized in an "adverse" digitwise local minimum, standard GD recovers 3/5 times, while Momentum and Adam recover 5/5 times. On the two-layer network, GD recovers all 5 seeds in 1.5$\times N$ evaluations versus 208$\times N$ for width-10 beam search.
  • 100% Modulo Accuracy: Matched-prime linear classifiers trained with $p$-adic Adam hit 1.000 ± 0.000 test accuracy on $x \bmod 4$ ($p=2$) and $x \bmod 9$ ($p=3$). Mismatched primes ($p=5$) and Euclidean raw-scalar linear models stay stuck at chance (~0.24 and ~0.11).
  • Competitive Hierarchical Classification: On the Quillian benchmark, the 2-adic linear classifier trained with Adam achieves 0.814 Pooled AP and 0.973 accuracy, matching batch-32 beam search (0.804 AP, 0.976 accuracy) and approaching a full-batch two-layer Euclidean MLP (0.879 AP, 0.976 accuracy) that uses 3.6$\times$ as many parameters.

Limitations and Future Work

  • Scaling to Deep Architectures: While backpropagation works theoretically for arbitrary depth, the authors only train affine models and a restricted two-layer network (grouped descent alone struggled when hidden units were fully connected). Additionally, stage-by-stage radius propagation suffers from the "dependency problem" (like interval arithmetic), loosening radius bounds if one parameter feeds into a stage along multiple paths.
  • Missing Mixed Seminorms: Optimizing on the Cartesian product $\Gamma_p^d$ omits "mixed seminorms" present in the full multidimensional Berkovich space, which might offer better joint descent directions.
  • Adelic Machine Learning: Because $p$-adic models require choosing a specific prime $p$, the authors propose adelic losses and optimization—combining real ($\mathbb{R}$) and multiple $p$-adic ($\mathbb{Q}_p$) norms simultaneously via Arakelov geometry.

Summary updated

Abstract

We present the first method for native, continuous gradient descent for machine learning models with $p$-adic parameters. Existing native optimizers are discrete and mostly combinatorial searches, as the $p$-adic numbers $\mathbb{Q}_p$ are totally disconnected, with standard losses that are flat away from their minima. To enable continuous optimization, we propose working with $\mathbb{Q}_p$ via its Berkovich affine line: a canonical, path-connected expansion of $\mathbb{Q}_p$ that preserves its isometries and locally extends its analytic maps. This hull is a metric tree with interpretable points and local derivatives, which we show enables effective optimizers and backpropagation. We formulate gradient descent and show that its approximations efficiently learn linear models with coefficients in $\mathbb{Q}_p$ to do modular arithmetic, an XOR-like task not expressible by linear models in $\mathbb{R}$. We also demonstrate momentum and Adam variants, linear regression, and classification on binary-encoded hierarchies (Quillian semantic networks), addressing open problems posed by Martins (2025).
BibTeX
@inproceedings{salazar2026continuous,
  author = {Julian Salazar and Dimitri Kanevsky and Matt Harvey and Pascal Getreuer and Lucas Dixon},
  title = {{Continuous Optimization for p-adic Models}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=smz6odwrZ6},
}
Figure