Robust Automatic Differentiation of Square-Root Kalman Filters via Gramian Differentials

Adrien Corenflos · 2026

Read Robust Automatic Differentiation of Square-Root Kalman Filters via Gramian Differentials by Adrien Corenflos (2026) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2603-13559.txt.

Introduction

Adrien Corenflos tackles robust automatic differentiation of square-root Kalman filters. These filters propagate covariances in Cholesky-factor form for numerical stability and suit gradient-based parameter learning. Differentiating through triangularization fails when the semi-orthogonal factor is non-unique or the input is rank-deficient. His key observation is that filter outputs depend on the input only through its Gramian. That makes the composite loss smooth even where triangularization is not. He derives a closed-form chain rule from the Gramian differential and extends it to rank-deficient inputs.

Catalog record

CREATORAdrien Corenflos
YEAR2026
COLLECTIONPAPERS
FORMATTXT
FILE SIZE17678
LICENSEhttp://creativecommons.org/licenses/by/4.0/
RIGHTSCC BY
SOURCEarXiv

Source: https://arxiv.org/abs/2603.13559

Browse the full library · About the Tower of Babel

Full text

The opening of the work, from the library's hosted text:

Robust Automatic Differentiation of Square-Root Kalman Filters via Gramian Differentials Adrien Corenflos Abstract Square-root Kalman filters propagate state covariances in Cholesky-factor form for numerical stability, and are a natural target for gradient-based parameter learning in state-space models. Their core operation, triangularization of a matrix M ∈ ℝ n × m M\in\mathbb{R}^{n\times m} , is computed via a QR decomposition in practice, but naively differentiating through it causes two problems: the semi-orthogonal factor is non-unique when m > n m>n , yielding undefined gradients; and the standard Jacobian formula involves inverses, which diverges when M M is rank-deficient. Both are resolved by the observation that all filter outputs relevant to learning depend on the input matrix only through the Gramian M ​ M ⊤ MM^{\top} , so the composite loss is smooth in M M even where the triangularization is not. We derive a closed-form chain-rule directly from the differential of this Gramian identity, prove it exact for the Kalman log-marginal likelihood and filtered moments, and extend it to rank-deficient inputs via a two-component decomposition: a column-space term based on the Moore–Penrose pseudoinverse, and a null-space correction for perturbations outside the column space of M M . I Introduction We consider the linear Gaussian state-space model (LGSSM) \displaystyle\mathbf{x}_{t+1} \displaystyle=A\,\mathbf{x}_{t}+\mathbf{u}_{t},\quad\mathbf{u}_{t}\sim\mathcal{N}(0,U), (1a) \displaystyle\mathbf{y}_{t} \displaystyle=B\,\mathbf{x}_{t}+\mathbf{v}_{t},\quad\mathbf{v}_{t}\sim\mathcal{N}(0,V), (1b) with state \mathbf{x}_{t}\in\mathbb{R}^{d_{x}} , and observation \mathbf{y}_{t}\in\mathbb{R}^{d_{y}} , for some transition and observation matrices A , B , respectively, and positive semi-definite covariance matrices U , and V . The Kalman filter [ 1 ] computes the posterior mean \hat{\mathbf{x}}_{t|t} and covariance P_{t|t} recursively, and evaluates the log-marginal likelihood \mathcal{L}(\theta)=\log p(\mathbf{y}_{1:t}\mid\theta) for the parameter set \theta=\{A,B,U,V,\hat{\mathbf{x}}_{0|0},P_{0|0}\} [see, e.g., 2 , Chapter 6] . Gradient-based estimation of \theta requires \nabla_{\theta}\mathcal{L} , which modern automatic differentiation [see, e.g., 3 , for a review] frameworks [ 4 , e.g.,] obtain by applying the chain rule through every primitive of the filter, in forward mode as a Jacobian-vector product [JVP, 5 , Chapter 3] or in reverse mode as a vector-Jacobian product [VJP, 5 , Chapter 3] . Standard covariance updates are however numerically unstable over long horizons: rounding errors can cause P_{t|t} to lose positive semi-definiteness. Square-root filters [ 6 , 7 ] avoid this by propagating a lower-triangular factor S_{t|t} with P_{t|t}=S_{t|t}S_{t|t}^{\top} , and are increasingly used in parallel-in-time implementations [ 8 ] . Every step of a square-root filter reduces to one call to the triangularization operator \mathcal{T}(M)=L , where M\in\mathbb{R}^{n\times m} and L\in\mathbb{R}^{n\times n} satisfies LL^{\top}=MM^{\top} . In practice \mathcal{T} is computed via the thin QR decomposition of M^{\top} , M^{\top}=Q\,R,\quad Q\in\mathbb{R}^{m\times n},\;Q^{\top}Q=I_{n},\;R\in\mathbb{R}^{n\times n}, (2) by setting L=R^{\top} . When M is square and full-rank, differentiating through the QR decomposition is well-defined [ 9 , Section 3.1] and has been used in this context, e.g., in [ 8 ] . In general, however, two failure modes arise. First, when m>n , the map \mathcal{T} has no unique differential: Q admits a continuous (m-n) -dimensional family of valid choices [ 10 , Chapter 5] , so there is no canonical JVP for L or M ; this occurs in the predict step whenever \operatorname{rank}(U)>0 and in the update step whenever d_{y}>0 . Second, the standard JVP formula for R involves R^{-1} [ 11 ] , which is singular whenever M is rank-deficient; this arises when U or V is singular, or when P_{t|t} degenerates during filtering. Both failures are resolved by a single observation: the filter’s marginal likelihood, filtered mean, and filtered covariance all depend on L=\mathcal{T}(M) only through the Gramian LL^{\top}=MM^{\top} , so \ell\circ\mathcal{T} factors through the smooth map M\mapsto MM^{\top} even though \mathcal{T} is not everywhere differentiable. In view of this, we propose to differentiate \mathcal{T} directly from the differential of the Gramian identity LL^{\top}=MM^{\top} , bypassing the QR decomposition entirely. Our contributions are: (i) a closed-form JVP for \mathcal{T} that is exact for any Gramian-dependent loss, recovers the classical QR-based formula wherever it exists, and extends to rank-deficient inputs via a column-space component based on the Moore–Penrose pseudoinverse together with a null-space correction term that accounts for perturbations outside \operatorname{col}(L) (Section III ); (ii) a proof that all relevant Kalman filter outputs are Gramian-dependent, illustrated on a single predict-update step (Section III-D ); (iii) a VJP obtained for free by automatic transposition [ 12 ] , by virtue of the JVP being linear in the input tangent (Section IV ); and (iv) an open-source implementation. II Square-Root Kalman Filtering The square-root filter maintains the lower-triangular Cholesky factor S_{t|t} satisfying P_{t|t}=S_{t|t}S_{t|t}^{\top} . Each predict-update cycle is built from the following primitive. Definition 1 (Triangularization Operator) . For M\in\mathbb{R}^{n\times m} with r=\operatorname{rank}(M) , the triangularization \mathcal{T}(M) is a matrix L\in\mathbb{R}^{n\times n} satisfying LL^{\top}=MM^{\top} , of the form L=\begin{pmatrix}L_{1}&0\\ L_{2}&0\end{pmatrix}, where L_{1}\in\mathbb{R}^{r\times r} is lower-triangular with non-negative diagonal and L_{2}\in\mathbb{R}^{(n-r)\times r} is arbitrary. It is computed via the column-pivoted thin QR decomposition ( 2 ) by setting L=R^{\top} . When r=n , L_{2} is empty and L=L_{1} is the usual lower-triangular Cholesky factor. In all filter applications below, M is a wide matrix ( m\geq n ), consistently with the block-augmented constructions in ( 3 )–( 4 ). Predict step. Form the augmented matrix M_{\mathrm{pred}}=\begin{bmatrix}A\,S_{t|t}^{\top}&(U^{1/2})^{\top}\end{bmatrix}\in\mathbb{R}^{d_{x}\times 2d_{x}}, (3) where U^{1/2}\in\mathbb{R}^{d_{x}\times d_{x}} satisfies U=U^{1/2}(U^{1/2})^{\top} . Then S_{t+1|t}=\mathcal{T}(M_{\mathrm{pred}}) , and one verifies S_{t+1|t}S_{t+1|t}^{\top}=AP_{t|t}A^{\top}+U . When U is rank-deficient, so is M_{\mathrm{pred}} , and computing gradients will require Definition 2 in Section III . Update step. Write V=V^{1/2}(V^{1/2})^{\top} with V^{1/2}\in\mathbb{R}^{d_{y}\times d_{y}} . Form M_{\mathrm{upd}}=\begin{bmatrix}B\,S_{t+1|t}&V^{1/2}\\ S_{t+1|t}&0\end{bmatrix}\in\mathbb{R}^{(d_{y}+d_{x})\times(d_{y}+d_{x})}. (4) Partitioning the result \mathcal{T}(M_{\mathrm{upd}}) conformably as \mathcal{T}(M_{\mathrm{upd}})=\begin{bmatrix}L_{11}&0\\ L_{21}&L_{22}\end{bmatrix},\quad L_{11}\in\mathbb{R}^{d_{y}\times d_{y}},\;L_{22}\in\mathbb{R}^{d_{x}\times d_{x}}, (5) one reads off the Cholesky factor of the predicted observation covariance L_{11} (with L_{11}L_{11}^{\top}=V+BP_{t+1|t}B^{\top} ) used to compute p(\mathbf{y}_{t}\mid\mathbf{y}_{1:t-1};\theta) , the Kalman gain K_{t}=L_{21}L_{11}^{-1} , and the posterior Cholesky factor S_{t+1|t+1}=L_{22} . When V is rank-deficient, so is M_{\mathrm{upd}} , and we will again need Definition 2 in Section III . III Differentiation via Gramian Differentials III-A The Smooth-Factorization Argument Lemma 1 (Smooth factorization) . Let \ell:\mathbb{R}^{n\times n}_{\mathrm{sym}}\to\mathbb{R} be smooth and suppose \ell depends on L=\mathcal{T}(M) only through the Gramian \Sigma=LL^{\top} . Then M\mapsto\ell(\mathcal{T}(M)) factors as the composition of the polynomial map M\mapsto MM^{\top} with a smooth function of \Sigma , and is therefore smooth in M everywhere. Proof. For any version of \mathcal{T} , LL^{\top}=MM^{\top} , so every branch yields the same value \ell(\mathcal{T}(M))=\tilde{\ell}(MM^{\top}) where \tilde{\ell}(\Sigma)\coloneqq\ell(L) for any L with LL^{\top}=\Sigma . The map M\mapsto MM^{\top} is polynomial, hence smooth. ∎ By Lemma 1 , the JVP of \ell\circ\mathcal{T} at M in direction dM equals the JVP of M\mapsto\tilde{\ell}(MM^{\top}) , which is well-defined everywhere. Rather than differentiating through MM^{\top} directly, we derive a surrogate tangent dL satisfying the differential of LL^{\top}=MM^{\top} ; by the chain rule through \ell(L) , any such dL yields the correct JVP for \ell . III-B Gramian Sufficiency Proposition 1 (Gramian sufficiency) . Let \ell:\mathbb{R}^{n\times n}_{\mathrm{sym}}\to\mathbb{R} be a smooth function of the Gramian \Sigma=LL^{\top}=MM^{\top} , and let dM be a tangent at M . If dL\in\mathbb{R}^{n\times n} satisfies the Gramian differential identity dL\,L^{\top}+L\,dL^{\top}=dM\,M^{\top}+M\,dM^{\top}, (6) then the JVP of \ell\circ\mathcal{T} at M in direction dM computed through dL is exact. Proof. We have d\ell=\langle\nabla_{\Sigma}\ell,\,d\Sigma\rangle_{F} . Differentiating \Sigma=LL^{\top} gives d\Sigma=dL\,L^{\top}+L\,dL^{\top} , and differentiating \Sigma=MM^{\top} gives d\Sigma=dM\,M^{\top}+M\,dM^{\top} . Equation ( 6 ) states these are equal, so both paths yield the same d\ell

Read the complete text