Research

holonomy_lib

holonomy_lib is a GPU-native, batched-first PyTorch library of geometric, spectral, and topological primitives: Riemannian manifolds, spectral graph theory, discrete Ricci curvature and flow, tensor decompositions, simplicial topology and batched persistent homology, cellular sheaves, and content-addressable provenance for mechanistic interpretability. Every public function carries a citation to the paper that defines its math, and every numerical constant is derived, a universal invariant, or cataloged with a documented scale of validity. It is developed by independent and Synoros researchers for the substrate research program.

Versionv0.7.0
Modules14
Tests1220 passing
LicenseAGPL-3.0-or-later, with commercial dual licensing (contact@synoros.io)

github.com/Synoros-io/holonomy_lib · read the paper: Meaning on a Video Card

Modules

ModuleWhat it gives you
manifoldsRiemannian geometry on low-rank matrices and SPD cones, the hyperboloid and κ-stereographic models of hyperbolic space, pseudo-Riemannian Minkowski spacetime, mixed-curvature products, and per-point-κ heterogeneous geometry.
algebraRandomized and exact truncated SVD, Lanczos top-k and shift-and-invert eigensolvers (dense and sparse), conjugate gradient, and LSQR.
convexProblem-level convex optimization; ridge/Tikhonov least squares dispatching to Cholesky, CG, or LSQR depending on problem shape.
tensor_calculusTruncated HOSVD with Kolda-Bader n-mode product.
spectralFour graph Laplacians including magnetic (directed) and signed variants, Chebyshev heat kernel, effective resistance, commute time, diffusion maps, spectral dimension.
discrete_geometrySinkhorn-based Ollivier-Ricci curvature, discrete Ricci flow with surgery (community detection), and the cheaper Forman-Ricci alternative.
info_geometryBregman divergence for any convex generator plus closed-form KL divergence for the standard exponential families.
optimizationRiemannian SGD on fixed-rank, SPD, and Lorentz manifolds via projection and retraction.
simplicialDense and sparse simplicial complex data structures, boundary operators, Vietoris-Rips construction.
topologyHodge Laplacians and Betti numbers, plus batched persistent homology (H₀+H₁+H₂) of Vietoris-Rips filtrations.
sheafCellular sheaves on graphs, uniform or per-node stalk dimensions, dense and sparse Laplacians, sparse bottom-k spectral read.
lieSO(3) primitives (Rodrigues exp/log, Haar-uniform sampling, composition) and real spherical harmonics up to l = 4.
provenanceContent-addressable Merkle DAG of math primitives: substitution, replay, and SAELens-style dataset emission for mech interp.
hyperbolicManifold-aware graph operations: Fréchet mean, RSGD-based hyperbolic Laplacian eigenmaps, tangent-at-origin inner product, dimension-dispatched H^n heat kernel.

New in 0.7.0

v0.7.0 adds a new convex package seeded with regularized_lstsq (Tikhonov/ridge least squares with method-auto dispatch across Cholesky, CG, and LSQR), a sparse-COO sheaf spectral pipeline (sheaf_coboundary_sparse, sheaf_laplacian_sparse, sheaf_bottom_spectrum) for sheaves past the dense byte cap, and a sparse shift-and-invert Lanczos backend (eigsh_sparse_sa) that dispatches to SciPy shift-invert, SciPy LOBPCG with ILU preconditioning, or torch.lobpcg depending on problem size and device. Test count rose from 1187 to 1220; the audit stayed clean.

Performance

All numbers are CPU, single-thread, PyTorch 2.12, float64, from the library's benchmark notes. These are the highlighted wins, not an average case.

PrimitiveSizeSpeedupNote
Ollivier-Ricci curvaturen = 6413×Sinkhorn pair-tiling plus reduced sync cadence
FixedRank retraction1024×1024 rank-3225×auto-switches to randomized SVD at low rank ratio
Lanczos top-1 eigenvaluen = 10244.2×vs dense eigvalsh
Sparse Laplacian constructionn = 102414×vs dense L = D − A

The gains are real but scale-dependent: at small n, Lanczos and sparse-vs-dense crossovers can run the other way (dense wins at n = 128, for instance), because iterative methods pay fixed overhead that only amortizes once the problem is big enough. The benchmark notes document where each crossover sits.

Vs alternatives

Existing libraries cover slices of what's here. geoopt and pymanopt cover Riemannian manifolds and optimizers; geomstats adds information geometry; gudhi covers simplicial complexes and Hodge Laplacians. None combine breadth, GPU-native batched-first execution, an audit gate against uncataloged numerical constants, and citations on every public function.

Featureholonomy_libgeooptgeomstatspymanoptgudhi
Riemannian manifolds + optimizersyesyesyesyesno
Spectral graph theory (4+ Laplacians)yesnononono
Ollivier-Ricci + Forman-Ricci curvatureyesnononono
Simplicial complexes + Hodge Laplaciansyesnononoyes
Batched persistent homology (H₀+H₁+H₂)yesnononono
GPU-native, batched-firstyesyespartialnono
Content-addressable provenanceyesnononono
Audit gate (no uncataloged constants)yesnononono

Audit discipline

Every numerical constant in the codebase has to fall into one of three categories: derived from inputs (like 1 / N for normalization), a universal invariant (like a 1e-9 numerical floor or ), or experimentally tuned and cataloged with a scale of validity (like SINKHORN_TILE_DEFAULT = 256). A custom audit CLI, python -m holonomy_lib.audit src/ --strict, fails the build on any uncataloged literal and runs before every commit. The library ships 1220 tests: unit tests for correctness, property tests for invariants, and comparison tests against geoopt, pymanopt, tensorly, scipy, and GraphRicciCurvature where a comparable implementation exists.

Provenance for mechanistic interpretability

Every public primitive is decorated with @with_provenance. Inside a provenance.record() block, calls emit nodes in a content-addressable Merkle DAG, whose hex identity is a hash of the operation id, version, canonical parameters, and input hexes. Same operation, same inputs, same hex: deterministic and reproducible. This is what unlocks TransformerLens-style activation patching and SAELens-style dataset emission for mathematical primitives, not just neural network internals: substitute a node's value with reg.replay() and only the downstream computation re-executes. The registry can be exported as a Mermaid or Graphviz diagram, diffed against another run, or summarized as compact text for an agent prompt.

License

holonomy_lib is free software under the GNU Affero General Public License v3.0 or later (AGPL-3.0-or-later), including the AGPL's network clause: anyone running a modified version as a network service must make that modified source available to the service's users. The copyright holder also offers a commercial license for uses the AGPL does not permit, such as embedding the library in a proprietary product without the AGPL's source-disclosure obligations. For a commercial license, contact contact@synoros.io.