# Predictive Safe Projection for Flow-Matching Actions

- ID: 524
- Canonical URL: https://synthcore.org/idea/524/predictive-safe-projection-for-flow-matching-actions
- API JSON: https://synthcore.org/api/idea/524.json
- API Markdown: https://synthcore.org/api/idea/524.md
- Verification status: mech_ok_no_baseline
- Source: [arXiv:2607.01378](https://arxiv.org/abs/2607.01378)
- Category: sampling
- Solves: stability, accuracy, generalization
- ML areas: diffusion-sampling, diffusion, world-model
- Math tags: optimization, geometry, control-theory, dynamical-systems
- Ratings: usefulness 7/10; difficulty 5/10; novelty 5/10

## Idea description

Add a safety projection step to every or selected Euler updates of a flow-matching action sampler. Instead of correcting only the first action, differentiate a collision-risk function through the predicted full action chunk, construct local linear inequality constraints, and apply the smallest correction that makes the future trajectory safe.

## Mathematical statement

The paper generates an action chunk A_t=[a_t,a_{t+1},...,a_{t+H-1}] by integrating a learned velocity field v_theta from Gaussian noise. The flow-matching update is forward Euler integration, A_t^{tau+Delta tau}=A_t^tau+Delta tau v_theta(A_t^tau,o_t,tau), where tau is flow time, Delta tau is the integration step, o_t is the observation, and v_theta is the learned velocity field. Let g_j(A,o)>=0 be the signed safety margin for constraint j, where nonnegative values mean safe. Around the current trajectory A, linearize g_j(A+delta,o) as g_j(A,o)+J_j delta, with J_j=partial g_j/partial A. Compute the minimum-norm correction by solving min_delta 1/2||delta||_2^2 subject to J_j delta >= -g_j(A,o) for every constraint. For one active constraint J delta >= -g(A,o), the exact correction is zero when g(A,o)>=0 and otherwise delta*=(-g(A,o))/||J||_2^2 J^T. For multiple constraints, solve the small quadratic program with an active-set or projected-gradient method. Apply this correction to the Euler candidate, optionally scaled by lambda_delta. A is the flattened H-step action trajectory, J contains one row per predicted collision or joint-limit constraint, and g can be a differentiable signed-distance margin minus a required safety buffer.

## Key formulas

- $$A_t^{\tau+\Delta\tau}=A_t^\tau+\Delta\tau\,v_\theta(A_t^\tau,o_t,\tau),\qquad A_t^1\sim\mathcal N(0,I).$$
- $$g_j(A,o)\ge 0,\qquad g_j(A+\delta,o)\approx g_j(A,o)+J_j\delta,\qquad J_j=\nabla_A g_j(A,o).$$
- $$\delta^*=\arg\min_{\delta}\frac12\|\delta\|_2^2\quad\text{s.t.}\quad J_j\delta\ge -g_j(A,o)\ \forall j.$$
- $$A^{\tau+\Delta\tau}=A^\tau+\Delta\tau\,v_\theta(A^\tau,o,\tau)+\lambda_\delta\delta^*,\qquad \delta^*=\frac{-g(A,o)}{\|J\|_2^2}J^T\ \text{when }g(A,o)<0\text{ for one constraint}. $$

## Implementation notes

Integrate this at inference time in the flow-matching action sampler, immediately after the velocity-field Euler update and before the next flow-time evaluation. Flatten the predicted action chunk A with shape [H, action_dim]. For an MVP, use differentiable robot forward kinematics and an obstacle representation such as spheres or signed-distance fields. Define g_j(A,o)=distance(link_j(A), obstacle_j(o))-margin, and add joint-limit margins for each future timestep. At each sampler step: sample A from N(0,I); compute v=v_theta(A,o,tau); form A_candidate=A+Delta_tau*v; evaluate all margins g_j(A_candidate,o); obtain each Jacobian J_j by automatic differentiation with respect to A_candidate; solve min 0.5||delta||^2 subject to J delta >= -g using an active-set solver or one to five projected-gradient iterations; clip delta to a maximum action norm; and set A=A_candidate+lambda_delta*delta. Recompute constraints at every flow step, or only when any margin falls below a trigger threshold. The paper supplies the Euler transport and minimum-norm projection; obstacle geometry, Jacobians, and active constraints are estimated online. First test a small flow-matching policy on a 2D point-mass or simulated 7-DOF reaching task, comparing unconstrained sampling, next-action-only projection, and full-horizon projection at H=10, 20, and 40. Record collision rate, task success, correction norm, and sampler latency. Success means lower collision rate with no major task-success loss and less than 20% additional inference cost.

## Verification

- Status: mech_ok_no_baseline
- Mechanism evidence: yes
- Mechanism confirmed: yes
- Practical verdict: harms
- Verdict: Built a NumPy MVP implementing Euler flow sampling, differentiable obstacle margins, exact single-halfspace projection, and cyclic multi-constraint predictive projection over the full action horizon. The mechanism checks matched their quantitative predictions: correction norm slope 0.523245 predicted versus 0.523245 observed, lambda residual error 5.6e-17, and active constraints scaled exactly with horizon. In the toy sampler, predictive projection reduced collision rate from 0.913 to 0.010 versus 0.890 for first-step projection, but latency increased from 1.12 ms to 6.42 ms and the baseline task setup had zero success, so this is evidence for the safety mechanism rather than a validated practical performance win.

### Mechanism check

- Verdict: Built a NumPy MVP implementing Euler flow sampling, differentiable obstacle margins, exact single-halfspace projection, and cyclic multi-constraint predictive projection over the full action horizon. The mechanism checks matched their quantitative predictions: correction norm slope 0.523245 predicted versus 0.523245 observed, lambda residual error 5.6e-17, and active constraints scaled exactly with horizon. In the toy sampler, predictive projection reduced collision rate from 0.913 to 0.010 versus 0.890 for first-step projection, but latency increased from 1.12 ms to 6.42 ms and the baseline task setup had zero success, so this is evidence for the safety mechanism rather than a validated practical performance win.
- Confidence: 9/10
- Limitations: Only a synthetic 2D point-action flow field and spherical point obstacle were tested; no learned neural flow-matching policy, robot forward kinematics, multiple interacting obstacle constraints, GPU implementation, real task-success benchmark, or rigorous QP solver comparison was evaluated. The cyclic projection is an approximation for multiple constraints, and the toy baseline's zero success makes task-quality conclusions weak.

### Practical benchmark

- Paired seeds: 8
- Baseline mean: 0
- Idea mean: 0
- p-value: 0.0081
- Paired wins: 0/8
- Benchmark verdict: idea worse (significant)

## Artifacts

- [bench_report.json](https://synthcore.org/code/245/bench_report.json)
- [predictive_control_track.py](https://synthcore.org/code/245/predictive_control_track.py)
- [report.md](https://synthcore.org/code/245/report.md)
- [report_bench_2026-08-30T213406.md](https://synthcore.org/code/245/report_bench_2026-08-30T213406.md)
- [results.json](https://synthcore.org/code/245/results.json)
- [safe_projection_bench.py](https://synthcore.org/code/245/safe_projection_bench.py)
- [safe_projection_mvp.py](https://synthcore.org/code/245/safe_projection_mvp.py)
- [Download all files as ZIP](https://synthcore.org/download/245)

## Disclaimer

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