Safe offline reinforcement learning Under review · TMLR

PID-DiffRL: Safe Offline Reinforcement Learning as Noisy Delayed Feedback Control

Learning safety only from logged data means trusting a biased, late, noisy safety signal; tuning the safety price like a thermostat kept all 11 benchmark tasks within budget.

SafetyReinforcement LearningDiffusion Models
Watch its chapter of the film

Learning to be careful from someone else's diary

Imagine you want to teach a robot to run fast without ever exceeding a safe speed, but you are not allowed to let it practise. All you have is a log: thousands of runs recorded earlier by other controllers, some cautious, some reckless, each step tagged with the reward it earned and the safety cost it incurred. From that diary alone you must produce a policy that scores well and stays under a cost budget when it is finally switched on.

This is safe offline reinforcement learning, and it matters wherever trial and error is expensive or dangerous: driving, robotics, healthcare. A new paper from the optimal* lab, PID-DiffRL: Safe Offline Reinforcement Learning as Noisy Delayed Feedback Control (currently under review at TMLR), argues that one of its hardest parts is a question of control engineering in disguise.

The safety price, and why offline makes it slippery

The standard recipe for safe RL attaches a price to cost. A number called the Lagrange multiplier, λ, says how much the learner should care about the safety budget. If the policy is spending more cost than the limit κ allows, λ goes up and safety weighs more heavily; if the policy is comfortably inside the limit, λ drifts down and reward gets more attention. The textbook update simply adds the current violation to λ at every step.

When the agent can practise, this works reasonably well, because the violation is measured: run the current policy, count the cost, compare it to the limit. Offline, there is nothing to run. The violation has to be estimated by a learned model, a cost critic, which predicts how much cost the policy would incur. And it must make that prediction for actions the current policy proposes, which may be actions the dataset never contains.

The paper names three ways this estimated signal goes wrong:

The authors observe that the textbook update, which only ever accumulates past violations, is what a control engineer would call integral-only feedback. Integral-only control is known to be slow to react and prone to oscillation when its sensor reports late or noisily.

A thermostat with a bad thermometer

Picture a heater controlled by a thermometer that reads a little wrong, updates a few minutes late, and jitters. A controller that only looks at accumulated error keeps pushing the heater harder for as long as the room has been cold, even after the room has started warming, because the thermometer has not caught up yet. The result is overshoot, then overcorrection, then overshoot again.

Engineers handle this with a PID controller. In the paper's own words, it looks at the error three ways: "where the system is now, how long it has remained away from the target, and whether it is moving toward or away from the target." The proportional term reacts to the current error, the integral term removes persistent error, and the derivative term notices when the error is already shrinking and eases off.

PID control of the safety multiplier is not new in itself: earlier work applied it to online safe RL, where violations come from fresh rollouts. The contribution here is to frame the offline problem, where the sensor is a learned critic, as noisy delayed feedback control, and to build a method around that framing.

The method: three parts that fit together

PID-DiffRL combines three ingredients.

  1. A PID-controlled safety price. At each training step, the controller computes the critic-estimated violation (predicted cost minus the limit, scaled by the limit), keeps a clipped running sum of it, and takes its change since the last step. The update to λ is a weighted combination of the three, and λ itself is kept between 0 and a ceiling of 10. The gains are fixed across all tasks: kP = 0.01, kI = 0.001, kD = 0.005.
  2. A more pessimistic thermometer. The method trains two cost critics and uses the larger of their two predictions. Mathematically, the maximum of two numbers equals their average plus half their disagreement, so this choice pushes the estimate up exactly when the critics disagree, which is often where the data is thin. The authors are explicit that this is a heuristic for reducing optimistic underestimation, not a guaranteed upper bound: both critics can be wrong in the same direction.
  3. A diffusion policy. Instead of the usual bell-shaped (Gaussian) policy, the actor is a diffusion model that generates an action by gradually denoising random noise, the same family of models behind modern image generators. Logged datasets often contain several distinct ways of behaving, and safe actions can sit in separate pockets. A single bell curve stretched over two safe pockets also covers the unsafe gap between them; a diffusion model can place its probability on the pockets themselves.

A toy example in the paper makes the last point concrete. With two separated safe regions and an unsafe bridge between them, a Gaussian fitted to both modes put 53.2% of its samples in the bridge and 26.0% in the safe regions, while the diffusion policy put 0.3% in the bridge and 99.7% in the safe regions. The authors add that this illustrates the fitted policies in that example, not an impossibility of safe Gaussian behaviour or a guarantee for diffusion policies.

What was found

The method was tested on 11 tasks from the DSRL benchmark, spanning simulated agents from point masses and balls to cars, drones, hoppers, half-cheetahs, ants and swimmers, against eight offline safe RL baselines, including the recent O3SRL and FISOR. Each number is averaged over 5 random seeds and 100 evaluation episodes. Rewards are normalised to a 0 to 100 scale, and costs are normalised so that anything above 1 breaks the safety budget.

The headline result is consistency. PID-DiffRL stayed within the cost threshold on all 11 tasks, while O3SRL and FISOR were each safe on 8 of 11. Its largest normalised cost on any task was 0.26 (HopperVel). It also obtained the best reward among safe methods on 8 of the 11 tasks, for example HopperVel (reward 87.26, cost 0.26), HalfCheetahVel (99.93, 0.00), BallCircle (69.90, 0.01) and AntRun (57.41, 0.01).

Normalized cost on the tasks where recent baselines break the budgetPID-DiffRL vs O3SRL and FISOR, mean over 5 seeds; above 1 means the cost limit is violated. Lower is better.
O3SRLFISORPID-DiffRL02.557.5103.506.630.00PointCircle10.798.950.02PointCircle20.020.420.01AntRun1.250.010.00BallRun1.271.280.20DroneRuncost limitnormalized cost

Source: Table 1, page 10 of the paper.

Show the numbers
O3SRLFISORPID-DiffRL
PointCircle13.506.630.00
PointCircle20.798.950.02
AntRun0.020.420.01
BallRun1.250.010.00
DroneRun1.271.280.20

Note that it is not best everywhere. On SwimmerVel, CarCircle and AntVelocity, at least one baseline was also safe and earned more reward. Among the 8 tasks where O3SRL is safe, PID-DiffRL has higher reward on 7, and the same holds against FISOR.

The ablations probe each ingredient separately.

Taking the larger of two cost critics keeps the policy safeNormalized cost with min vs max aggregation of the twin cost critics, 5 seeds. Lower is better.
Min aggregationMax aggregation0510153.420.01AntRun10.630.20DroneRun1.510.00BallRuncost limitnormalized cost

Source: Table 2, page 12 of the paper.

Show the numbers
Min aggregationMax aggregation
AntRun3.420.01
DroneRun10.630.20
BallRun1.510.00

The Gaussian comparison deserves a careful reading. The Gaussian variant was still safe on three of the four tasks; what it lost was reward. The paper says the result supports the more expressive parameterization but does not establish multimodality as the sole source of the gains.

Same PID controller, different actorNormalized reward of a Gaussian vs a diffusion policy, 5 seeds (both safe on BallCircle, HalfCheetahVel and CarCircle). Higher is better.
Gaussian PIDDiffusion PID025507510049.9164.36SwimmerVel28.8199.93HalfCheetahVel14.1869.90BallCircle37.8662.82CarCirclenormalized reward

Source: Table 3, page 12 of the paper.

Show the numbers
Gaussian PIDDiffusion PID
SwimmerVel49.9164.36
HalfCheetahVel28.8199.93
BallCircle14.1869.90
CarCircle37.8662.82

The method is also practical at run time: on an NVIDIA RTX 3080 GPU, the paper reports an average of 5.50 ms per action (roughly 182 Hz), with the PID controller adding nothing at inference because it is used only during training. Training took roughly 60 to 75 minutes per 100k training steps.

When the only safety signal is a learned prediction that arrives biased, late and noisy, it helps to treat the safety price as a control loop and tune it like one.

What it means, and what it does not

The broader lesson is a change of viewpoint. Rather than avoiding adaptive safety prices in the offline setting, as some recent methods do, PID-DiffRL keeps them and stabilises the update itself with standard tools from control engineering.

The paper is careful about the limits, and so should we be.

Within those limits, the evidence points one way: in these benchmarks, a better-designed feedback loop around an imperfect safety sensor kept every task under its cost budget while staying competitive on reward.

More stories from the lab

Want to be part of the lab? Write to us.