这是indexloc提供的服务,不要输入任何密码
Skip to content

Asynchronous sampling vector environment #134

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

Merged
merged 15 commits into from
Jul 26, 2020

Conversation

duburcqa
Copy link
Collaborator

Fix #103

@duburcqa
Copy link
Collaborator Author

ping @youkaichao

@youkaichao youkaichao self-requested a review July 13, 2020 14:19
@youkaichao
Copy link
Collaborator

Roger that. Keep following this pr.

@Trinkle23897 Trinkle23897 linked an issue Jul 14, 2020 that may be closed by this pull request
8 tasks
@Trinkle23897 Trinkle23897 changed the base branch from dev to test July 20, 2020 07:48
@Trinkle23897 Trinkle23897 changed the base branch from test to dev July 20, 2020 07:49
@duburcqa
Copy link
Collaborator Author

duburcqa commented Jul 22, 2020

@youkaichao If you want to help me on that, do not hesitate. I'm quite busy right now. I can find time for reviews, but not to code something new, for at least the next 2 weeks.

@youkaichao
Copy link
Collaborator

Ok, I'll take this pr.

@youkaichao
Copy link
Collaborator

@duburcqa please invite me to your repo so that I can work on your branch.

@duburcqa duburcqa removed the request for review from youkaichao July 22, 2020 07:29
@youkaichao
Copy link
Collaborator

The head is now at b99f484 . I think we should only modify Collector.collect.

@duburcqa
Copy link
Collaborator Author

duburcqa commented Jul 22, 2020

The head is now at b99f484 . I think we should only modify Collector.collect.

Yes I think so, but are you sure AsyncVectorEnv is not useful ?

@youkaichao
Copy link
Collaborator

are you sure AsyncVectorEnv is not useful ?

Emmm, my bad. After a second thought, I thin it is useful.

@duburcqa
Copy link
Collaborator Author

Emmm, my bad. After a second thought, I thin it is useful.

Yes, I think both are needed.

@youkaichao
Copy link
Collaborator

After #157 , this should be done today ✌️

@duburcqa
Copy link
Collaborator Author

Nice !

@codecov-commenter
Copy link

codecov-commenter commented Jul 23, 2020

Codecov Report

Merging #134 into dev will decrease coverage by 0.21%.
The diff coverage is 81.13%.

Impacted file tree graph

@@            Coverage Diff             @@
##              dev     #134      +/-   ##
==========================================
- Coverage   88.94%   88.72%   -0.22%     
==========================================
  Files          35       35              
  Lines        2098     2147      +49     
==========================================
+ Hits         1866     1905      +39     
- Misses        232      242      +10     
Flag Coverage Δ
#unittests 88.72% <81.13%> (-0.22%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
tianshou/env/vecenv.py 71.17% <80.76%> (+2.75%) ⬆️
tianshou/env/__init__.py 100.00% <100.00%> (ø)
tianshou/data/collector.py 92.64% <0.00%> (-0.06%) ⬇️
tianshou/data/buffer.py 92.43% <0.00%> (-0.05%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bfeffe1...ecec577. Read the comment docs.

@youkaichao
Copy link
Collaborator

youkaichao commented Jul 25, 2020

@Trinkle23897 @duburcqa should be ok now, please have a look when you are available :)

@duburcqa duburcqa changed the title WIP: Asynchronous sampling vector environment Asynchronous sampling vector environment Jul 25, 2020
@duburcqa
Copy link
Collaborator Author

I approve this PR (but I cannot actually approve it since I opened it 😅).

youkaichao
youkaichao previously approved these changes Jul 25, 2020
simulation is disabled; else, ``1 <= wait_num <= env_num``.
"""
super().__init__(env_fns)
self.wait_num = wait_num or len(env_fns)
Copy link
Collaborator

@Trinkle23897 Trinkle23897 Jul 26, 2020

Choose a reason for hiding this comment

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

So if wait_num is None, this AsyncVenv is equal to the original SubprocVenv. Why not add this directly into the SubprocVenv?
In other words, the sync mode is a special case of async mode, thus we can unify the collector to use async mode for all venv instead of sync mode, and implement async in all venv.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe we can create another issue and pr

Copy link
Collaborator

Choose a reason for hiding this comment

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

Good point, and this can go further: why not just make it an ability of BaseVecEnv so that async simulation directly works for any vec envs? This seems worthwhile, but is a breaking change. Maybe we need to abstract Worker and change the interface of vec env.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Having a unified VecEnv would be awesome and it may greatly ease the implementation of other classes/methods such as Collector.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In other words, the sync mode is a special case of async mode, thus we can unify the collector to use async mode for all venv instead of sync mode, and implement async in all venv.

That's what I was thinking x)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@Trinkle23897 But I think adding this feature in a dedicated class as we did is a good start I think, since it may be break changing as said.

@Trinkle23897 Trinkle23897 merged commit e024afa into thu-ml:dev Jul 26, 2020
@Trinkle23897 Trinkle23897 mentioned this pull request Jul 26, 2020
8 tasks
BFAnas pushed a commit to BFAnas/tianshou that referenced this pull request May 5, 2024
Fix thu-ml#103

Co-authored-by: youkaichao <youkaichao@126.com>
Co-authored-by: Trinkle23897 <463003665@qq.com>
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.

Async Sampling
4 participants