---
title: Constraint-Parameterized Latent Safety Filters
url: https://www.emergentmind.com/topics/constraint-parameterized-latent-safety-filters
type: topic
---

# Constraint-Parameterized Latent Safety Filters

Constraint-parameterized latent safety filters arise in settings where safety must be enforced from high-dimensional observations rather than from a known analytic state, dynamics model, or fixed failure set. In latent-space Hamilton–Jacobi (HJ) safety filtering, a world model encodes observations into a latent state and safety is represented by a latent margin or value function. Parameterization enters when the unsafe set is conditioned on a runtime-specified constraint image, when the control-barrier-function (CBF) decay term is learned as a state-dependent quantity, or when the hidden parameter of a safety constraint is inferred from observed safety-filtered actions. Across these formulations, the common objective is to retain the safety benefits of filtering while reducing the conservatism of fixed, decoupled, or pre-specified safety mechanisms [2509.19555, 2511.18606, 2605.26534, 2604.02687].

## 1. Problem setting and conceptual scope

Classical HJ reachability and CBF safety filters typically assume access to a known state, known dynamics, and an explicitly specified failure set. That assumption is often incompatible with modern visuomotor control, in which policies act directly from RGB observations and interact with hard-to-model constraints such as spilling contents from a bag. A latent safety filtering formulation replaces analytic state access with a learned latent representation. One formulation assumes an offline dataset of trajectories
\[
\mathcal{D} = \{(o_t, a_t, o_{t+1})_i\}_{i=1}^N,
\]
together with binary labels indicating whether an observation corresponds to failure, and learns an encoder \(E(o): O \rightarrow Z\) and latent dynamics \(Z \times A \rightarrow \Delta(Z)\). Safety filtering then operates on the latent state \(z = E(o)\) rather than on a hand-specified physical state [2511.18606].

Within that latent setting, early methods generally treated the unsafe set as fixed. In the fixed-constraint HJ formulation, a failure classifier
\[
\ell(z) \in \{-1,1\}
\]
defines a failure set
\[
F := \{ z : \ell(z) \le 0 \},
\]
and the safety value function is learned for that single set. Constraint parameterization broadens this picture. In AnySafe, the unsafe set becomes a runtime-conditioned object indexed by a user-provided image [2509.19555]. In safe-by-design CBF controllers, the safety constraint is parameterized through a learned decay term \(\alpha_\vartheta(x,h(x))\), which induces state-dependent affine constraints [2605.26534]. In inverse safety filtering, the constraint family \(h(s,\theta)\ge 0\) is known but the parameter \(\theta\) is latent and must be recovered online from the difference between nominal and safety-filtered actions [2604.02687].

A central technical distinction separates switching-based latent safety filters from optimization-based ones. Least-restrictive switching filters simply hand control to a safety policy when danger is detected. Smooth latent CBF filters instead seek to modify the nominal action minimally while preserving safety, which is especially important when task performance depends on preserving the fine-grained behavior of a learned visuomotor controller [2511.18606].

## 2. Runtime-conditioned unsafe sets in latent space

AnySafe extends latent-space HJ safety filtering from a fixed, pre-specified failure set to a runtime-specified safety constraint given as an image. A user provides a constraint image \(o_c\), which is encoded into a latent constraint representation
\[
c = E(o_c).
\]
Rather than defining failure through a binary classifier on \(z\), the method introduces a failure projector
\[
g : Z \to \mathcal{P}, \qquad p = g(z),
\]
and defines a dense similarity-to-failure signal through cosine similarity:
\[
\tilde{\ell}_z(z; c) := - \operatorname{sim}(p, p_c), \qquad p = g(z), \quad p_c = g(c).
\]
The resulting unsafe set is parameterized by the constraint representation:
\[
F_c^\delta := \{ z : \tilde{\ell}_z(z; c) \le \delta \}
= \{ z : -\operatorname{sim}(g(z), g(c)) \le \delta \}.
\]
This replaces a fixed classifier-defined failure region with a parameterized sublevel set indexed by the current constraint image [2509.19555].

The corresponding parameterized HJ backup is
\[
V(z_t; c) = (1-\gamma)\,\tilde{\ell}_z(z_t; c) + \gamma \min \Big\{ \tilde{\ell}_z(z_t; c),\; \max_{a_t \in A} \mathbb{E}_{\hat z_{t+1} \sim (\cdot \mid z_t, a_t)}[V(\hat z_{t+1}; c)] \Big\},
\]
with safety policy
\[
a^*(z;c)=\arg\max_{a\in A}\mathbb{E}_{\hat z_{t+1}\sim(\cdot\mid z,a)}[V(\hat z_{t+1}; c)].
\]
At deployment, the execution rule is
\[
a^\text{exec}_c :=
\begin{cases}
a_\text{task}, & \text{if } V(z;c) > \delta,\\
a^*(z;c), & \text{otherwise}.
\end{cases}
\]
Only the conditioning image changes at runtime; no retraining is required when the user changes the safety specification [2509.19555].

This formulation directly targets a limitation of fixed latent safety filters: the assumption that the failure notion is known a priori and remains unchanged during deployment. The motivating use case is a robot that should avoid one region in one task but later intentionally use that same region and avoid another one. A classifier trained for a single unsafe set does not naturally support that kind of retargeting, whereas a constraint-conditioned latent value function does [2509.19555].

## 3. Calibration, imagination-based training, and semantic alignment

A parameterized unsafe set is only useful if latent similarity corresponds to the intended notion of failure. AnySafe therefore uses conformal prediction to calibrate the threshold \(\delta\). The calibration data are latent pairs with labels,
\[
D_{\text{calib}} := \{ ((z_j, z_j'), y_j) \}_{j=1}^{N_{\text{calib}}}, \qquad y_j \in \{0,1\},
\]
where \(y_j=1\) denotes a positive or similar failure pair. The class-conditioned conformal guarantee is
\[
\mathbb{P}\!\left( \tilde{\ell}_z(z_{\text{test}}; z'_{\text{test}}) \le \delta \mid y_{\text{test}} = 1 \right) \ge 1-\alpha.
\]
Equivalently,
\[
\mathbb{P}\!\left( z_{\text{test}} \in F^{\delta}_{z'_{\text{test}}} \mid y_{\text{test}}=1 \right) \ge 1-\alpha.
\]
The nonconformity score is
\[
s_j = -\operatorname{sim}(g(z_j), g(z'_j)),
\]
and using only positive pairs, the threshold is chosen as the \((1-\alpha)\)-quantile of these scores:
\[
\delta = \text{the } \left\lceil (1-\alpha)(N+1) \right\rceil\text{-th smallest value of } \{-\operatorname{sim}(g(z_j), g(z'_j))\}_{j=1}^N.
\]
Smaller \(\alpha\) yields a more conservative threshold, forcing the system to remain farther from the constraint image in the calibrated failure representation [2509.19555].

Training is carried out entirely inside the world model’s imagination. The procedure samples images from the world-model dataset, treats each as a potential future test-time constraint, encodes it as \(c\), and solves the parameterized reachability problem in imagination over many such constraints. In the appendix formulation, the replay buffer stores tuples
\[
(z, c, a, \tilde{\ell}, z'),
\]
the critic is trained with
\[
\mathcal{L}_{\text{critic}} = \mathbb{E}_{\mathcal{B}} \left[ \big(Q(z,a;c)-y\big)^2 \right],
\]
where
\[
y=(1-\gamma)\tilde{\ell}+\gamma \min\{\tilde{\ell},\max_{a'}Q(z',a';c)\},
\]
and the actor uses
\[
\mathcal{L}_{\text{actor}} = \mathbb{E}_{z\sim\mathcal{B}}\left[-Q(z,\bar a;c)\right], \qquad \bar a=\pi(z;c).
\]
The explicit claim is that training on diverse sampled constraints allows interpolation between training constraints and handling of a new constraint image at runtime [2509.19555].

A recurrent misconception is that raw latent similarity should already suffice for runtime constraint adaptation. The reported results do not support that view: the failure projector is presented as crucial because raw latent similarity is too poorly aligned with failure semantics [2509.19555].

## 4. Smooth latent CBF filtering under hard-to-model constraints

A separate but closely related development addresses the problem of turning a learned latent reachability value function into a CBF-like safety filter that modifies the nominal action smoothly rather than by abrupt switching. The discrete-time CBF condition is
\[
\exists a \in A \text{ s.t. } B(f(s,a)) \geq \alpha B(s), \qquad \alpha \in [0,1),
\]
with safe set \(\Omega := \{ s ~|~ B(s) > 0 \}\) disjoint from the failure set \(F\). In HJ reachability, safety is encoded by a margin function \(\ell(s)\) whose zero-sublevel set defines failure,
\[
F := \{ s ~|~ \ell(s) < 0\},
\]
and the safety value function satisfies
\[
V(s) = \min \{ \ell(s), \max_{a \in A} V(f(s,a)) \}.
\]
In that formulation, \(V\) can itself be used as a discrete-time CBF through \(B(s)=V(s)\). The latent-space version uses a discounted Bellman equation,
\[
V(z, a) = (1-\gamma)\ell(z) + \gamma \min \Big\{ \ell(z), ~ \max_{a' \in A} \mathbb{E}_{z' \sim p(z,a)} V(z',a') \Big\},
\]
together with a latent discrete-time CBF filter that selects the action closest to the nominal policy while satisfying a value-based safety inequality [2511.18606].

The paper identifies two incompatibilities between existing latent safety filters and smooth CBF-style optimization. First, training the margin \(\ell(z)\) as a classifier from safe/fail labels tends to produce sharp jumps and a large Lipschitz constant, especially near the failure boundary. The reported theoretical statement is a margin-to-value Lipschitz bound,
\[
L_V \leq L_\ell \cdot \max \left\{1, \frac{1-\gamma}{1 - \gamma L_f} \right\},
\]
where \(L_\ell\) is the Lipschitz constant of the margin, \(L_V\) is the Lipschitz constant of the discounted HJ value function, and \(L_f\) is the Lipschitz constant of the dynamics in state. The implication stated in the paper is that smooth value functions require smooth margin functions. Second, reinforcement-learning approximations trained solely on safety-policy data yield inaccurate value estimates for nominal-policy actions, even though those are precisely the actions that a CBF filter must evaluate near the boundary [2511.18606].

LatentCBF addresses these issues by combining three ingredients. The margin is trained with a WGAN-GP-style objective,
\[
\mathcal{L}_\text{WGAN}(\mu) =
\lambda_{\text{zs}} \Big( \mathbb{E}_{z^- \sim D}[\ell_\mu(z^-)] - \mathbb{E}_{z^+ \sim D}[\ell_\mu(z^+)] \Big)
+ \lambda_{\text{gp}}
\mathbb{E}_{\hat{z} \sim \mathcal{D}_\text{interp}}
\big[(\|\nabla_{\hat{z}} \ell_\mu(\hat{z})\|_2 - \beta)^2\big],
\]
and augmented with the sign loss
\[
\mathcal{L} = \mathcal{L}_\text{WGAN} + \lambda_{\text{sign}} \mathcal{L}^{\delta=0}_\text{sign},
\]
which preserves the semantic zero level set for failure while enforcing smoothness. The value function is trained from a replay buffer containing transitions from both the nominal policy and the safety policy, reducing distribution mismatch. Because the latent CBF filtering problem is nonconvex and not control-affine, the method uses zeroth-order sampling rather than a quadratic program: it samples candidate actions from a mixture of the nominal and safety policies, keeps those satisfying the CBF inequality, and selects the surviving action closest to the nominal action, falling back to the safety policy if none survive [2511.18606].

A common misunderstanding is that a latent reachability value function can automatically serve as a useful smooth CBF. The explicit claim of LatentCBF is that current latent-space learning methods produce fundamentally incompatible value functions unless smoothness of the margin and coverage of nominal-policy actions are addressed [2511.18606].

## 5. State-dependent CBF parameterization and inverse parameter recovery

In safe-by-design neural network controllers, parameterization appears not as a runtime image-conditioned failure set but as a learned CBF decay term embedded directly in the controller architecture. The system is control-affine,
\[
\dot{x} = f(x) + g(x)u,
\]
with polytopic input set \(\mathcal{U}\), and a safety function \(h:\mathbb{R}^n\to\mathbb{R}\) defines the safe set
\[
\mathcal{C} = \{x \in \mathbb{R}^n \mid h(x)\ge 0\}.
\]
The standard CBF condition is
\[
\sup_{u\in \mathcal U}\left[L_f h(x) + L_g h(x)u\right] \ge -\alpha(h(x)).
\]
The usual QP filter solves
\[
\begin{aligned}
u^*(x) &= \arg\min_{u \in \mathcal{U}} \|u-u_{\mathrm{nom}}(x)\|_2^2 \\
&\text{s.t.}\quad -L_g h(x)u \le L_f h(x)+\alpha(h(x)).
\end{aligned}
\]
The paper replaces the fixed, hand-tuned \(\alpha(h(x))\) by a trainable neural parameterization
\[
\alpha_\vartheta(x,h(x)),
\]
with \(\alpha_\vartheta(x,0)=0\), yielding state-dependent affine constraints
\[
A(x)u \le b_\vartheta(x).
\]
These constraints are enforced by construction through the CAffNet-Lite projection layer, avoiding an online QP. Under continuity, feasibility, local Lipschitzness in \(h\), the boundary condition \(\alpha_\vartheta(x,0)=0\), and nonemptiness of the feasible set \(K_\vartheta(x)\), the controller guarantees strong forward invariance of \(\mathcal{C}\) in the Filippov sense [2605.26534].

Inverse safety filtering treats the safety filter itself as a latent parameterized model and works backward from observed action corrections to the hidden constraint parameter. In the discrete-time CBF formulation,
\[
h(s_{t+1}, \theta) \geq (1 - \gamma)\, h(s_t, \theta),
\]
the minimally invasive safety filter solves
\[
\begin{aligned}
u_{\mathrm{safe}} = \arg\min_{u} \quad & \tfrac{1}{2}\|u - u_{\mathrm{nom}}\|^2 \\
\text{s.t.} \quad & h(s_{t+1}(u), \theta) \geq (1-\gamma)\, h(s_t, \theta).
\end{aligned}
\]
Observing \(u_{\mathrm{nom}}\), \(u_{\mathrm{safe}}\), and \(x_t\), the method uses the KKT conditions to infer \(\theta\). Stationarity gives
\[
\Delta u \coloneq u_{\mathrm{safe}} - u_{\mathrm{nom}} = \lambda\, \nabla_u h(s_{t+1}, \theta),
\]
and for the quadratic barrier
\[
h(s, \theta) = (s - \theta)^\top Q (s - \theta) - r^2
\]
this becomes
\[
\Delta u = 2\lambda\, B_s^\top Q(s_{t+1} - \theta).
\]
The paper then defines an inferred direction
\[
\hat{d} \coloneq \frac{Q^{-1}(B_s^\top)^{-1}\Delta u}
{\|Q^{-1}(B_s^\top)^{-1}\Delta u\|},
\]
parameterizes
\[
\theta = s_{t+1} - t \hat{d},
\]
and determines \(t\) from the active constraint condition. Identifiability requires an active constraint, sufficient actuation, and barrier sensitivity to the parameter. In this sense, the latent quantity is the hidden constraint parameter of the filter itself rather than a latent state of a world model [2604.02687].

These two directions show that “constraint parameterization” is not limited to runtime image conditioning. It also includes state-dependent parameterization of the CBF constraint and online recovery of hidden safety parameters from filtered behavior.

## 6. Empirical profile, guarantees, and limitations

AnySafe evaluates runtime adaptation in both simulation and hardware. In the Dubins car benchmark, the world model is a Dreamer/RSSM with continuous latent state trained on \(N_{\text{train}}=4000\) image-action trajectories, each observation is a \(3\times128\times128\) RGB image, calibration uses \(N_{\text{calib}}=3000\) held-out labeled images, positive pairs are within \(\epsilon=0.5\) m, and the conformal level is \(\alpha=0.005\). Tested on 50 different constraint images and 250 safe initial states, the reported metrics for AnySafe with projector are FPR \(0.082\), Recall \(0.966\), Precision \(0.977\), \(F_1=0.971\), Balanced Acc. \(0.942\), and Safe Rate \(0.924\). The version without projector drops to FPR \(0.480\), Precision \(0.881\), Balanced Acc. \(0.755\), and Safe Rate \(0.836\). Calibration also changes the effective distance to the constraint: \(\delta_{0.3}\) yields Min. Dist \(0.377\), \(\delta_{0.4}\) yields \(0.477\), and \(\delta_{0.5}\) yields \(0.569\). On the Franka sweeping task, evaluated over 30 trajectories with different runtime constraints, the method is reported to consistently keep distances to the failure regions above the thresholds, with a distance violation rate less than \(2\%\); in a cross-constraint experiment it also identifies a new intermediate constraint image \(o^{2.5}\) that fixed-filter baselines fail to handle [2509.19555].

LatentCBF reports both smoother interventions and better task completion than least-restrictive switching. In the vision-based Dubins car benchmark, the largest single-step change in \(\ell(z)\) drops from about \(1.2 \pm 0.76\) to \(0.17 \pm 0.065\) when the gradient penalty is used. The nominal policy safety rate is \(41\%\); least-restrictive switching achieves \(97\%\) safety with larger action overrides; the gradient-penalized latent CBF achieves \(100\%\) safety with \(45\%\) lower override magnitude than least-restrictive switching; the non-gradient-penalized latent CBF yields only about \(13\%\) lower override magnitude than least-restrictive switching. On the 7-DOF Franka bag-pickup task, safe-task success rises from \(38\%\) under least-restrictive switching to \(80\%\) under LatentCBF. The paper also reports about 10 ms for 7,600 samples on a 7-DOF manipulator, while a model-based filtering variant runs out of memory beyond about 50 samples. The stated limitations are equally explicit: because the method relies on learned latent representations, learned dynamics, and RL approximations, it does not provide formal safety guarantees; the filter can push the robot into out-of-distribution states; and the method depends on the nominal policy and may be overconfident outside its training distribution [2511.18606].

Safe-by-design neural controllers provide the strongest formal guarantee among the works considered here, but under more structured assumptions. In the single-integrator collision-avoidance benchmark, CAffNet and CAffNet-Lite achieve zero constraint violations and the lowest mean cost among the learned methods, with lower cost than some well-tuned fixed-QP baselines. In fixed-wing aircraft geofencing, both methods have zero violations and equal cost \(3.82\times 10^7\), while CAffNet-Lite is faster, with training time 85.52 ms versus 118.67 ms and test time 21.07 s versus 25.39 s. These results support the paper’s claims of hard architectural enforcement, reduced conservatism relative to fixed \(\alpha(h)=\omega h\), and improved scalability relative to full CAffNet [2605.26534].

Inverse safety filtering emphasizes recoverability of hidden constraints rather than direct performance preservation of a single controller. In 100 randomized two-agent Monte Carlo scenarios with double-integrator dynamics, the KKT-based inference procedure is reported to have essentially zero ghosts, very low error, and the highest discovery rate relative to input matching. Its decentralized safety guarantee requires an inflated demonstration radius
\[
r_{\mathrm{demo}} = r + (d + \varepsilon),
\]
together with initial satisfaction of the formation constraints and forward invariance for the demonstrator; under those assumptions, every agent maintains \(\|s_t^i - \theta\| \ge r\) for all time. The hardware experiments with two Unitree Go2 robots connected by a rope are presented as confirmation that hidden obstacles can be inferred in time for collision avoidance while maintaining formation [2604.02687].

Taken together, these results delineate the present landscape of constraint-parameterized latent safety filtering. Runtime image conditioning demonstrates adaptability without retraining. Smooth latent CBF learning shows that practical filtering quality depends on value-function regularity and action-distribution coverage. Safe-by-design architectures show that parameterization can coexist with strong forward-invariance guarantees when a valid CBF and feasible affine constraints are available. Inverse formulations show that filtered actions themselves can reveal hidden constraint parameters. A plausible implication is that future work will increasingly combine these themes: adaptive constraint specification, smoother latent filtering, and explicit mechanisms for uncertainty estimation and out-of-distribution detection, which are already identified as needed in the learned latent setting [2511.18606].

Source: https://www.emergentmind.com/topics/constraint-parameterized-latent-safety-filters