✗ Mechanism failed 2026

Matrix-Free Differentiable CBF Safety Layer

Implementation & benchmark of arXiv:2607.20674 — End-to-End Learning of Safe Optimal Feedback Control in High Dimensions with Control Barrier Function Layers

Usefulness8/10
Difficulty6/10
Novelty6/10

Source paper: End-to-End Learning of Safe Optimal Feedback Control in High Dimensions with Control Barrier Function Layers arXiv:2607.20674 ⓘ · analyzed Aug 30, 2026

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

Idea description

Attach a hard control-barrier-function quadratic-program safety filter to a neural policy, but solve the filter with operator splitting and differentiate through its fixed-point map using projection Jacobian-vector products. The network learns the nominal action and task objective end to end, while the deployed action remains the feasible filtered action rather than an unconstrained penalty-based approximation.

Formulas

$$C_{2}(z)=\{(u,s)\in\mathbb{R}^{m+c}:A(z)u+s=b(z)\},\qquad C_{1}=\mathbb{R}^{m}\times\mathbb{R}_{+}^{c}.$$
$$P_{C_{1}}(y)=\begin{bmatrix}u\\\max(s,0)\end{bmatrix},\qquad \frac{dP_{C_{1}}}{dy}(y)=\begin{bmatrix}I_{m\times m}&0_{m\times c}\\0_{c\times m}&\operatorname{diag}(\mathbf{1}[s>0])\end{bmatrix}.$$
$$P_{C_{2}}(y)=y-M(z)^{\top}\big(M(z)M(z)^{\top}\big)^\dagger\big(M(z)y-b(z)\big),\qquad M(z)=[A(z)\ I_c].$$
$$\frac{dT_{\theta}}{dy}(y;z)=P_{\mathcal H_{2,z}^{\perp}}P_{\mathcal H_{1,y}^{\perp}}+P_{\mathcal H_{2,z}}\left(I-\zeta Q_u^{\top}Q_u\right)P_{\mathcal H_{1,y}}.$$

Mathematical statement

The safety filter uses variables $y=(u,s)\in\mathbb{R}^{m+c}$, where $u\in\mathbb{R}^{m}$ is the control and $s\in\mathbb{R}^{c}$ are nonnegative slack variables for $c$ barrier inequalities. The two sets are $C_{1}=\mathbb{R}^{m}\times\mathbb{R}_{+}^{c}$ and $C_{2}(z)=\{(u,s):A(z)u+s=b(z)\}$, with state-dependent barrier matrix $A(z)$ and right-hand side $b(z)$. The projection onto $C_{1}$ is elementwise: $P_{C_{1}}(u,s)=(u,\max(s,0))$, and at differentiable points its Jacobian is $P_{\mathcal H_{1,y}}=\operatorname{diag}(I_m,\operatorname{diag}(\mathbf{1}[s_i>0]))$, where $\mathcal H_{1,y}$ is the tangent space of the active orthant face. For the affine set, define $M(z)=[A(z)\ I_c]$; its projection derivative is the orthogonal projector $P_{\mathcal H_{2,z}}=I-M(z)^\top(M(z)M(z)^\top)^\dagger M(z)$ onto the nullspace of $M(z)$. Theorem 16 gives the differentiable-point Jacobian of the DYS operator $T_{\theta}$ as $$\frac{dT_{\theta}}{dy}(y;z)=P_{\mathcal H_{2,z}^{\perp}}P_{\mathcal H_{1,y}^{\perp}}+P_{\mathcal H_{2,z}}\left(I-\zeta Q_u^{\top}Q_u\right)P_{\mathcal H_{1,y}},$$ where $Q_u$ selects or weights the control coordinates and $\zeta\in(0,1)$ is the splitting or gradient step. Each factor is a sparse diagonal mask, an affine nullspace projection, or a cheap control-coordinate scaling, enabling a matrix-free backward pass.

Implementation notes

1. Integration point: use a nominal policy $u_{\mathrm{nom}}=\pi_\phi(z)$ in an RL actor, imitation policy, or differentiable model-predictive controller. Construct CBF inequalities in affine-control form $A(z)u+s=b(z)$ from $\dot h_j(z,u)+\alpha_j h_j(z)\ge0$, append slack $s\ge0$, and output the filtered control $u$ from the splitting layer. Keep the filter active during both training and inference. 2. Forward pass: initialize $y^0=(u_{\mathrm{nom}},s^0)$ with $s^0=\operatorname{softplus}(b-Au_{\mathrm{nom}})$. For $k=0,\ldots,K-1$, compute $v^k=P_{C_1}(y^k)$, compute $w^k=P_{C_2}(v^k-\zeta\widetilde Qv^k)$ using $P_{C_2}(x)=x-M^\top(MM^\top)^\dagger(Mx-b)$, and apply the DYS fixed-point update. Check the primal residual $\|Ay+s-b\|_2$ and nonnegativity of $s$ after every iteration. 3. Backward pass: do not materialize $dT/dy$. Given incoming vector $r$, apply the four factors in the displayed Jacobian in reverse order: mask the slack coordinates by $\mathbf{1}[s_i>0]$, scale control coordinates by $(1-\zeta Q_u^\top Q_u)$, and apply the affine-set projector using matrix-vector products with $M$ and $M^\top$ plus conjugate gradients or a sparse factorization of $MM^\top$. Accumulate gradients through $A(z)$, $b(z)$, and $u_{\mathrm{nom}}$. At kink points $s_i=0$, use the deterministic subgradient mask $\mathbf{1}[s_i>0]$ and test a straight-through alternative. 4. Quantities from the mathematics are the orthant mask, projection formula, and matrix-free Jacobian factorization. Estimate $MM^\top$ solves numerically and tune $\zeta\in(0,1)$ and iteration count $K$ by residual and gradient tradeoff. First experiment: train a 20-agent planar point-mass or quadrotor actor on collision avoidance and goal reaching, comparing this layer with an unrolled generic differentiable QP solver and a penalty-only actor at equal FLOPs. Measure safety violations, return, wall-clock training time, peak memory, and loss descent. Scale from 4 to 64 agents; success is near-zero violations with lower memory and comparable return when the dense KKT baseline becomes impractical.

Verification

Mechanism failed

Stage 1 · Toy mechanism gate: Failed ✗

Stage 2 · Mechanism transferred to benchmark: Not tested

Stage 2 · Practical benchmark result: Not run

Methodology: Toy-system gate first; the benchmark stage runs only after a pass. How verification works

Stage 1 — Mechanism check agent confidence 8/10

Built a matrix-free NumPy/PyTorch DYS CBF layer with orthant and affine projections, unrolled differentiation, CUDA fallback, and numerical checks. The core math manifested: affine projection residual was 5.6e-17, projector idempotence was 1.9e-16, analytic-versus-finite-difference Jacobian error was 5.2e-11, and the orthant kink produced the predicted unit Jacobian jump. However, the small learning experiment did not show a practical win: the 12-step idea layer had 0.236 mean no-slack violation, MSE 0.721, and took 12.8 seconds versus the penalty baseline's MSE 0.672 and 1.43 seconds.

Agent confidence
8/10
Baseline
Penalty actor: MSE 0.6719, mean no-slack violation 0.1282, 1.43 s. Dense 60-step unroll: MSE 0.1651, mean slack/no-slack violation 0.8125, affine residual 1.4e-7, 56.6 s.
Idea
12-step DYS layer: MSE 0.7214, mean slack/no-slack violation 0.2362, affine residual 4.6e-4, 12.8 s. Math checks: projection residual 5.6e-17, idempotence 1.9e-16, Jacobian error 5.2e-11, kink jump 1.0.

Limitations: Only a tiny static two-constraint supervised toy was tested; no multi-agent dynamics, RL return, sparse large-scale operators, memory profiling, generic differentiable QP implementation, straight-through kink alternative, or learned state-dependent A(z), b(z) was evaluated. The slack formulation softens hard CBF feasibility, and finite-step convergence/output semantics require further design before deployment.

How to run: python3 mvp.py

Verdict computed by deterministic test code from paired-seed statistics — not by the language model.

Artifacts

Implementation overview ⬇ Download all as ZIP 2 files · code, reports and structured results