Given a set of trajectories demonstrating the execution of a task safely in a constrained MDP with observable rewards but with unknown constraints and non-observable costs, we aim to find a policy that maximizes the likelihood of demonstrated trajectories trading the balance between being conservative and increasing significantly the likelihood of high-rewarding trajectories but with potentially unsafe steps. Having these objectives, we aim towards learning a policy that maximizes the probability of the most promising trajectories with respect to the demonstrations. In so doing, we formulate the ``promise" of individual state-action pairs in terms of Q values, which depend on task-specific rewards as well as on the assessment of states' safety, mixing expectations in terms of rewards and safety. This entails a safe Q-learning perspective of the inverse learning problem under constraints: The devised Safe Q Inverse Constrained Reinforcement Learning (SafeQIL) algorithm is compared to state-of-the art inverse constraint reinforcement learning algorithms to a set of challenging benchmark tasks, showing its merits.
Table 5. Ablation results for key SafeQIL’s variations.
Appendix figures & tables26 assets
Supplementary material from the paper’s appendix.
Appendix
Benchmark
Algorithm
Mean Reward
Mean Cost
Cost Drop ( ΔC )
Reward Drop ( ΔR )
Ratio ( ρ )
SafetyPointGoal1-v0 (SAC: R 27.47, C 49.15)
SafeQIL
5.27
34.22
30.4%
80.8%
0.38
ICRL 2
23.21
62.60
-27.4%
15.5%
N/A (Unsafe)
ICRL 7
-0.50
42.80
12.9%
101.8%
0.13
VICRL
21.87
62.97
-28.1%
20.4%
N/A (Unsafe)
SAC-GAIL
7.17
44.80
8.9%
73.9%
0.12
SafetyPointCircle2-v0 (SAC: R 58.81, C 392.20)
SafeQIL
27.06
29.28
92.5%
54.0%
1.71
Appendix
Table 6. Standard Trade-off Analysis (Mean Values Only). The Ratio ρ indicates % Cost Drop per 1% Reward Drop.
Benchmark
Algorithm
Pess. Reward ( R~ )
Pess. Cost ( C~ )
Robust ΔC~
Robust ΔR~
Ratio ( ρ )
SafetyPointGoal1-v0 (SAC Pess: R 27.26, C 51.36)
SafeQIL
3.42
36.93
28.1%
87.5%
0.32
ICRL 2
21.93
72.47
-41.1%
19.6%
N/A (Unsafe)
ICRL 7
-5.43
78.23
-52.3%
119.9%
N/A (Unsafe)
VICRL
20.67
73.78
-43.6%
24.2%
N/A (Unsafe)
SAC-GAIL
5.52
63.40
-23.4%
79.7%
N/A (Unsafe)
SafetyPointCircle2-v0 (SAC Pess: R 58.11, C 396.58)
SafeQIL
22.96
37.69
90.5%
60.5%
1.50
Appendix
Table 7. Robust Trade-off Analysis (Mean ± Std). Pessimistic metrics penalize high variance in cost and reward.
Figure 3. Learning curves for the SafetyPointCircle2-v0 benchmark.
Figure 4. Learning curves for the SafetyCarButton1-v0 benchmark.
Figure 5. Learning curves for the SafetyCarPush2-v0 benchmark.
Algorithm
Reward ↑
Cost ↓
Original
5.27 ± 1.85
34.22 ± 2.71
w/o cosine similarity
3.74 ± 2.52
30.25 ± 19.10
w/o max term
-10.62 ± 7.81
15.47 ± 8.67
w/o constraint term
4.34 ± 4.41
29.02 ± 14.03
w/o OOD term
1.07 ± 0.91
44.99 ± 4.95
w/o demonstrations term
-3.71 ± 1.00
8.41 ± 3.76
Appendix
Table 8. Complete ablation study evaluation results for SafeQIL.
Algorithm
Reward ↑
Cost ↓
1x Dataset
SafeQIL
5.27 ± 1.85
34.22 ± 2.71
ICRL 2
23.21 ± 1.28
62.60 ± 9.87
ICRL 7
-0.50 ± 4.93
42.80 ± 35.43
VICRL
21.87 ± 1.20
62.97 ± 10.81
SAC-GAIL
7.17 ± 1.65
44.80 ± 18.60
Appendix
Table 9. SafetyPointGoal1-v0: Comparative results of Dataset Size Ablation.
Algorithm
Reward ↑
Cost ↓
1x Dataset
SafeQIL
-0.62 ± 0.65
57.20 ± 30.02
ICRL 2
0.00 ± 1.73
203.10 ± 37.24
ICRL 7
1.15 ± 0.49
178.81 ± 60.69
VICRL
-9.05 ± 8.58
55.80 ± 71.45
SAC-GAIL
0.76 ± 0.92
87.97 ± 10.57
Appendix
Table 10. SafetyCarPush2-v0: Comparative results of Dataset Size Ablation.
Dataset Size
Algorithm
Mean Reward
Mean Cost
Cost Drop ( ΔC )
Reward Drop ( ΔR )
Ratio ( ρ )
1x Dataset (SAC: R 27.47, C 49.15)
SafeQIL
5.27
34.22
30.4%
80.8%
0.38
ICRL 2
23.21
62.60
-27.4%
15.5%
N/A (Unsafe)
ICRL 7
-0.50
42.80
12.9%
101.8%
0.13
VICRL
21.87
62.97
-28.1%
20.4%
N/A (Unsafe)
SAC-GAIL
7.17
44.80
8.9%
73.9%
0.12
2x Dataset (SAC: R 27.47, C 49.15)
SafeQIL
3.17
29.50
40.0%
88.5%
0.45
Appendix
Table 11. SafetyPointGoal1-v0: Standard Trade-off Analysis (Dataset Size Ablation). Calculated using Mean Values Only. The Ratio ρ indicates % Cost Drop per 1% Reward Drop.
Dataset Size
Algorithm
Pess. Reward ( R~ )
Pess. Cost ( C~ )
Robust ΔC~
Robust ΔR~
Ratio ( ρ )
1x Dataset (SAC Pess: R 27.26, C 51.36)
SafeQIL
3.42
36.93
28.1%
87.5%
0.32
ICRL 2
21.93
72.47
-41.1%
19.6%
N/A (Unsafe)
ICRL 7
-5.43
78.23
-52.3%
119.9%
N/A (Unsafe)
VICRL
20.67
73.78
-43.6%
24.2%
N/A (Unsafe)
SAC-GAIL
5.52
63.40
-23.4%
79.7%
N/A (Unsafe)
2x Dataset (SAC Pess: R 27.26, C 51.36)
SafeQIL
2.22
39.45
23.2%
91.9%
0.25
Appendix
Table 12. SafetyPointGoal1-v0: Robust Trade-off Analysis (Dataset Size Ablation). Calculated using worst-case bounds (Mean ± Std). Pessimistic metrics penalize high variance in cost and reward.
Dataset Size
Algorithm
Mean Reward
Mean Cost
Cost Drop ( ΔC )
Reward Drop ( ΔR )
Ratio ( ρ )
1x Dataset (SAC: R 1.50, C 245.36)
SafeQIL
-0.62
57.20
76.7%
141.3%
0.54
ICRL 2
0.00
203.10
17.2%
100.0%
0.17
ICRL 7
1.15
178.81
27.1%
23.3%
1.16
VICRL
-9.05
55.80
77.3%
703.3%
0.11
SAC-GAIL
0.76
87.97
64.1%
49.3%
1.30
2x Dataset (SAC: R 1.50, C 245.36)
SafeQIL
-3.38
58.10
76.3%
325.3%
0.23
Appendix
Table 13. SafetyCarPush2-v0: Standard Trade-off Analysis (Dataset Size Ablation). Calculated using Mean Values Only. The Ratio ρ indicates % Cost Drop per 1% Reward Drop.
Dataset Size
Algorithm
Pess. Reward ( R~ )
Pess. Cost ( C~ )
Robust ΔC~
Robust ΔR~
Ratio ( ρ )
1x Dataset (SAC Pess: R 1.49, C 273.88)
SafeQIL
-1.27
87.22
68.2%
185.2%
0.37
ICRL 2
-1.73
240.34
12.2%
216.1%
0.06
ICRL 7
0.66
239.50
12.6%
55.7%
0.23
VICRL
-17.63
127.25
53.5%
1283.2%
0.04
SAC-GAIL
-0.16
98.54
64.0%
110.7%
0.58
2x Dataset (SAC Pess: R 1.49, C 273.88)
SafeQIL
-6.35
75.96
72.3%
526.2%
0.14
Appendix
Table 14. SafetyCarPush2-v0: Robust Trade-off Analysis (Dataset Size Ablation). Calculated using worst-case bounds (Mean ± Std). Pessimistic metrics penalize high variance in cost and reward.
This paper addresses the problem of safe offline reinforcement learning, which involves training a policy to satisfy safety constraints using an offline dataset. This problem is inherently challenging as it requires balancing three highly interconnected and competing objectives: satisfying safety constraints, maximizing rewards, and adhering to the behavior regularization imposed by the offline dataset. To tackle this trilogy challenge, we propose Q-learning Penalized Transformer policy (QPT), a training--inference consistent framework that bridges conditional sequence modeling with constraint-aware value estimation. QPT trains a Transformer policy that generates actions conditioned on trajectory context and target return/cost, retaining strong behavior regularization. To inject explicit safety semantics during learning, we augment sequence-model training with a Q-shaped penalty using learned reward and cost Q-functions to favor high return under low constraint violation. At inference, the same Q-functions enforce the cost threshold and choose the highest-reward feasible action, closing the loop between training and deployment. We provide a principled analysis under stylized near-deterministic CMDPs, characterizing how Q-penalized conditional generation improve safety and performance. Empirically, QPT consistently outperforms strong safe offline RL baselines across 38 tasks on the DSRL benchmark, and exhibits robust zero-shot adaptation to different constraint thresholds.
Shengchao Hu, Peng Wang, Jifeng Hu +5
Shanghai Jiao Tong University, China · Shenzhen Campus of Sun Yat-sen University, China · Jilin University, China +1
Ensuring safety during reinforcement learning (RL) training is critical in real-world applications where unsafe exploration can lead to devastating outcomes. While most safe RL methods mitigate risk through constraints or penalization, they still allow exploration of unsafe states during training. In this work, we adopt a stricter safety requirement that eliminates unsafe state visitation during training. To achieve this goal, we propose a Q-learning-based safe RL framework that leverages a behavior policy supported on a safe set. Under the assumption that the induced trajectories remain within the safe set, this policy enables sufficient exploration within the safe region without requiring near-optimality. We adopt a two-stage framework in which the Q-function and policy are trained separately. Specifically, we introduce a KL-regularized Bellman target that constrains the Q-function to remain close to the behavior policy. We then derive the policy induced from the trained Q-values and propose a parametric policy extraction method to approximate the optimal policy. Our approach provides a unified framework that can be adapted to different action spaces and types of behavior policies. Experimental results demonstrate that the proposed method achieves stable learning and well-calibrated value estimates and yields safer behavior with comparable or better performance than existing baselines.
Yeeun Lim, Narim Jeong, Donghwan Lee
HD Korea Shipbuilding & Offshore Engineering · Department of Electrical Engineering, KAIST, Daejeon, South Korea
When safety is formulated as a limit of cumulative cost, safe reinforcement learning (RL) aims to learn policies that maximize return subject to the cost constraint in data collection and deployment. Off-policy safe RL methods, although offering high sample efficiency, suffer from constraint violations due to cost-agnostic exploration and estimation bias in cumulative cost. To address this issue, we propose Constrained Optimistic eXploration Q-learning (COX-Q), an off-policy safe RL algorithm that integrates cost-bounded online exploration and conservative offline distributional value learning. First, we introduce a novel cost-constrained optimistic exploration strategy that resolves gradient conflicts between reward and cost in the action space and adaptively adjusts the trust region to control the training cost. Second, we adopt truncated quantile critics to stabilize the cost value learning. Quantile critics also quantify epistemic uncertainty to guide exploration. Experiments on safe velocity, safe navigation, and autonomous driving tasks demonstrate that COX-Q achieves high sample efficiency, competitive test safety performance, and controlled data collection cost. The results highlight COX-Q as a promising RL method for safety-critical applications.
Guopeng Li, Matthijs T. J. Spaan, Julian F. P. Kooij
Faculty of Electrical Engineering, Mathematics and Computer Science, Delft University of Technology, Delft, the Netherlands