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

improve gym speedup #210

Merged
merged 16 commits into from
Nov 1, 2022
Merged

improve gym speedup #210

merged 16 commits into from
Nov 1, 2022

Conversation

wangsiping97
Copy link
Contributor

@wangsiping97 wangsiping97 commented Oct 27, 2022

Description

Improved speedup in gym by:

  • added max_episode_steps into the base config in c++
  • moved max_episode_steps from c++ default config per env into registration.py
  • moved trunc computation logics from python to c++

This PR also includes a big refactor of calling test env. We use make_dm / make_gym instead of envpool_cls(spec_cls(spec_cls.gen_config(...))).

Motivation and Context

The computation of trunc in gym_envpool.py is shown as a bottleneck by py-spy.

After fix, envpool's speedup in gym improved from ~1.0x to ~1.3x (using make_gym instead of make_dm for the test below):

Namespace(domain='cheetah', seed=0, task='run', total_step=200000)
100%|███████████████████████████████████████████████████████████████████████████████████████████████| 200000/200000 [00:17<00:00, 11301.86it/s]
FPS(gym) = 11300.15
100%|███████████████████████████████████████████████████████████████████████████████████████████████| 200000/200000 [00:13<00:00, 14408.97it/s]
FPS(envpool) = 14408.43
EnvPool Speedup: 1.28x
  • I have raised an issue to propose this change (required for new features and bug fixes)

Types of changes

What types of changes does your code introduce? Put an x in all the boxes that apply:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds core functionality)
  • New environment (non-breaking change which adds 3rd-party environment)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (update in the documentation)
  • Example (update in the folder of example)

Implemented Tasks

  • moved max_episode_steps from c++ default config per env into registration.py
  • moved trunc computation logics from python to c++
  • added configuration for max_episode_steps in test files

Checklist

Go over all the following points, and put an x in all the boxes that apply.
If you are unsure about any of these, don't hesitate to ask. We are here to help!

  • I have read the CONTRIBUTION guide (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 code using make lint (required)
  • I have ensured make bazel-test pass. (required)

@Trinkle23897
Copy link
Collaborator

@wangsiping97 please do the rest the same as my commit

@Trinkle23897
Copy link
Collaborator

TODO:

  • no_type_check
  • docs update

@Trinkle23897 Trinkle23897 merged commit 29d8412 into sail-sg:main Nov 1, 2022
@Trinkle23897 Trinkle23897 linked an issue Nov 1, 2022 that may be closed by this pull request
3 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.

[BUG] Cannot speedup DMControl suite.
2 participants