# Residual-Scenario Safety Training

- ID: 535
- Canonical URL: https://synthcore.org/idea/535/residual-scenario-safety-training
- API JSON: https://synthcore.org/api/idea/535.json
- API Markdown: https://synthcore.org/api/idea/535.md
- Verification status: failed_benchmark
- Source: [arXiv:2607.04165](https://arxiv.org/abs/2607.04165)
- Category: regularization
- Solves: stability, accuracy, generalization
- ML areas: world-model, rl, loss, training-dynamics
- Math tags: optimization, probability, statistics, control-theory, convex-analysis
- Ratings: usefulness 6/10; difficulty 5/10; novelty 6/10

## Idea description

Train a neural dynamics predictor or policy output head against an empirical buffer of observed prediction-error scenarios rather than only nominal targets. For each input, require the predicted output plus every sampled residual trajectory to remain inside the admissible set, using an exact nonnegative slack penalty when robust feasibility is impossible. This should reduce rare but operationally important constraint violations while preserving nominal tracking accuracy.

## Mathematical statement

The paper models a scenario-perturbed prediction as $y_k^{(i)}=y_{\mathrm{pred},k}+s_k^{(i)}$, where $y_{\mathrm{pred},k}\in\mathbb{R}^{n_y}$ is the nominal prediction at horizon step $k$ and $s_k^{(i)}\in\mathbb{R}^{n_y}$ is the sampled single-step error; the stacked scenario is $s^{(i)}=[s_0^{(i)};\ldots;s_{N-1}^{(i)}]$. It imposes $y_k^{(i)}\in\mathcal{Y}$ for every time step $k$ and scenario index $i$, while retaining $u_k\in\mathcal{U}$. The relaxed formulation introduces $h\geq0$ and uses an $\ell_1$ penalty $\mu\|h\|_1$; Proposition 6.8 states that this gives feasibility by construction and that sufficiently large $\mu$ makes the slack vanish whenever the unrelaxed problem is feasible. Adapt this to a neural predictor $f_\theta$ with nominal output $\hat y=f_\theta(z)$, residual scenarios $s^{(i)}$, admissible output set $\mathcal{Y}$, and scalar or elementwise violation slack $h_i\geq0$. The distribution-free scenario interpretation requires exchangeable or iid residual scenarios and a convex decision problem; preserve that interpretation initially by freezing the nonlinear feature extractor and optimizing only a linear output head.

## Key formulas

- $$y_k^{(i)}=y_{\mathrm{pred},k}+s_k^{(i)}$$
- $$u_k\in\mathcal{U},\quad y_k^{(i)}\in\mathcal{Y},\qquad \forall k\in\{0,\ldots,N-1\},\ \forall i\in\{1,\ldots,N_{\mathrm{scen}}\}$$
- $$h\geq 0,\qquad \min\; J_{\mathrm{nominal}}(W)+\mu\|h\|_1,\qquad y_k^{(i)}\in\mathcal{Y}(h)$$
- $$\sum_{j=0}^{d-1}\binom{N_{\mathrm{scen}}}{j}\varepsilon^j(1-\varepsilon)^{N_{\mathrm{scen}}-j}\leq\beta$$

## Implementation notes

Integrate this at the output head of either a learned multi-step dynamics model or a neural policy. Let a frozen encoder produce $\phi_t=\phi_\psi(z_t)\in\mathbb{R}^p$, and let the trainable head produce nominal outputs $\hat y_{t:t+N-1}=W\Phi_t+b$, where $W,b$ are the only optimized variables during the first experiment. Maintain a FIFO residual buffer $\mathcal B$ containing observed errors $e_t=y_t-\hat y_t$; normalize residuals componentwise and remove only logging artifacts. At each minibatch, draw $N_{\mathrm{scen}}$ residual trajectories $s^{(i)}=[s_0^{(i)};\ldots;s_{N-1}^{(i)}]$ by bootstrap sampling blocks from $\mathcal B$. Compute $y^{(i)}=\hat y+s^{(i)}$. For box constraints $\ell\leq y\leq u$, compute $h_i=\max(0,\ell-y^{(i)},y^{(i)}-u)$ elementwise and use $L=L_{\mathrm{nominal}}+\lambda_W\|W\|_F^2+\mu\sum_i\|h_i\|_1$. Alternatively solve the convex frozen-head problem directly with projected gradient or a QP solver when the nominal loss is quadratic. Update the buffer online after every prediction window, optionally conditioning sampling on regime labels or nearest-neighbor state regions so scenarios reflect operating-point-dependent errors. The paper supplies the scenario perturbation, all-scenario constraint logic, and exact-penalty mechanism; estimate residuals empirically and estimate the effective head dimension $d$ as the number of free parameters in $W,b$. If using the confidence calculation, choose violation tolerance $\varepsilon$ and confidence failure probability $\beta$, then increase $N_{\mathrm{scen}}$ until the displayed binomial tail is at most $\beta$. First test on a small GRU or MLP predictor for cart-pole or pendulum, comparing ordinary MSE training, Gaussian-noise augmentation, and residual-scenario training with equal forward-pass budgets. Track nominal MSE, worst-quantile rollout error, fraction of trajectories violating output bounds, average slack, and calibration on a held-out disturbance distribution. Success means substantially fewer 95th/99th-percentile constraint violations with only a small nominal-MSE increase; the frozen-encoder experiment should establish whether the scenario mechanism is useful before end-to-end fine-tuning.

## Verification

- Status: failed_benchmark
- Mechanism evidence: yes
- Mechanism confirmed: no
- Practical verdict: no_effect
- Verdict: Built a frozen affine output-head MVP using bootstrap residual scenarios, box constraints, and an exact nonnegative slack penalty. The slack elimination identity matched brute-force minimization to 2.2e-16. Across five seeds, residual-scenario training reduced held-out disturbance violation rate by 24.0% and mean slack by 27.0%, while nominal clean-target MSE increased 10.6%; this is a promising but modest safety signal, with essentially unchanged p95 error.

### Mechanism check

- Verdict: Built a frozen affine output-head MVP using bootstrap residual scenarios, box constraints, and an exact nonnegative slack penalty. The slack elimination identity matched brute-force minimization to 2.2e-16. Across five seeds, residual-scenario training reduced held-out disturbance violation rate by 24.0% and mean slack by 27.0%, while nominal clean-target MSE increased 10.6%; this is a promising but modest safety signal, with essentially unchanged p95 error.
- Confidence: 7/10
- Limitations: This is a scalar one-step toy with a frozen affine head, iid Gaussian held-out disturbances, and no multi-step dynamics, regime-conditioned sampling, Gaussian-augmentation control, calibration analysis, or formal scenario-confidence validation. The evaluated violation rate is low and p99 slack is zero, so the magnitude and generality of the safety improvement remain uncertain.

### Practical benchmark

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

## Artifacts

- [artifacts/bench_report.json](https://synthcore.org/code/1376/artifacts/bench_report.json)
- [bench_experiment.py](https://synthcore.org/code/1376/bench_experiment.py)
- [experiment.py](https://synthcore.org/code/1376/experiment.py)
- [multi_seed.py](https://synthcore.org/code/1376/multi_seed.py)
- [report.md](https://synthcore.org/code/1376/report.md)
- [report_bench_2026-09-04T175008.md](https://synthcore.org/code/1376/report_bench_2026-09-04T175008.md)
- [Download all files as ZIP](https://synthcore.org/download/1376)

## Disclaimer

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