Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RLlib] Minor fixes (torch GPU bugs + some cleanup). #11609

Merged
merged 5 commits into from
Oct 27, 2020

Conversation

sven1977
Copy link
Contributor

@sven1977 sven1977 commented Oct 26, 2020

Minor fixes:

  • torch GPU bugs
  • some cleanup.
  • some test cases were deactivated (unintentionally?).
  • shortened some tests.
  • fix breaking test cases test_bc and test_marwil.py (due to json file w/ compressed obs not understood).

Why are these changes needed?

Related issue number

Checks

  • I've run scripts/format.sh to lint the changes in this PR.
  • I've included any doc changes needed for https://docs.ray.io/en/master/.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
  • Testing Strategy
    • Unit tests
    • Release tests
    • This PR is not tested :(

@@ -331,7 +332,8 @@ def compute_actions(
fetched = builder.get(to_fetch)

# Update our global timestep by the batch size.
self.global_timestep += fetched[0].shape[0]
self.global_timestep += len(obs_batch) if isinstance(obs_batch, list) \
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may be a tensor (eager tracing) or a list.

@@ -28,7 +28,7 @@ def test_multi_agent_pendulum(self):
"env": "multi_agent_pendulum",
"stop": {
"timesteps_total": 500000,
"episode_reward_mean": -300.0,
"episode_reward_mean": -400.0,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make some tests run a little faster.

@@ -187,39 +187,35 @@ def test_batch_ids(self):
def test_global_vars_update(self):
# Allow for Unittest run.
ray.init(num_cpus=5, ignore_reinit_error=True)
for fw in framework_iterator(frameworks=()):
for fw in framework_iterator(frameworks=("tf2", "tf")):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was completely deactivated! frameworks=empty

agent.stop()

def test_no_step_on_init(self):
register_env("fail", lambda _: FailOnStepEnv())
for fw in framework_iterator(frameworks=()):
for fw in framework_iterator():
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

@@ -80,7 +80,8 @@ def __init__(self,
behaviour_policy_logits=behaviour_logits,
target_policy_logits=target_logits,
actions=tf.unstack(actions, axis=2),
discounts=tf.cast(~dones, tf.float32) * discount,
discounts=tf.cast(~tf.cast(dones, tf.bool), tf.float32) *
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would fail if dones are floats (0.0 or 1.0).

if sess:
expected_logp = sess.run(expected_logp)
elif fw == "torch":
expected_logp = expected_logp.detach().cpu().numpy()
adv = adv.detach().cpu().numpy()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

failed on GPU

@@ -150,6 +150,7 @@ def _from_json(batch: str) -> SampleBatchType:

if data_type == "SampleBatch":
for k, v in data.items():
print("Trying to unpack {}: {}".format(k, v))#TODO
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this prior to merging.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course, trying to catch the failing test_marwil/bc.py problem, which is related to a different compression format on the observation and will go into a different PR.

@ericl ericl added the @author-action-required The PR author is responsible for the next step. Remove tag to send back to the reviewer. label Oct 26, 2020
@sven1977 sven1977 merged commit d9f1874 into ray-project:master Oct 27, 2020
cathrinS pushed a commit to mariodoebler/ray that referenced this pull request Nov 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@author-action-required The PR author is responsible for the next step. Remove tag to send back to the reviewer.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants