Skip to content

[Bug Report] SB3 wrapper's unbounded action space fallback breaks off-policy algorithms (SAC) #5080

Closed

Description

@e-ndorfin

Describe the bug

Sb3VecEnvWrapper clamps unbounded action spaces to [-100, 100] (source). This works fine for on-policy algorithms like PPO (which sample from an unbounded Gaussian and ignore bounds), but breaks off-policy algorithms like SAC.

SAC squashes actions through tanh() then rescales to the full [low, high] range via unscale_action(). With [-100, 100] bounds, the initial action distribution is spread across the entire range, while the useful range is typically around [-1, 1]. This causes reward divergence or collapse on every environment tested.

Reference: https://araffin.github.io/post/sac-massive-sim/

Steps to reproduce

Train SAC on any environment with unbounded action spaces (which includes all ManagerBasedRLEnv environments and any DirectRLEnv using integer action_space configs):

import gymnasium as gym
from stable_baselines3 import SAC
from isaaclab_rl.sb3 import Sb3VecEnvWrapper

env = gym.make("Isaac-Ant-v0", cfg=env_cfg)
env = Sb3VecEnvWrapper(env)
# env.action_space is now Box(-100, 100)

agent = SAC("MlpPolicy", env)
agent.learn(total_timesteps=1_000_000)

Results across 3 environments (SAC, 1M steps, 64 envs):

Env [-100, 100] (current) [-1, 1] (fix)
Isaac-Ant-v0 -1,786 -1.5
Isaac-Humanoid-v0 -7.87 trillion (diverged) +1.92
Isaac-Cartpole-v0 -1.071 4.341

Ant mean reward graph:
Image

Humanoid mean reward graph:
Image

Cartpole mean reward graph:
Image

System Info

  • Commit: 8d327dfa
  • Isaac Sim Version: 5.1.0
  • OS: Ubuntu 24.04.4 LTS
  • GPU: NVIDIA RTX PRO 6000 Blackwell
  • CUDA: 13.1
  • GPU Driver: 590.48.01

Additional context

The root cause is in Sb3VecEnvWrapper.__init__():

action_space = self.unwrapped.single_action_space
if isinstance(action_space, gym.spaces.Box) and not action_space.is_bounded("both"):
    action_space = gym.spaces.Box(low=-100, high=100, shape=action_space.shape)

Additionally, ManagerBasedRLEnv always creates unbounded action spaces (low=-np.inf, high=np.inf), so this code path is hit by the majority of environments.

Checklist

  • I have checked that there is no similar issue in the repo (required)
  • I have checked that the issue is not in running Isaac Sim itself and is related to the repo

Acceptance Criteria

  • SAC can train successfully on environments with unbounded action spaces without manual intervention

Activity

  1. RandomOakForest commented on Mar 23, 2026

    @RandomOakForest
    Collaborator

    Thank you for posting this. Would it be possible to try this on Isaac Sim 5.1 or later? That would give us a set up we could use to reproduce this issue if it persists. Thank you.

  2. added
    question
    on Mar 23, 2026
  3. e-ndorfin commented on Mar 24, 2026

    @e-ndorfin
    Author

    Apologies, @RandomOakForest my initial statement was mis-stated, and this training was done on IsaacSim 5.1.0, IsaacLab 2.3.2. I have edited the original issue.

  4. RandomOakForest commented on Apr 3, 2026

    @RandomOakForest
    Collaborator

    Thank you for the correction and adding the PR. The team will review it.

  5. added
    bug
    and removed
    question
    on Apr 3, 2026
  6. added a commit that references this issue on Sep 20, 2026
    24f7b48
  7. StafaH commented on Sep 20, 2026

    @StafaH
    Collaborator

    Resolved by #7910.

  8. added a commit that references this issue on Sep 20, 2026
    e5a1779
  9. araffin commented on Nov 6, 2026

    @araffin
    Contributor

    I think #7910 might have broken training SB3 PPO policy (at least for locomotion envs). If you read the blog post, the issue is for SAC and other algorithm using a tanh to rescale the output.

    However setting the action space to [-1, 1] breaks the performance for PPO (if I recall my experiments when I wrote the blog post). For SAC, it is a better default than the large action space but not optimal (optimal would be properly defining action bounds per task and maybe retuning the reward weights).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions