Sparse Sum-of-Squares Layers for Certified Learning

Ege Gursoy, Nicolas Mansard

TL;DR

Sparse Sum-of-Squares (SOS) Layers allow neural networks to learn with formal safety and performance guarantees by integrating sparse semidefinite programming directly into the training loop. By ensuring the backward pass reuses the sparse structure of the forward solve, the authors achieve a 100x reduction in memory usage and significant speedups, making certified learning practical for large-scale systems.

What Problem Does This Paper Address?

Modern machine learning excels at empirical performance but often lacks formal guarantees. If you’re training a neural network to control a robot, "it worked on the test set" isn't a safety guarantee. Sum-of-Squares (SOS) methods provide these guarantees by proving that certain polynomial inequalities (like "the energy of the system always decreases") hold true everywhere.

Technically, SOS problems are solved using Semidefinite Programming (SDP). While researchers have previously built differentiable SDP layers, they face a "sparsity gap." Real-world problems often have a sparse structure (e.g., a robot arm is a chain of links, not a fully connected blob). While forward solvers can exploit this sparsity, standard differentiation techniques often force a "dense reconstruction" in the backward pass. This leads to a computational explosion in memory and time, effectively limiting certified learning to tiny toy problems.

Methods

The authors propose Sparse SOS Layers, which maintain sparsity throughout the entire learning pipeline. Their approach relies on three key pillars:

  1. Fixed-Template Architecture: The layer fixes the monomial basis and the sparse interaction pattern (cliques) once at setup. The neural network only predicts the coefficients of the polynomial.
  2. Value-Function Differentiation: Instead of differentiating the entire solution map (which is computationally heavy), the layer differentiates the optimal certified value (like a safety margin).
  3. Sparse Pullback: The backward pass uses an "envelope rule" from sensitivity analysis. It directly contracts the optimal local coordinates from the forward solve with the derivatives of the predicted coefficients. This avoids ever building a large, dense certificate matrix.

By keeping the solver’s local coordinates across the automatic differentiation boundary, the layer ensures that the memory cost remains proportional to the problem's actual complexity, not the square of its total variables.

Datasets

The paper evaluates the layer across several structured problem families rather than traditional static datasets:

  • Banded Binary Optimization: Quadratic problems on ladder graphs (similar to Ising models).
  • Pendulum Control: Learning Lyapunov certificates for single and coupled pendulum chains to guarantee stability.
  • Continuum Robot Projection: Projecting robot shapes onto feasible sets using chordal Shor relaxations.
  • Coupled Oscillator Chains: Certifying stability for chains of Van der Pol oscillators.
  • Pose Graph Synchronization: A common problem in computer vision and robotics for aligning 3D scans.

Key Insights and Ideas

  • Sparsity is a First-Class Citizen: The core "aha" moment is that the chordal decomposition (breaking one giant matrix into smaller overlapping blocks) used to make forward solves tractable can—and should—be preserved during backpropagation.
  • The Envelope Rule Shortcut: For many learning tasks, we only care about the value of the certificate (e.g., "is the margin > 0?"). Differentiating this value is significantly cheaper than differentiating the optimal variables themselves, provided you have access to the solver's internal sparse blocks.
  • Template Caching: By caching the association between neural network outputs and SDP coefficients, the authors eliminate the overhead of rebuilding the sparse problem structure at every training step.

Key Results

The efficiency gains are most dramatic at scale. As shown in the resource measurements for a problem size of $N=384$:

Table 2: Resource measurements at N = 384.
  • Memory Efficiency: The sparse layer used only 1.69 GiB of memory compared to 164.07 GiB for a dense parameterization—a nearly 100x improvement.
  • Speed: The approach achieved up to a 2.7x speedup in total warm-call time compared to generic differentiable optimization layers (see Table 1).
  • Certified Safety: In a design study, the Sparse SOS layer was the only method to achieve zero violations of safety requirements on unseen problem instances, outperforming "sampled surrogates" (which only check safety at specific points) and finite difference methods.
  • Numerical Accuracy: The gradients produced by the sparse layer closely matched high-accuracy reference solvers like MOSEK.
Table 6: Coupled oscillator certificate values and gradients for the same multiplier SOS program.

Limitations and Future Work

  • Fixed Templates: The current implementation requires a fixed sparsity pattern and monomial basis. You cannot currently "learn" the best way to sparsify the certificate on the fly.
  • Scalar Focus: The efficiency gains are specific to losses defined on the scalar certified value. If a loss function requires the full dense certificate matrix, the benefits of this approach diminish.
  • Future Directions: The authors suggest that future work should explore larger coefficient models and more complex, non-chain-like sparsity patterns to tackle even more demanding robotics and control tasks.

Summary updated

Abstract

A central limitation of modern machine learning systems is the lack of formal certificates guaranteeing their behavior beyond empirical, sample-based evaluation. Sum-of-squares (SOS) methods provide such guarantees by certifying polynomial inequalities over continuous domains via semidefinite programming (SDP). While prior work has introduced SDP layers as differentiable components in neural networks, repeated learning calls can lose the computational benefit of the forward program's sparse representation. We propose Sparse SOS Layers, differentiable value layers whose backward passes reuse the local coordinates of the forward solve. Under a fixed template and learned objective coefficients, each layer avoids building dense certificates and reuses its sparse structure across training steps. Compared with existing methods, our approach achieves up to 2.7 times speedup in total warm-call time, with nearly 100 times lower memory usage (1.7 vs. 160 GiB) for relatively large problem sizes for the tested dense parameterization. Experiments cover sparse polynomial certification, pendulum control, combinatorial relaxations, robotics projection, oscillator chains, and pose graph synchronization. A design study achieves zero certified violations across unseen problem instances and sizes, while requiring roughly 7 times fewer optimization solves than estimating gradients by perturbing the objective coefficients and re-solving the problem (finite differences). These results show that sparse certificate values can be effectively integrated into learning pipelines when the backward pass respects the verifier's structure.
BibTeX
@inproceedings{gursoy2026sparse,
  author = {Ege Gursoy and Nicolas Mansard},
  title = {{Sparse Sum-of-Squares Layers for Certified Learning}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=fO3zFhG0ES},
}
Figure