-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
[Serve] DeploymentResponse._to_object_ref() blocks untill final results from actor #46893
Comments
I was able to reproduce the issue too: Repro# File name: repro.py
import asyncio
import time
from ray import serve
@serve.deployment(max_ongoing_requests=5)
async def sleepy():
await asyncio.sleep(3)
return "Finished!"
app = sleepy.bind()
async def experiment():
handle = serve.run(app)
print("Starting experiment.")
t0 = time.perf_counter()
deployment_response = handle.remote()
t1 = time.perf_counter()
print(f"Finished remote call: {(t1 - t0):.4f}s")
t2 = time.perf_counter()
assignment_ref = deployment_response._to_object_ref()
t3 = time.perf_counter()
print(f"Created assignment ref: {(t3 - t2):.4f}s")
t4 = time.perf_counter()
result_ref = await assignment_ref
t5 = time.perf_counter()
print(f"Awaited assignment ref: {(t5 - t4):.4f}s")
t6 = time.perf_counter()
result = await result_ref
t7 = time.perf_counter()
print(f"Awaited result ref: {(t7 - t6):.4f}s")
print(f"Final results: {result}")
if __name__ == "__main__":
asyncio.run(experiment())
Awaiting the |
Hi @kyle-v6x can you say more about this, and what you are trying to use the |
@zcin In order to pass the result of a serve replica to an actor async, we need to retrieve the Further, if you want to run a task fully async (I know this is not supported officially yet) it makes sense to retrieve/return the I'll link this one more time for visibility. I may have time next week to finally build locally and work on a solution, but I can't guaruntee! |
Hi @kyle-v6x, your use case makes sense to me, and you're correct that currently that isn't supported in Serve because the second object ref won't be retrieved until the request finishes. We are currently working on a fix! |
fixed by #47209 |
Sorry, not resolved yet. This is depended on #46934 |
What happened + What you expected to happen
Since
2.10.0
, DeploymentResponses._to_object_ref() functions await the final result from the task, rather than returning the ObjectRef of the running task once it is scheduled. This effectively prevents any Async task from being computed while previous tasks are running (i.e passing by ref).You can find more details here.
Versions / Dependencies
This is an issue with
Ray[Serve]>=2.10.0
Reproduction script
Issue Severity
High: It blocks me from completing my task.
The text was updated successfully, but these errors were encountered: