haystack icon indicating copy to clipboard operation
haystack copied to clipboard

Async Pipelines

Open Timoeller opened this issue 1 year ago • 12 comments

We want to showcase async RAG pipelines in 2.0.

There is already async 2.0 code in: https://github.com/deepset-ai/haystack/commit/48534693a45072041309c3f9e3b572ef09f2ac9e

Timoeller avatar Oct 09 '23 16:10 Timoeller

FYI: We currently don't know if asyncio actually is the best solution. Could be that threading might actually be better. @ArzelaAscoIi and I want to give this another stab this Friday

wochinge avatar Oct 30 '23 13:10 wochinge

Depriotized for the beta release since we wont break existing functionality.

Timoeller avatar Nov 23 '23 13:11 Timoeller

Can we bring this back? Would love to have async, so things are a bit easier for the backend - particularly if you call mostly REST endpoints in the pipeline.

jdb78 avatar Jan 26 '24 17:01 jdb78

honestly, if being super ideal .. then would use rust as backend to handle async/multithreading (no GIL in rust)/multiprocessing for efficiency and expose api in python with way to create components in rust or python ;)

jermatic avatar Apr 21 '24 03:04 jermatic

Hi there, to anybody in this thread. We are going to host an async office hour next Tuesday in our discord server. Office hours are friendly informal sessions. We would love to see you there to find out more about your use case, and maybe share what you can already achieve today that might solve your problem.

Link for the event: https://discord.com/events/993534733298450452/1232379918822932530

We look forward to seeing you there!

mrm1001 avatar Apr 26 '24 11:04 mrm1001

Hi! Is there a clean outline somewhere about using async components with haystack?

If we cannot write all our components asynchronously (we are serving our chat endpoints via FastAPI) this would be a dealbreaker for us. It would also be nice if most components offered by haystack would be asynchronous.

I would be thankful for a quick update since we are doing a code refactor very soon. 🙂 Thank you!

tostenzel avatar Jun 05 '24 12:06 tostenzel

Hi @tostenzel we're in the process of introducing an AsyncPipeline along with a subset of components for which it makes sense to support async execution. The AsyncPipeline will be able to run non-async components as well, so it will be a drop-in replacement for the normal Pipeline.

masci avatar Jun 14 '24 12:06 masci

While this is still in development I would like to propose to also support Trio as an async framework. Trio is an async API for humans.

Writing sound code with Asyncio is notoriously difficult. I suggest reading some of these items to find out why. Trio makes it orders of magnitudes easier to write clean and tractable async code by following principles of "structured concurrency" . It's been a real life saver for me and I could imagine it would be for many others too.

Probably the easiest way to have Haystack support both Trio and Asyncio async frameworks simultaneously would be to use AnyIO.

iiLaurens avatar Jul 01 '24 18:07 iiLaurens

Hi @tostenzel we're in the process of introducing an AsyncPipeline along with a subset of components for which it makes sense to support async execution. The AsyncPipeline will be able to run non-async components as well, so it will be a drop-in replacement for the normal Pipeline.

@masci when do you anticipate this feature being released?

vineetsajuTR avatar Jul 23 '24 20:07 vineetsajuTR

@vineetsajuTR We'll work on this topic this quarter.

julian-risch avatar Aug 13 '24 14:08 julian-risch

https://github.com/deepset-ai/haystack-experimental/pull/65

shadeMe avatar Sep 03 '24 13:09 shadeMe