# Passivity-Constrained Neural State-Space Layer

- ID: 687
- Canonical URL: https://synthcore.org/idea/687/passivity-constrained-neural-state-space-layer
- API JSON: https://synthcore.org/api/idea/687.json
- API Markdown: https://synthcore.org/api/idea/687.md
- Verification status: mech_ok_no_baseline
- Source: [arXiv:2607.10439](https://arxiv.org/abs/2607.10439)
- Category: dynamics
- Solves: stability, generalization
- ML areas: ssm, rnn, world-model, training
- Math tags: dynamical-systems, control-theory, linear-algebra
- Ratings: usefulness 7/10; difficulty 4/10; novelty 6/10

## Idea description

Replace an unconstrained recurrent transition or latent neural-ODE vector field with a port-Hamiltonian transition. The layer separates conservative mixing from dissipative contraction, guaranteeing non-increasing latent storage energy when the external input is zero and bounding energy growth under driven inputs.

## Mathematical statement

The paper defines the continuous-time state equation $\dot{\mathbf{x}}=[\mathbf{J}(\mathbf{x})-\mathbf{R}(\mathbf{x})]\nabla_{\mathbf{x}}\mathcal{H}(\mathbf{x})+\mathbf{G}\mathbf{u}(t)$, where $\mathbf{x}\in\mathbb{R}^d$ is the latent state, $\mathcal{H}:\mathbb{R}^d\to\mathbb{R}_{\geq 0}$ is stored energy, $\mathbf{J}(\mathbf{x})^\top=-\mathbf{J}(\mathbf{x})$ is the conservative routing operator, $\mathbf{R}(\mathbf{x})\succeq0$ is the dissipative operator, $\mathbf{u}(t)$ is an external input, and $\mathbf{G}$ maps inputs into the state. With output $\mathbf{y}=\mathbf{G}^\top\nabla\mathcal{H}(\mathbf{x})$, the power balance is $\dot{\mathcal{H}}=-\nabla\mathcal{H}^\top\mathbf{R}\nabla\mathcal{H}+\mathbf{y}^\top\mathbf{u}(t)\leq\mathbf{y}^\top\mathbf{u}(t)$. Therefore, when $\mathbf{u}=0$, stored energy cannot increase. A practical parameterization is $\mathcal{H}(x)=\tfrac12x^\top Qx$ with $Q=L_QL_Q^\top+\epsilon I\succ0$, $\mathbf{J}=A-A^\top$, and $\mathbf{R}=BB^\top+\operatorname{diag}(\operatorname{softplus}(r))\succeq0$, making all constraints hold for every parameter value.

## Key formulas

- $$\dot{\mathbf{x}}=\bigl[\mathbf{J}(\mathbf{x})-\mathbf{R}(\mathbf{x})\bigr]\nabla_{\mathbf{x}}\mathcal{H}(\mathbf{x})+\mathbf{G}\mathbf{u}(t)$$
- $$\dot{\mathcal{H}}=-\nabla\mathcal{H}^{\top}\mathbf{R}\,\nabla\mathcal{H}+\mathbf{y}^{\top}\mathbf{u}(t)\;\leq\;\mathbf{y}^{\top}\mathbf{u}(t),\qquad \mathbf{y}=\mathbf{G}^{\top}\nabla\mathcal{H}(\mathbf{x})$$
- $$\mathcal{H}(x)=\tfrac12x^{\top}Qx,\quad Q=L_QL_Q^{\top}+\epsilon I,\quad J=A-A^{\top},\quad R=BB^{\top}+\operatorname{diag}(\operatorname{softplus}(r))$$
- $$x_{k+1}=x_k+\Delta t\left[(J-R)\nabla\mathcal{H}(x_k)+Gu_k\right]$$

## Implementation notes

(1) Integration point: replace the transition in a GRU-free recurrent model, latent ODE, or small state-space model with a port-Hamiltonian vector field. Let the input sequence be $u_k\in\mathbb{R}^m$ and latent state be $x_k\in\mathbb{R}^d$. Use a linear decoder $\hat z_k=Cx_k$, or attach the block before an existing prediction head. Start with constant $J$, $R$, $Q$, and $G$ for each layer; later test input-conditioned low-rank factors. (2) Pseudocode: initialize unconstrained parameters $A$, $B$, $L_Q$, vector $r$, and input matrix $G$. Compute $Q=L_QL_Q^\top+10^{-4}I$, $J=A-A^\top$, and $R=BB^\top+\operatorname{diag}(\operatorname{softplus}(r))$. For each time step, compute $g_k=Qx_k$, $v_k=(J-R)g_k+Gu_k$, and update $x_{k+1}=x_k+\Delta t v_k$. Decode $x_{k+1}$ and backpropagate through the rollout. For numerical stability, use two half-step updates or a differentiable adaptive ODE solver while retaining the same vector field. (3) Compute from the mathematics: construct $J$ and $R$ exactly from the antisymmetric and Gram-factor parameterizations, and calculate the certificate $\Delta H_k=H(x_{k+1})-H(x_k)$. Estimate empirically only discretization error, prediction loss, and the fraction of unforced steps with $\Delta H_k>0$. Initially train with prediction loss alone; optionally add a small penalty on positive energy increments to compensate for Euler discretization. (4) First cheap experiment: compare this layer against a vanilla tanh RNN and a diagonal SSM with matched hidden width on sequential MNIST or PhysioNet waveform forecasting. Measure one-step MSE, free-running 100- to 500-step rollout error, gradient norms, and latent energy drift after setting $u=0$. The expected signal is similar short-horizon accuracy but fewer exploding or chaotic rollouts, monotone or near-monotone unforced energy, and lower long-horizon error at equal parameter count. Also scale input amplitude and verify that energy growth tracks the supplied power $y_k^\top u_k$ rather than growing autonomously.

## Verification

- Status: mech_ok_no_baseline
- Mechanism evidence: yes
- Mechanism confirmed: yes
- Practical verdict: inconclusive
- Verdict: Built a passivity-constrained port-Hamiltonian recurrent layer with Q=L L^T+epsilon I, J=A-A^T, and R=B B^T+diag(softplus(r)), plus a matched tanh RNN baseline. The mechanism was confirmed: continuous unforced dH/dt had maximum -4.33 with zero violations, the Euler stability boundary was 1.47059 predicted versus 1.47074 observed, and the discretization residual scaled as dt^2 with observed slope 2.00. The forecasting task showed worse one-step MSE for the idea (0.0475 vs 0.0329), but unforced energy decreased by 2.15 overall, so passivity worked while prediction accuracy did not improve.

### Mechanism check

- Verdict: Built a passivity-constrained port-Hamiltonian recurrent layer with Q=L L^T+epsilon I, J=A-A^T, and R=B B^T+diag(softplus(r)), plus a matched tanh RNN baseline. The mechanism was confirmed: continuous unforced dH/dt had maximum -4.33 with zero violations, the Euler stability boundary was 1.47059 predicted versus 1.47074 observed, and the discretization residual scaled as dt^2 with observed slope 2.00. The forecasting task showed worse one-step MSE for the idea (0.0475 vs 0.0329), but unforced energy decreased by 2.15 overall, so passivity worked while prediction accuracy did not improve.
- Confidence: 9/10
- Limitations: Only a small synthetic sinusoid forecasting task was tested; no sequential MNIST, PhysioNet, long free-running rollout comparison, adaptive integration, input-conditioned operators, parameter-count matching, or systematic input-amplitude/power-balance sweep was performed.

### Practical benchmark

- Paired seeds: 8
- Baseline mean: 0
- Idea mean: 0
- p-value: 0.46065
- Paired wins: 2/8
- Benchmark verdict: no significant win

## Artifacts

- [bench_report.json](https://synthcore.org/code/298/bench_report.json)
- [passivity_experiment.py](https://synthcore.org/code/298/passivity_experiment.py)
- [report.md](https://synthcore.org/code/298/report.md)
- [report_bench_2026-08-31T004048.md](https://synthcore.org/code/298/report_bench_2026-08-31T004048.md)
- [results.json](https://synthcore.org/code/298/results.json)
- [stage2_bench.py](https://synthcore.org/code/298/stage2_bench.py)
- [Download all files as ZIP](https://synthcore.org/download/298)

## Disclaimer

AI-generated research hypothesis, automatically tested. Not peer-reviewed.
