Bridging Safety and Performance in Offline Reinforcement Learning via Epigraph-Guided Flow Matching

Manan Tayal, Mumuksh Tayal, Ravi PrakashNeurIPS 2026

TL;DR

Training robots or autonomous systems purely from historical data—offline reinforcement learning—usually forces an uncomfortable choice: chase high rewards and risk catastrophic crashes, or guarantee safety and end up with a system too timid to get anything done. This paper introduces EpiFlow, a method that unifies formal control theory with generative AI (Flow Matching) to find the exact "sweet spot." By asking "what is the highest score I can aim for right now without ever crashing in the future?", EpiFlow achieves competitive task performance with near-zero safety violations.

What Problem Does This Paper Address?

You wouldn't teach a self-driving car by letting it crash into pedestrians until it learns better. Instead, we use offline reinforcement learning (RL), training policies entirely from static, pre-collected datasets without live trial-and-error.

When safety is critical, offline RL hits a wall. Existing approaches generally fall into two camps:

  1. Soft-constraint RL: Treats safety like a toll road—violations incur a penalty, so the agent tries to keep average costs low. Where a single failure is unacceptable, "mostly safe on average" isn't good enough.
  2. Classical formal control (e.g., Control Barrier Functions, Hamilton–Jacobi reachability): Treats safety as an unbreakable law. While great at avoiding danger, these methods usually act as blunt safety filters bolted onto a policy, resulting in overly conservative agents that hug the walls and sacrifice performance.
Figure 1: Safety–performance trade-off in offline RL (con- ceptual illustration): soft-constraint methods violate con- straints, while classical safety methods stay safe but follow conservative, lower-performing paths; our method achieves safety with high performance.

Mathematically, the ideal framing is a State-Constrained Optimal Control Problem (SC-OCP): maximize reward subject to zero state-constraint violations ever. Historically, solving SC-OCPs required gridded numerical PDE solvers that choke on the "curse of dimensionality" in complex robotics. The authors ask: can we approximate this exact mathematical ideal directly from offline data in high dimensions?

Methods

EpiFlow (Epigraph-Guided Flow Matching) tackles this in two main stages: learning what is safely achievable, and generating actions to make it happen.

Figure 2: Framework Overview. We propose a framework to solve the SC-OCP problem by using offline dataset. We learn ˆV , which if satisfies to stay positive, makes sure that the system stays safe while maximizing the reward. We then learn a policy which optimizes for ˆV at all time steps to find the most optimal path that the offline data supports.
  • Epigraph Reformulation & Bounded Recursion (Novel): Jointly optimizing hard safety and cumulative reward is messy. Using a mathematical trick called an epigraph reformulation, the authors introduce an auxiliary variable $z$—think of $z$ as a target performance budget. They learn a feasibility value function $\hat{V}(x, z)$ that is non-negative if and only if the agent can start at state $x$, achieve at least return $z$, and remain 100% safe forever. To learn this offline without the neural network ignoring $z$ (a failure mode they prove happens with standard Bellman updates), they derive a bounded Bellman recursion regularized by an explicit upper bound combining separately learned reward and safety envelopes.
  • Avoiding Hallucinated Actions (Standard): To prevent the value function from feeling optimistic about unseen, out-of-distribution actions, they use expectile regression (borrowed from Implicit Q-Learning) to stick to the upper envelope of what the dataset actually supports.
  • Policy Synthesis via Flow Matching (Adapted/Novel Integration): At deployment, given state $x$, EpiFlow runs a fast binary search to find $z^*(x)$—the highest performance budget where $\hat{V}(x, z) \ge 0$. Next, it needs an action. Building on recent Flow Q-Learning, they train a Flow Matching generative model to capture the dataset's behavior, and distill it into a one-step student actor that maximizes the feasibility Q-value at budget $z^*(x)$. This yields fast, single-pass action generation without expensive rejection sampling.

Datasets

No new datasets are introduced, though the authors evaluate on a custom Safe Boat Navigation 2D simulation (navigating a river with spatially varying drift around static obstacles) alongside standard safe offline RL benchmarks from the DSRL (Datasets for Safe Reinforcement Learning) suite:

  • Safety-Gymnasium: High-dimensional MuJoCo velocity tasks (HalfCheetah, Hopper, Ant, Walker2D, Swimmer) and Car Navigation tasks (CarButton1, CarGoal1, CarPush1).
  • Bullet-Safety-Gym: Eight Run and Circle tasks across four embodiments (Ant, Ball, Car, Drone).

Key Insights and Ideas

  • Preventing "Value Collapse" Offline: A major "aha" moment in the paper is realizing why standard epigraph dynamic programming fails offline. The Bellman update for $\hat{V}(x, z)$ looks structurally identical to a pure safety calculation; $z$ only shifts quietly in the background. On fixed data, neural networks take the lazy route, ignoring $z$ entirely and collapsing into a conservative, safety-only model. Adding a simple one-sided penalty enforcing $\hat{V}(x, z) \le \min(V_{\text{reward}}(x) - z, V_{\text{safety}}(x))$ forces the network to stay sensitive to performance.
  • Dynamic Risk Allocation: Because $z^*(x)$ is computed at every state via binary search, the agent dynamically adjusts its ambition—pushing for high rewards in open, safe regions and automatically clamping down to safety-recovery mode near hazards.

Key Results

Evaluated across 500 episodes and 5 random seeds per task against eight baselines (both Lagrangian soft-constraint methods like BEAR-Lag/CPQ and hard-safety methods like FISOR/V-OCBF):

Figure 3: Evaluation Results: Results plot for all the environments. Points towards left (←) are more safe than those on right (→). Whereas those towards top (↑) have higher rewards than those towards bottom (↓). Evaluated over 500 episodes and 5 seed values (± standard deviation).
  • Superior Safety–Performance Balance: EpiFlow consistently occupies the top-left corner of evaluation plots (high reward, near-zero violations). Soft-constraint baselines rack up 25 to 100+ violations per episode to get high scores, while hard-safety filters like FISOR and NCBF get near-zero violations but sacrifice massive amounts of reward (e.g., on HalfCheetah, EpiFlow scores ~2600 with zero cost, whereas V-OCBF/NCBF score ~900–1200).
  • Bullet-Safety-Gym: EpiFlow achieves the highest return among all methods that maintain zero observed violations across all eight tasks.
  • Fast Training & Inference: Because the flow-matching teacher is distilled into a one-step actor, inference takes ~100 ms—more than 2x–3x faster at deployment than CBF/reachability baselines like FISOR (~240 ms) and V-OCBF (~345 ms), while training in under 200 seconds (vs. 600–800s for CPQ/BEAR-Lag).

Limitations and Future Work

  • Empirical, Not Formal, Guarantees: Because $\hat{V}$ is approximated with neural networks on finite data, safety guarantees remain empirical. Sparse data near hazard boundaries still causes small residual violations in tricky tasks like Hopper and CarPush1.
  • Deterministic Dynamics Only: The math assumes deterministic state transitions. In stochastic environments, a static dataset only records one outcome per action, making it impossible to identify the true "worst-case" successor state.
  • Future Directions: The authors plan to integrate formal verification tools (such as Lipschitz-based certification and conformal prediction) to bridge the approximation gap, and explore uncertainty-aware objectives like Conditional Value-at-Risk (CVaR) to handle stochasticity and disturbances.

Summary updated

Abstract

Offline reinforcement learning (RL) offers a promising framework for deploying autonomous systems in safety-critical settings without the risks of online exploration. However, learning policies that simultaneously achieve high performance and strong safety guarantees from fixed datasets remains a fundamental challenge. Many existing safe offline RL approaches typically rely on soft constraint formulations, which may permit safety violations and are sensitive to distributional shift. In contrast, formal methods such as Hamilton--Jacobi (HJ) reachability and Control Barrier Functions (CBFs) provide rigorous safety guarantees, but often yield overly conservative solutions, often neglecting performance. In this work, we bridge this gap by formulating safe offline RL as a state-constrained optimal control problem, where safety is enforced through hard state constraints and performance is captured via a reward function. The resulting value function satisfies a Hamilton--Jacobi--Bellman (HJB) equation, which we approximate using offline RL on fixed datasets by learning an epigraph feasibility value function and extracting policies via flow matching. This formulation enables principled integration of safety guarantees with data-driven policy optimization. Empirically, across safety-critical benchmarks including boat navigation, Safety-Gymnasium, and Bullet-Safety-Gym tasks, our approach achieves competitive returns while exhibiting near-zero constraint violations, demonstrating a favorable balance between safety and performance in the offline setting.
BibTeX
@inproceedings{tayal2026bridging,
  author = {Manan Tayal and Mumuksh Tayal and Ravi Prakash},
  title = {{Bridging Safety and Performance in Offline Reinforcement Learning via Epigraph-Guided Flow Matching}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=i6JA2toOiB},
}
Figure