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

info API compatibility with Gym #164

Open
vwxyzjn opened this issue Feb 16, 2022 · 3 comments
Open

info API compatibility with Gym #164

vwxyzjn opened this issue Feb 16, 2022 · 3 comments

Comments

@vwxyzjn
Copy link
Contributor

vwxyzjn commented Feb 16, 2022

What is the problem

Right now Brax provides a slightly different Gym vector API in the info field.

Gym's info dict is returned per environment, like if I have 5 envs, then the dict could look like
[{}, {}, {}, {}, {["truncated": True}

In Brax, it looks like

{"truncated":[False, False, False, False, True]}

This makes it difficult to develop wrappers compatible with both gym and brax. See #89.

As a result, gym wrapper + jumpy with brax does not work out of the box: see code

Pros and Cons

Brax's approach feels more ergonomic for high-throughput envs (note that envpool also adopts brax approach in the info field), whereas Gym's approach is maybe more efficient for "sparse" info keys that don't appear often (I could be wrong with this).

Not sure what's the best way to do this. CC @RedTachyon @jkterry1 @lebrice

@erikfrey
Copy link
Collaborator

The Gym wrapper is explicitly meant for correct interop with Gym users - Brax is unopinionated and happy to support whatever is the expected output here. Just let us know what change you would like and we'll make it.

@erikfrey
Copy link
Collaborator

Actually taking a second read through this issue, I am concerned this would tank performance when stepping through vectorized environments. Turning a single dict with 2048-length arrays into 2048 dicts with 1-length arrays could be expensive, particularly if it's done every step.

You could try it, but I suspect it will slow things down significantly.

@vwxyzjn
Copy link
Contributor Author

vwxyzjn commented Feb 26, 2022

Turning a single dict with 2048-length arrays into 2048 dicts with 1-length arrays could be expensive, particularly if it's done every step.

That's my thought on this, too. Hence the reason maybe gym should reconsider how the info API is designed. The current design is not friendly to these types of 2048-length arrays.

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

No branches or pull requests

2 participants