Safety Aware Reinforcement Learning (SARL)

Santiago Miret, Somdeb Majumdar, Carroll Wainwright

TL;DR

Safety Aware Reinforcement Learning (SARL) introduces a framework that decouples task performance from safety by using a "virtual safe agent" to guide a primary task agent. By regularizing the task agent's action probabilities against a task-independent safety policy, the authors achieve robust safety performance that generalizes across different objectives and dynamic environments without needing task-specific safety tuning.

What Problem Does This Paper Address?

As Reinforcement Learning (RL) moves from games to real-world applications like robotics and microgrid management, "side effects"—unintended and often irreversible changes to the environment—become a major hurdle.

Traditional approaches usually bake safety into the reward function (e.g., giving a negative reward for breaking something). However, this has two major drawbacks:

  1. Task Dependency: A safety penalty designed for one task might not work for another, even in the same environment.
  2. Complexity: In dynamic environments, it is difficult for an agent to distinguish between changes it caused (side effects) and changes that happened naturally.

The authors aim to create a portable and task-independent notion of safety that can modulate different policies within the same environment dynamics.

Methods

The core of the paper is the SARL framework, which utilizes two agents:

  • Task Agent ($A$): Learns to maximize the primary reward (e.g., completing a goal).
  • Virtual Safe Agent ($Z$): Learns a policy focused purely on minimizing environmental impact, independent of the primary task.

Instead of just adding a penalty to the reward, SARL uses Distributional Regularization. The task agent is trained with a loss function that includes a distance metric between its action probabilities and those of the safe agent.

Figure 2: A co-training framework for safety aware RL training. The task agent, A(θ), determines the action taken in the environment and the resulting trajectories. The virtual safe agent, Z(ψ), receives the same state as A(θ) and makes a suggestion for a safe action given the state. The distance between the action probabilities of the A(θ) and Z(ψ) is captured in the Distribution Loss Ldist(θ, ψ). Z(ψ) learns how to maximize the safety objective on its own set of environments in parallel to A(θ).

The authors experimented with two primary distance metrics for this regularization:

  • Jensen-Shannon (JS) Distance: A bounded, symmetric version of the KL divergence.
  • Wasserstein Distance (WD): Specifically a dual formulation based on behavioral embeddings, which is often better suited for low-dimensional manifolds.

Datasets

The researchers evaluated their framework using the SafeLife Suite, a benchmark based on Conway’s Game of Life. This environment is particularly challenging because it features complex, emergent dynamics.

Figure 1: A simple level of the SafeLife environment containing an agent ( ), a spawner ( ), crates ( ), and cells of life. The agent’s goal is to remove unwanted red cells (prune task) and to create new patterns of life in the blue squares (append task). Once the agent has satisfactorily completed its goals it can leave via the level exit ( ). Note that all level boundaries wrap; they have toroidal topology.

They tested four specific task configurations:

  1. Prune-Still: Removing unwanted cells in a static environment.
  2. Append-Still: Creating new patterns in a static environment.
  3. Prune-Dynamic: Removing cells where the environment itself is constantly changing.
  4. Append-Dynamic: Creating patterns in a constantly changing environment.

Key Insights and Ideas

  • Safety as a Policy, Not a Scalar: By treating safety as a separate agent's policy rather than just a number in a reward function, the framework captures the behavior of being safe.
  • Zero-Shot Portability: A safe agent trained on a simple task (like "Prune-Still") can be "plugged in" to modulate a completely different, more complex task (like "Append-Dynamic") without any further safety training. This suggests that "safety" is a property of the environment dynamics that can be abstracted away from specific goals.
  • Robustness in Chaos: In dynamic environments, standard reward-penalty baselines often struggle to solve the task because the safety penalties become too noisy or restrictive. SARL's distributional approach allows the agent to learn the task effectively while maintaining a low side-effect profile.

Key Results

The authors compared SARL against a "reward-penalty" baseline where impact penalties are subtracted directly from the task reward.

  • Performance Parity: In static environments, SARL matched or slightly outperformed the baseline in both task completion (episode length) and safety (side-effect score).
  • Dynamic Superiority: In the "Prune-Dynamic" task, the baseline agent often failed to solve the task entirely (acting "too safe" by doing nothing). SARL agents successfully solved the task while keeping side effects low.
  • Generalization: The "Zero-Shot" SARL runs—where a safe agent from one task was used for a different task—performed nearly as well as agents where the safe agent was trained from scratch for that specific task.
Figure 3: Length Champion for SafeLife Suite of 1. prune-still (a-c), 2. append-still (d-f), 3. prune- dynamic (g-i), 4. append-dynamic (j-l) tasks evaluated for 100 testing environments every 100,000 steps on Episode Length (left column) where shorter is better, Performance Ratio (middle column) where higher is better, and Episodic Side Effect (right column) where lower is better

Limitations and Future Work

  • Discrete Action Spaces: The current work focuses exclusively on discrete actions. Extending this to continuous control (like robotics) will require new distance metrics and architectural adjustments.
  • Hyperparameter Sensitivity: The regularization parameter $\beta$ (which controls the trade-off between task and safety) requires careful tuning. The authors suggest that future work should focus on finding "Pareto optimal frontiers" to better navigate this trade-off.
  • Information Channels: The authors note that their current distance metrics might not capture all the "information richness" available in complex environments and suggest exploring multi-objective optimization techniques.

Summary updated

BibTeX
@misc{miret2020safety,
  author = {Santiago Miret and Somdeb Majumdar and Carroll Wainwright},
  title = {{Safety Aware Reinforcement Learning (SARL)}},
  year = {2020},
  eprint = {2010.02846},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2010.02846},
}
Figure