Sparse Sum-of-Squares Layers for Certified Learning
Organizations: LAAS-CNRS · ANITI
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.
Figures & tables
| Comparison | Size | Reference | Sparse value route |
| Generic / value-specialized | 28.851 [0.094] | 17.839 [0.080] | |
| Generic / value-specialized | 520.488 [1.550] | 196.259 [0.831] | |
| Ambient / chordal | 1.414 [0.003] | 3.263 [0.006] | |
| Rebuilt / cached | 5.893 [0.056] | 4.431 [0.048] | |
| Rebuilt / cached | 99.040 [5.165] | 72.820 [0.754] |
| Implementation | Peak memory (GiB) | Forward (s) | Backward (s) |
| Dense parameterization | 164.07 | 4161 | 203.6 |
| Sparse SOS (Ours) | 1.69 | 0.154 | 0.265 |
| Sparse SOS (Ours) | Dense CVXPY | Dense SDPR | |
| 96 | |||
| 128 | |||
| 192 | |||
| 256 | |||
| 384 | Not tested | Not tested | |
| 512 | Not tested | Not tested |
| Family | Width | Size | Median ratio | [Q1, Q3] |
| Banded | 4 | 96 | 1.068 | [1.063, 1.070] |
| Random chordal | 4 | 96 | 1.076 | [1.038, 1.139] |
| Random chordal | 6 | 160 | 1.057 | [1.038, 1.070] |
| Random chordal | 8 | 224 | 1.047 | [0.999, 1.104] |
| Segments | Objective discrepancy | Gradient discrepancy |
| 8 | ||
| 9 | ||
| 10 | ||
| 11 |
| Certificate value | Gradient value | |||
| Sparse SOS (Ours) | CVXPY | Sparse SOS (Ours) | CVXPY | |
| Poses | Forward time (s) | Backward time (s) | ||||
| Sparse SOS (Ours) | CVXPY | SDPR | Sparse SOS (Ours) | CVXPY | SDPR | |
| Pendulum | Method | Training signal | Cert. margin | Cert. rate |
| 1 | Sparse SOS (Ours) | certificate margin | 1.000 | |
| 1 | Sampled surrogate | sampled grid loss | 1.000 | |
| 1 | Post hoc | no certificate during training | 0.200 | |
| 2 | Sparse SOS (Ours) | certificate margin | 1.000 | |
| 2 | Sampled surrogate | sampled grid loss | 1.000 | |
| 2 | Post hoc | no certificate during training | 1.000 |
| Training signal | Train | Test | Solves | ||
| Sparse SOS (Ours) | 0/80 | 0/30 | 0/20 | 0/30 | 480 |
| Finite differences | 4/80 | 0/30 | 4/20 | 6/30 | 3360 |
| Sampled surrogate | 9/80 | 4/30 | 5/20 | 12/30 | 0 |
| Stop gradient | 80/80 | 30/30 | 20/20 | 30/30 | 480 |
| No layer | 80/80 | 30/30 | 20/20 | 30/30 | 0 |
| Layer choice | Final test loss | Forward total (s) | Backward total (s) | Time-to- (s) |
| Sparse SOS (Ours) | 32.93 | 5.37 | 22.28 | |
| SDPR | 20.67 | 268.33 | 71.94 | |
| CVXPY | 2023.60 | 361.12 | 594.36 |
Appendix figures & tables20 assets
Supplementary material from the paper’s appendix.
Appendix
| Objective value | Gradient value | |||||
| Sparse SOS (Ours) | CVXPY | SDPR | Sparse SOS (Ours) | CVXPY | SDPR | |
| Segments | Objective value | Gradient value | ||||
| Sparse SOS (Ours) | CVXPY | SDPR | Sparse SOS (Ours) | CVXPY | SDPR | |
| Poses | Objective value | Gradient value | ||||
| Sparse SOS (Ours) | CVXPY | SDPR | Sparse SOS (Ours) | CVXPY | SDPR | |
| Seg. | Status rate | Agreement vs. SDPR | Time (s) | Chordal structure | ||||
| Usable | Strict | Obj. rel. | Grad. rel. | Forward | Backward | Cliques | Max clique | |
| Method | Training signal | Cert. margin | Cert. rate | Train time (s) | Train speedup vs layer |
| Sparse SOS (Ours) | certificate margin | 1.000 | 52.86 | ||
| Sampled surrogate | sampled grid loss | 1.000 | 27.97 | ||
| Post hoc | - | 0.200 | 11.38 |
| Distribution shift | Layer margin | Layer success | margin vs sampled | margin vs stop-grad |
| in-distribution | 0.028 | 1.000 | 0.004 | 0.351 |
| high gravity | 0.025 | 1.000 | 0.002 | 0.223 |
| low damping | 0.024 | 1.000 | 0.003 | 0.349 |
| large region | 0.054 | 0.970 | 0.008 | 0.836 |
| combined hard | 0.050 | 0.957 | 0.634 |
| Schedule | Cert margin | Train time (s) | Train speedup vs every step | Cert time (s) | Exact step frac |
| every step | 0.028 | 44.942 | 0.019 | 1.000 | |
| every 5 | 0.024 | 20.235 | 0.008 | 0.202 | |
| every 10 | 0.023 | 18.804 | 0.007 | 0.101 | |
| late-stage | 0.025 | 21.495 | 0.007 | 0.183 | |
| curriculum | 0.028 | 22.115 | 0.007 | 1.000 |
| Method | Training signal | Cert. margin | Cert. rate | Train time (s) | Train speedup vs layer |
| Sparse SOS (Ours) | certificate margin | 1.000 | 17.128 | ||
| Stop gradient | blocked certificate gradient | 1.000 | 1.161 | ||
| Sampled surrogate | sampled grid loss | 1.000 | 16.223 | ||
| Post hoc | no certificate during training | 1.000 | 0.945 | ||
| DSOS | inner linear certificate | 0.002 | 1.000 | 96.710 | |
| SDSOS | inner second order certificate | 0.002 | 1.000 | 114.952 |
| Schedule | Cert. margin | Train time (s) | Train speedup vs every step | Exact step frac. |
| Every step | 17.128 | 1.000 | ||
| Every 5 | 1.490 | 0.200 | ||
| Every 10 | 1.361 | 0.113 | ||
| Curriculum | 1.894 | 1.000 |
| Mode | Test cert. margin | Cert. rate | Exact step frac. | Train time (s) | Train speedup vs exact |
| Sparse SOS (Ours) every step | 0.0021 | 1.000 | 1.0 | 98.7 | |
| Curriculum | 0.0021 | 1.000 | 1.0 | 97.9 | |
| Sampled surrogate | 0.0014 | 1.000 | 0.0 | 97.4 | |
| Post hoc | 0.0014 | 1.000 | 0.0 | 98.3 | |
| Stop gradient | 0.0014 | 1.000 | 1.0 | 94.6 |
| Method | Sparse cert. margin | Sparse cert. rate |
| Structured certificate (Ours) | 0.5315 | 1.000 |
| Post hoc repair | 0.0373 | 0.705 |
| Dense Cholesky | 0.1674 | 0.905 |
| Method | Test NLL | Rel. matrix error | Sparse cert. margin | Sparse cert. rate |
| Structured certificate (Ours) | 9.4311 | 0.3382 | 0.5315 | 1.000 |
| Post hoc repair | 9.3666 | 0.4860 | 0.0373 | 0.705 |
| Dense Cholesky | 9.4630 | 0.3893 | 0.1674 | 0.905 |
| Training signal | Certificate family | Order | Cert. margin | Cert. rate | Cert. time (s) | Cert. time rel. to sparse SOS |
| Certificate gradient | DSOS | 2 | 0.044 | 1.000 | 0.010 | |
| Certificate gradient | DSOS | 3 | 0.111 | 1.000 | 0.012 | |
| Certificate gradient | SDSOS | 2 | 0.052 | 1.000 | 0.008 | |
| Certificate gradient | SDSOS | 3 | 0.135 | 1.000 | 0.012 | |
| Certificate gradient | Sparse SOS | 2 | 0.052 | 1.000 | 0.007 | |
| Certificate gradient | Sparse SOS | 3 | 0.135 | 1.000 | 0.007 |
| Schedule | Cert. rate | Cert. margin | Train time (s) | Train speedup vs every step | Cert. time (s) | Exact step frac. |
| every step | 1.000 | 0.266 | 27.211 | 0.007 | 1.000 | |
| every 5 | 1.000 | 0.263 | 3.791 | 0.007 | 0.203 | |
| every 10 | 1.000 | 0.262 | 3.594 | 0.008 | 0.103 | |
| late-stage | 1.000 | 0.262 | 4.079 | 0.008 | ||
| curriculum | 1.000 | 0.266 | 14.094 | 0.007 | 1.000 |
| Study | Seeds | Modes | Runs | Total budget (s) | Mean run (s) |
| Coupled certification-native | 3 | 4 | 12 | 66.598 | 5.550 |
| Single pendulum control | 5 | 3 | 15 | 461.084 | 30.739 |
| Two pendulum control | 5 | 6 | 30 | 1235.595 | 41.187 |
| Three pendulum validation | 1 | 5 | 5 | 486.900 | 97.380 |
| Non-SOS chain precision | 5 | 3 | 15 | 59.510 | 3.967 |
| Forward time (s) | Backward time (s) | |||||
| Sparse SOS (Ours) | CVXPY | SDPR | Sparse SOS (Ours) | CVXPY | SDPR | |
| Forward time (s) | Backward time (s) | |||
| Sparse SOS (Ours) | CVXPY | Sparse SOS (Ours) | CVXPY | |
| Family | Median | Q1 | Q3 | IQR | ||
| Banded | 4 | 24 | 0.555 | 0.535 | 0.560 | 0.024 |
| Banded | 4 | 48 | 0.635 | 0.633 | 0.636 | 0.004 |
| Banded | 4 | 96 | 1.068 | 1.063 | 1.070 | 0.007 |
| Banded | 4 | 160 | 1.807 | 1.804 | 1.812 | 0.008 |
| Banded | 4 | 224 | 3.084 | 3.080 | 3.088 | 0.008 |
| Random chordal | 4 | 24 | 0.467 | 0.451 | 0.495 | 0.044 |
| Split | Sparse SOS (Ours) | Finite differences | Sampled surrogate |
| Train | 0, 0, 0, 0, 0 | 0, 0, 3, 0, 1 | 0, 0, 0, 0, 9 |
| Test instances | 0, 0, 0, 0, 0 | 0, 0, 0, 0, 0 | 0, 0, 0, 0, 4 |
| 0, 0, 0, 0, 0 | 0, 4, 0, 0, 0 | 0, 0, 1, 0, 4 | |
| 0, 0, 0, 0, 0 | 0, 6, 0, 0, 0 | 0, 0, 6, 0, 6 |
| Training signal | Mean of seed means | SD | Worst design |
| Sparse SOS (Ours) | 0.0114 | 0.0051 | 0.0056 |
| Finite differences | 0.0113 | 0.0184 | |
| Sampled surrogate | 0.0205 | 0.0333 | |
| Stop gradient or no layer | 0.0018 |
Semidefinite Programming
Semidefinite programming optimizes linear objectives over positive semidefinite matrices to solve convex problems and build tractable relaxations and certificates.
See all 21 papers