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] Fix bug in SingleAgentEnvRunner: Calling sample() would always force-reset the vector env (even if episodes were not completed in a previous call). #41168

Conversation

sven1977
Copy link
Contributor

@sven1977 sven1977 commented Nov 15, 2023

Fix bug in SingleAgentEnvRunner: Calling sample() repeatedly would always force-reset the vector env (even if episodes were not completed in a previous call).

Why are these changes needed?

Related issue number

Checks

  • I've signed off every commit(by using the -s flag, i.e., git commit -s) in this PR.
  • 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 added any new APIs to the API Reference. For example, if I added a
      method in Tune, I've added it in doc/source/tune/api/ under the
      corresponding .rst file.
  • 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 :(

Signed-off-by: sven1977 <svenmika1977@gmail.com>
Comment on lines 442 to 450
# TEST
#import pickle
#import torch
#import os
#with open("train_batch.pkl", "wb") as file:
# pickle.dump(train_batch, file)
#torch.save(self.workers.local_worker().policy_map["default_policy"].model.state_dict(), "model_weights.pth")
# END TEST

Copy link
Contributor

Choose a reason for hiding this comment

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

remove?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, will comb through changes and clean everything up before merging. Thanks for this catch!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Comment on lines 453 to 463
# TEST
#import pickle
#import torch
#import os
#from ray.rllib.utils.test_utils import check
#rw_path = "/Users/sven/ray_results/PPO_2023-11-15_13-28-16/PPO_CartPoleDebug_74001_00000_0_2023-11-15_13-28-16"
#with open(os.path.join(rw_path, "train_batch.pkl"), "rb") as file:
# rw_train_batch = pickle.load(file)
#rw_state_dict = torch.load(os.path.join(rw_path, "model_weights.pth"))
#self.workers.local_worker().module.load_state_dict(rw_state_dict)
# END TEST
Copy link
Contributor

Choose a reason for hiding this comment

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

remove?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Comment on lines 480 to 482
#check(train_batch["advantages"], rw_train_batch["default_policy"]["advantages"], rtol=0.000001)
#check(train_batch["vf_preds"], rw_train_batch["default_policy"]["vf_preds"])
#check(train_batch["value_targets"], rw_train_batch["default_policy"]["value_targets"])
Copy link
Contributor

Choose a reason for hiding this comment

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

remove?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Signed-off-by: sven1977 <svenmika1977@gmail.com>
@sven1977 sven1977 changed the title [RLlib] Fix bug in SingleAgentEnvRunner: Calling sample() repeatedly would always force-reset the vector env (even if episodes were not completed in a previous call). [RLlib] Fix bug in SingleAgentEnvRunner: Calling sample() would always force-reset the vector env (even if episodes were not completed in a previous call). Nov 16, 2023
@sven1977 sven1977 merged commit ed9588a into ray-project:master Nov 16, 2023
15 of 18 checks passed
ujjawal-khare pushed a commit to ujjawal-khare-27/ray that referenced this pull request Nov 29, 2023
…ays force-reset the vector env (even if episodes were not completed in a previous call). (ray-project#41168)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants