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

[Core] Have ActorPool.submit return a future #38061

Open
Darkdragon84 opened this issue Aug 3, 2023 · 7 comments
Open

[Core] Have ActorPool.submit return a future #38061

Darkdragon84 opened this issue Aug 3, 2023 · 7 comments
Labels
core Issues that should be addressed in Ray Core core-util enhancement Request for new feature and/or capability good first issue Great starter issue for someone just starting to contribute to Ray P1.5 Issues that will be fixed in a couple releases. It will be bumped once all P1s are cleared usability

Comments

@Darkdragon84
Copy link

Description

Hi! I know there is ray.util.ActorPool and the possibility to submit asynchronous jobs via ray.util.ActorPool.submit. However it doesn’t return a future and results can only be retrieved using get_next or get_next_unordered which are blocking, return the result value (no objectref), and offer no way of connecting the retrieved result to a submission call.

OTOH python’s concurrent.futures.Executor.submit returns a concurrent Future, which can be awaited in calling code. This is very useful if several concurrent processes call the same PoolExecutor, bc. each process can await its respective future separately.

With ray.util.ActorPool I don’t see a way to submit tasks to the ActorPool from several concurrent remote tasks, s.t. each calling task gets a future for the job it submitted and await it separately.

Please implement ray.util.ActorPool in such a way that ray.util.ActorPool.submit returns an ObjectRef which can be awaited in calling code with e.g. ray.get().

Use case

ray.util.ActorPool could be used as a drop in replacement for concurrent.futures.Executor. It would be very useful if several concurrent processes (e.g. ray tasks) were able to asynchronously submit to the same ActorPool, s.t. each process can await its respective future separately.

@Darkdragon84 Darkdragon84 added enhancement Request for new feature and/or capability triage Needs triage (eg: priority, bug/not-bug, and owning component) labels Aug 3, 2023
@Darkdragon84
Copy link
Author

@Darkdragon84 Darkdragon84 changed the title Have ActorPool.submit return a future [Core] [Core] Have ActorPool.submit return a future Aug 4, 2023
@jjyao jjyao added core Issues that should be addressed in Ray Core good first issue Great starter issue for someone just starting to contribute to Ray P1.5 Issues that will be fixed in a couple releases. It will be bumped once all P1s are cleared labels Aug 7, 2023
@jjyao
Copy link
Collaborator

jjyao commented Aug 7, 2023

Hi @Darkdragon84,

Thanks for submitting this feature request. Are you willing to contribute? We can help.

@jjyao jjyao removed the triage Needs triage (eg: priority, bug/not-bug, and owning component) label Aug 7, 2023
@PRESIDENT810
Copy link
Contributor

Hi, I want to help with this issue. Can I try this one?

@Darkdragon84
Copy link
Author

Hi! Yes, I am happy to contribute! What's the best way to proceed? cheers

@PRESIDENT810
Copy link
Contributor

Hi! Yes, I am happy to contribute! What's the best way to proceed? cheers

I'm thinking extending a Future class (as a wrapper of ray.ObjectRef) returned when calling submit(). Calling Future.result() will behave just like get_unordered_next(), but waits for this specific future instead of any future, and pop that future if it's finished just like in get_unordered_next(). In this way users have a result() API to wait for future returned in submit(), and we can also keep the original behavior unchanged with the same APIs in ActorPool?

But while I was trying to implement it I found get_unordered_next() method has some bugs (#38607 and #38635). I'm thinking maybe I should fix those two first before implementing this Future API?

@larrylian
Copy link
Contributor

larrylian commented Sep 1, 2023

@Darkdragon84 @PRESIDENT810
I Recently, I have been proposing a new API for batch submission of actor tasks. I believe that this can perfectly meet your requirements and significantly improve performance.

[Core] ray.util.ActorPool supports batch submission of remote actor tasks #39196

@anyscalesam
Copy link
Contributor

@jjyao let's prioritize this later unless you tell me an internal team needs this; focus on p0/p1 internal team reported issues seems bigger bang for buck

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Issues that should be addressed in Ray Core core-util enhancement Request for new feature and/or capability good first issue Great starter issue for someone just starting to contribute to Ray P1.5 Issues that will be fixed in a couple releases. It will be bumped once all P1s are cleared usability
Projects
None yet
Development

No branches or pull requests

6 participants