-
Notifications
You must be signed in to change notification settings - Fork 1.2k
code refactor for venv #179
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
Conversation
I would add that in m'y opinion it is usually more common to deal with such dynamic environment than a static one. For example in my case I have to deal with dynamic environments, never static. It comes from the way the state is integrated over time. Some state requires to refine the computation to guarantee the accuracy, while for others it is not necessary. |
Is it ready for review ? I didn't spent much time thinking to a better way to handle methods such as |
Yes, of course! And I have another concern: can we reduce the async overhead as much as possible? I tested with wait_num == env_num for both sync and async mode (use test_drqn.py), and the result shows that the speed of async is 80% of sync. This could be the future work. |
Agree. Only toy environments are static. Almost all realistic environments are dynamic. |
I'll have a look later today |
As I said, I should be clear from the documentation that the vector env are not usual pool, a sense that it does not really handle parallelism directly. Being asynchronous or not is to the resort of the sole worker and at its discretion, with no explicit mechanism for the pool to know this information in advance (hence the unusual wait mechanism). |
I don't agree. The workers have |
No it is not. It requires the user to use a worker that support async behavior. It is not asynchronous by itself.
Are you kidding me ? Show me a single well-known library using the same "calling static method from workers" strategy to implement |
I admit the current implementation requires the hack of calling static method from workers. To remove the hack, each worker should implement a The |
I agree it is tricky to implement and I'm fine with the current implementation. It could be refactor later if necessary, or if we have time for that. |
- Refacor code to remove duplicate code - Enable async simulation for all vector envs - Remove `collector.close` and rename `VectorEnv` to `DummyVectorEnv` The abstraction of vector env changed. Prior to this pr, each vector env is almost independent. After this pr, each env is wrapped into a worker, and vector envs differ with their worker type. In fact, users can just use `BaseVectorEnv` with different workers, I keep `SubprocVectorEnv`, `ShmemVectorEnv` for backward compatibility. Co-authored-by: n+e <463003665@qq.com> Co-authored-by: magicly <magicly007@gmail.com>
Refacor code to remove duplicate code
Enable async simulation for all vector envs
Remove
collector.close
and renameVectorEnv
toDummyVectorEnv
The abstraction of vector env changed.
Prior to this pr, each vector env is almost independent.
After this pr, each env is wrapped into a worker, and vector envs differ with their worker type. In fact, users can just use
BaseVectorEnv
with different workers, I keepSubprocVectorEnv
,ShmemVectorEnv
for backward compatibility.