Skip to content

[rllib] TorchDiagGaussian doesn’t handle multiple actions correctly. #7397

Closed

Description

@soundway

This is not a contribution.

Ray version: 0.8.2
Python version: 3.6.8
Pytorch version: 1.4
OS: Ubuntu 18.04 Docker

TorchDiagGaussian doesn’t handle multiple actions correctly. As a result, training PPO with Pytorch will crash when the action space has more than 1 action. Here’s minimal reproduction script:

import gym
from gym.spaces import Box
from ray import tune

class ContinuousEnv(gym.Env):
   def __init__(self, config):
       self.action_space = Box(0.0, 1.0, shape=(2,))
       self.observation_space = Box(0.0, 1.0, shape=(1, ))

   def reset(self):
       return [0.0]

   def step(self, action):
       return [0.0], 1.0, False, {}

tune.run(
   "PPO",
   config={"env": ContinuousEnv, "use_pytorch": True, "num_workers": 1})

Activity

  1. added
    bug
    on Mar 2, 2020
  2. self-assigned this
    on Mar 2, 2020
  3. sven1977 commented on Mar 2, 2020

    @sven1977
    Contributor

    Thanks for filing this. Taking a look ...

  4. sven1977 commented on Mar 2, 2020

    @sven1977
    Contributor

    Please try this PR for a fix. This will go into master within the next few days.
    #7398

  5. soundway commented on Mar 4, 2020

    @soundway
    Author

    This works. Thanks for the quick fix!

  6. omri-axon-vision commented on Mar 30, 2020

    @omri-axon-vision

    Had the same problem, so i updated to the 0.8.3 version. Now the bug happens in the GAE calculation:
    File "/home/spider-sense01/PycharmProjects/multi-agent-emergence-environments/.venv/lib/python3.6/site-packages/ray/rllib/agents/ppo/ppo_torch_policy.py", line 105, in init
    vf_loss_coeff * vf_loss - entropy_coeff * curr_entropy)
    RuntimeError: The size of tensor a (512) must match the size of tensor b (2) at non-singleton dimension 1

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