Comments (3)
@sagebei sorry for the late reply, I sometimes get lost in GitHub notifications. You're right that you can in principle have race conditions there. and yes, in practice you will have to take care of that (there are different ways of ensuring that, acquiring a lock is one of them). the worst thing that can happen above is that some updates simply get lost.
from learning_ray.
@maxpumperla Thank you very much for your reply! I closed the issue because I found there is no problem in the code. My understanding (which might not be correct) is that although the update_policy_task
is invoked by num_episodes
times in the for-loop and runs in parallel, the update_policy_task
s are "chained" together. as the policy_ref
in the parameter comes from the policy_ref
returned from the prior function call. Inside the update_policy_task
, Ray actually does two extra things under the hood for us, which are ray.get()
and ray.put()
as shown below.
@ray.remote
def update_policy_task(policy_ref, experiences_list):
# policy = ray.get(policy_ref) policy_ref: ObjectRef(7df446e0be2f9350ffffffffffffffffffffffff0100000001000000)
[update_policy(policy_ref, ray.get(xp)) for xp in experiences_list]
# policy_ref = ray.put(policy) policy_ref: ObjectRef(80f450872c2ccadaffffffffffffffffffffffff0100000001000000)
return policy_ref
As ray.get
is a waiting function, the function must be wait until the execution of the prior function gets finished. I have been fiddling with code for a while, and still cannot make sure that I understand the code correctly. Please correct me if my understanding is wrong. Much appreciated!
from learning_ray.
@sagebei apologies for the long turnaround. we've now updated the example (https://github.com/maxpumperla/learning_ray/blob/main/notebooks/ch_03_core_app.ipynb) to only do rollouts in parallel, not the actual update step, as this was both confusing (e.g. the race conditions you mentioned) and unnecessary. also note that this pattern (distributed rollouts, central updates to a policy on the driver) is how RLlib currently does things as well.
Hope that helps!
from learning_ray.
Related Issues (11)
- Pendulumv0 vs Pendulum-v0 HOT 6
- RLlib: env must be one of following supported types issue HOT 2
- Will this repo keep update?
- Not use the updated policy
- Exception Errors in Chapter 4: Could be newbie error as well HOT 3
- pygame is required for pendulum demo in chap01 HOT 3
- Example 4-5. ValueError: Cannot evaluate w/o an evaluation worker set in the Trainer or w/o an env on the local worker! HOT 3
- Example 4-11.AttributeError: 'dict' object has no attribute 'set_training' HOT 2
- Example 6-2. not imported HOT 1
- May I translate your book to chinese version? HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from learning_ray.