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

Multiprocessing support for off policy algorithms #439

Merged
merged 47 commits into from
Dec 1, 2021

Conversation

araffin
Copy link
Member

@araffin araffin commented May 17, 2021

Description

closes #179

Add support for multiprocessing, only HerReplayBuffer not supported (done in #654 ).

Motivation and Context

  • I have raised an issue to propose this change (required for new features and bug fixes)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (update in the documentation)

Checklist:

  • I've read the CONTRIBUTION guide (required)
  • I have updated the changelog accordingly (required).
  • My change requires a change to the documentation.
  • I have updated the tests accordingly (required for a bug fix or a new feature).
  • I have updated the documentation accordingly.
  • I have reformatted the code using make format (required)
  • I have checked the codestyle using make check-codestyle and make lint (required)
  • I have ensured make pytest and make type both pass. (required)
  • I have checked that the documentation builds using make doc (required)

Note: You can run most of the checks using make commit-checks.

Note: we are using a maximum length of 127 characters per line

@araffin araffin added the experimental Experimental Feature label May 23, 2021
@araffin araffin requested a review from hill-a November 4, 2021 13:31
@araffin
Copy link
Member Author

araffin commented Nov 4, 2021

@yonkshi @SonSang could you also take a look and review this PR?

@Miffyli
Copy link
Collaborator

Miffyli commented Nov 4, 2021

Would you have any performance metrics to share vs. single-threaded (agent performance, training time)? I will try to take a look before end of the week :)

@araffin
Copy link
Member Author

araffin commented Nov 5, 2021

so I've got something qualitative so you get the general idea of the pros/cons of multi envs.
This is SAC on Pendulum on cpu with (in order):

  • one env
  • two envs
  • four envs
  • height envs
  • four envs and gradient_steps=2 (instead of 1)

Sample efficiency:
Training_Episodic_Reward_steps

Wall clock time

Training_Episodic_Reward

more envs = less sample efficient and faster wall clock time but you can retrieve some sample efficiency by having more gradients steps , in that case you will lose some speed (especially in that experiment with my laptop on cpu only)

the slower the env, the bigger the gap with using one env only will be

tests/test_spaces.py Show resolved Hide resolved
docs/guide/examples.rst Show resolved Hide resolved
stable_baselines3/common/type_aliases.py Outdated Show resolved Hide resolved
stable_baselines3/common/off_policy_algorithm.py Outdated Show resolved Hide resolved
stable_baselines3/common/off_policy_algorithm.py Outdated Show resolved Hide resolved
@araffin araffin requested a review from Miffyli December 1, 2021 18:39
Copy link
Collaborator

@Miffyli Miffyli left a comment

Choose a reason for hiding this comment

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

LGTM but need to fix the typing thing :)

@araffin
Copy link
Member Author

araffin commented Dec 1, 2021

I reintroduced the next_obs = deepcopy(new_obs_) because it prevents many errors (and not only with dict observations)

@araffin araffin merged commit 507ed17 into master Dec 1, 2021
@araffin araffin deleted the feat/multienv-off-policy branch December 1, 2021 21:30
@christqoh christqoh mentioned this pull request Dec 17, 2021
5 tasks
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.

[Feature request] Adding multiprocessing support for off policy algorithms
2 participants