Well, I decided to spend some time learning Ray. Why do I do this? Mainly two reasons:
- I would like to get some understanding regarding how distributed computing framework works
- I would like to learn to read source code of an open-source project (I know it is kinda embarrassing that I haven’t studied any open source project after being a software engineer for 6 years)
Hello World
The ray website has the first tiny example:
1 | import ray |
Running this code snippet will give the following result
1 | [0, 1, 4, 9] |
I will ignore the ray.init()
for now as there are likely many details there. The interesting thing here is the @ray.remote
decorator, it turns the square
function into a remote function. Later when we call square.remote(i)
, it gives us a future, which can be resolved via ray.get()
.
Check the source code of ray.remote
:
1 | return ray.remote_function.RemoteFunction( |