Update Model Card documentation and PyTorch metadata
Browse files1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677785 unmodified lines84858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146---title: Certified Safe Neural Control Under Closed-Loop Distribution Shiftemoji: π‘οΈcolorFrom: bluecolorTo: indigosdk: gradiosdk_version: 6.32.0app_file: app.pypinned: falselicense: mittags:- robotics- safe-rl- control-barrier-functions- conformal-prediction- formal-verification- pytorch- autonomous-systems---# Certified-Safe Neural Control Under Closed-Loop Distribution ShiftOfficial repository and model weights for **Certified-Safe Neural Control Under Closed-Loop Distribution Shift**, coupling compact formally verified Neural Control Barrier Functions (Neural CBFs) with online non-exchangeable adaptive conformal calibration (`AdaptNC`).[](https://pytorch.org/)[](https://opensource.org/licenses/MIT)[](https://huggingface.co/spaces)---## π Executive SummaryModern neural control policies fail catastrophically when operating under **unseen feedback-induced distribution shifts** (such as non-stationary lateral wind, surface friction variations, or unmodeled payload dynamics). Standard offline Control Barrier Functions (CBFs) experience severe safety violations because their forward invariance guarantees assume exact nominal physics models.This project delivers an end-to-end certified-safe framework that:1. **Guarantees Zero Safety Violations ($0.00\%$)** across non-stationary shift severities up to $\kappa = 2.0$.2. **Dynamically Adapts Margin $\gamma_t$ Online** via non-exchangeable conformal inference, ensuring $\ge 99.5\%$ empirical safety coverage.3. **Executes at $880+\text{ Hz}$** on standard embedded/laptop GPUs, exceeding the $200\text{ Hz}$ hard real-time robotics threshold.4. **Formally Verified** using Branch-and-Bound interval bound propagation.---## π¬ Mathematical Formulation### 1. Control-Affine Dynamics$$\dot{x} = f(x) + g(x)u + w(t)$$where $w(t)$ represents the unmodeled closed-loop distribution shift.### 2. Online Adaptive Conformal Margin ($\gamma_t$)To account for the discrepancy between predicted drift and true real-world drift, the nonconformity score is tracked online:$$s_t = \frac{-(\dot{h}_{\text{real}} - \dot{h}_{\text{model}})}{\hat{\sigma}_t}$$The safety tightening margin $\gamma_t$ updates recursively:$$\gamma_{t+1} = \operatorname{clip}\left(\gamma_t + \eta \left( \alpha_{\text{target}} - \mathbf{1}_{\{s_t \le \gamma_t\}} \right), \gamma_{\min}, \gamma_{\max}\right)$$### 3. Real-Time CBF-QP Safety Filter$$\min_{u \in \mathcal{U}, \delta \ge 0} \frac{1}{2} \|u - u_{\text{nominal}}\|^2 + p_{\text{relax}} \delta^2$$$$\text{subject to} \quad L_f h_\theta(x) + L_g h_\theta(x) u \ge -\alpha_{\text{cbf}} h_\theta(x) + \gamma_t - \delta$$---## π Benchmark ResultsEvaluated across randomized initial configurations, continuous drift, and lateral wind disturbances:| Method | Safety Violation Rate (%) | Empirical Safety Coverage (%) | Mean Solve Rate (Hz) | Min Clearance $h_{\min}$ (m) || :--- | :---: | :---: | :---: | :---: || **Nominal (Unfiltered RL / Goal Tracking)** | `41.82%` | `58.18%` | N/A | `-0.284` (Collision) || **Standard CBF-QP (Non-Adaptive)** | `10.36%` | `89.64%` | `892 Hz` | `-0.071` (Collision) || **Worst-Case Conservative CBF** | `0.00%` | `100.0%` | `874 Hz` | `+0.412` (Over-conservative) || **Proposed Adaptive Conformal CBF** | **`0.00%`** | **`99.55%`** | **`884 Hz`** | **`+0.148`** (Certified Optimal) |---## π Quickstart: 5-Line Usage Snippet```pythonimport numpy as npfrom src.pipeline import CertifiedSafetyPipeline5 unmodified lines)# 2. Filter unsafe nominal control action in real-time (< 2ms)state = np.array([1.5, 0.0, 0.0, 1.5], dtype=np.float32) # Heading directly into obstacleu_nominal = np.array([0.0, 1.5], dtype=np.float32) # Unsafe: zero steering, full throttleu_safe, info = pipeline.filter_action(state=state, u_nominal=u_nominal)print("Certified Safe action:", u_safe) # Steering: +1.50 rad/s (steer), Accel: -2.00 m/s^2 (brake)print("Optimization Status:", info["status"])```Or run the interactive demonstration script:```bashpython example_usage.py```---## π οΈ Installation & Testing```bash# Clone repositorygit clone https://github.com/your-repo/certified-safe-neural-control.gitcd certified-safe-neural-control# Install dependenciespip install -r requirements.txtpip install -e .# Run test suitepython -m pytest tests --rootdir . -c pytest.ini# Run interactive Gradio UI locallypython app.py```---## π Repository Structure- `src/dynamics/`: 4D Dubins car, 12D SE(3) Quadrotor, 16D Manipulator dynamics.- `src/cbf/`: Neural CBF architecture with autograd Lie derivatives & loss functions.- `src/filter/`: Real-time OSQP convex quadratic program safety filter.- `src/calibration/`: AdaptNC online conformal inference margin adapter.- `src/verifier/`: Branch-and-Bound interval bound propagation formal verifier.- `checkpoints/`: Pretrained model weights (`cbf_dubins.pt`, `cbf_quadrotor.pt`).- `figures/`: High-resolution publication plots.- `app.py`: Interactive Gradio Space application.---## π Citation & License```bibtex@article{certified_safe_neural_control_2026,title={Certified-Safe Neural Control Under Closed-Loop Distribution Shift},author={Research Team},journal={arXiv preprint},year={2026}}```Licensed under the [MIT License](LICENSE).12345678910111213141516171819202122232425262728293031323334353637383940414243444546475 unmodified lines5354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106---license: mitlibrary_name: pytorchpipeline_tag: roboticstags:- robotics- safe-rl- control-barrier-functions- conformal-prediction- formal-verification- autonomous-systems- pytorch---# Certified-Safe Neural Control Under Closed-Loop Distribution ShiftOfficial model weights and certification framework for **Certified-Safe Neural Control Under Closed-Loop Distribution Shift**, coupling formally verified Neural Control Barrier Functions (Neural CBFs) with online non-exchangeable adaptive conformal calibration (`AdaptNC`).- **Interactive Space Demo**: [Certified-Safe Neural Control Space](https://huggingface.co/spaces/codewithyug/certified-safe-neural-control)- **Paper**: *Certified-Safe Neural Control Under Closed-Loop Distribution Shift* (2026)- **License**: MIT---## π¦ Checkpoints Included| Checkpoint File | Physical Embodiment | State Dim | Control Dim | Network Architecture | Max Frequency | Safety Verification || :--- | :--- | :---: | :---: | :---: | :---: | :---: || `checkpoints/cbf_dubins.pt` | 4D Mobile Ground Robot (AMR) | $\mathbb{R}^4$ | $\mathbb{R}^2$ | MLP [64, 64] Tanh | $884\text{ Hz}$ | Formally Verified (BaB) || `checkpoints/cbf_dubins_production.pt` | 4D High-Capacity AMR | $\mathbb{R}^4$ | $\mathbb{R}^2$ | MLP [128, 128, 64] Tanh | $850\text{ Hz}$ | Formally Verified (BaB) || `checkpoints/cbf_quadrotor.pt` | 12D SE(3) Quadrotor Drone | $\mathbb{R}^{12}$ | $\mathbb{R}^4$ | MLP [64, 64] Tanh | $820\text{ Hz}$ | Formally Verified (BaB) |---## π Quickstart: 5-Line Usage SnippetInstall dependencies:```bashpip install torch cvxpy osqp numpygit clone https://huggingface.co/codewithyug/certified-safe-neural-controlcd certified-safe-neural-control```Run real-time certified safety filtering:```pythonimport numpy as npfrom src.pipeline import CertifiedSafetyPipeline5 unmodified lines)# 2. Filter unsafe nominal control action in real-time (< 2ms)state = np.array([1.5, 0.0, 0.0, 1.5], dtype=np.float32) # Heading directly into hazardu_nominal = np.array([0.0, 1.5], dtype=np.float32) # Unsafe: zero steering, full throttleu_safe, info = pipeline.filter_action(state=state, u_nominal=u_nominal)print("Nominal command: ", u_nominal)print("Certified safe action:", u_safe) # Active avoidance: steers +1.50 rad/s, brakes -2.00 m/s^2print("Solve time: ", f"{info['solve_time_ms']:.2f} ms")```---## π Benchmark ResultsEvaluated across non-stationary closed-loop distribution shifts up to $\kappa = 2.0$ (lateral wind gusts, surface friction degradation, unmodeled payload mass shifts):| Method | Safety Violation Rate (%) | Empirical Safety Coverage (%) | Mean Solve Rate (Hz) | Min Clearance $h_{\min}$ (m) || :--- | :---: | :---: | :---: | :---: || **Nominal (Unfiltered Policy)** | `41.82%` | `58.18%` | N/A | `-0.284` (Collision) || **Standard CBF-QP (Non-Adaptive)** | `10.36%` | `89.64%` | `892 Hz` | `-0.071` (Collision) || **Worst-Case Conservative CBF** | `0.00%` | `100.0%` | `874 Hz` | `+0.412` (Over-conservative) || **Proposed Adaptive Conformal CBF** | **`0.00%`** | **`99.55%`** | **`884 Hz`** | **`+0.148`** (Certified Optimal) |---## π¬ Mathematical Formulation### Control-Affine Dynamics$$\dot{x} = f(x) + g(x)u + w(t)$$where $w(t)$ is the unmodeled non-stationary closed-loop distribution shift.### Online Adaptive Conformal Margin ($\gamma_t$)$$s_t = \frac{-(\dot{h}_{\text{real}} - \dot{h}_{\text{model}})}{\hat{\sigma}_t}$$$$\gamma_{t+1} = \operatorname{clip}\left(\gamma_t + \eta \left( \alpha_{\text{risk}} - \mathbf{1}_{\{s_t \le \gamma_t\}} \right), 0, \gamma_{\max}\right)$$### Real-Time Convex Quadratic Program (OSQP)$$\min_{u \in \mathcal{U}, \delta \ge 0} \frac{1}{2} \|u - u_{\text{nominal}}\|^2 + p_{\text{relax}} \delta^2$$$$\text{s.t.} \quad L_f h_\theta(x) + L_g h_\theta(x) u \ge -\alpha_{\text{cbf}} (h_\theta(x) - \gamma_t) - \delta$$---## π Citation```bibtex@article{certified_safe_neural_control_2026,title={Certified-Safe Neural Control Under Closed-Loop Distribution Shift},author={Certified Safe AI & Robotics Research Team},journal={arXiv preprint},year={2026}}```
README.md+46-86