diffusers icon indicating copy to clipboard operation
diffusers copied to clipboard

Add thread-safe wrappers for components in pipeline (examples/server-async/utils/requestscopedpipeline.py)

Open FredyRivera-dev opened this issue 2 months ago • 5 comments

What does this PR do?

In the file examples/server-async/utils/requestscopedpipeline.py, add thread-safe wrappers for the tokenizer, VAE, and image processor. Introduce locking mechanisms to ensure thread safety during concurrent access.

This improves memory safety when using the VAE and ImageProcessor wrappers, helping to avoid memory leaks.

Who can review?

Core library / Schedulers / Pipelines: @yiyixuxu, @asomoza, @sayakpaul
General / integrations: @DN6, @stevhliu

FredyRivera-dev avatar Oct 21 '25 00:10 FredyRivera-dev

Ok, I'm going to move the wrappers to a separate file, and it was just an update to add wrappers to the VAE and the ImageProccesor to avoid memory leaks during decoding and saving of the image when the Pipeline is executed (requestscopedpipeline.py), sorry if it wasn't very clear

FredyRivera-dev avatar Oct 21 '25 00:10 FredyRivera-dev

Heeyyy @sayakpaul I already moved the wrappers to wrappers.py, check it out :b

FredyRivera-dev avatar Oct 21 '25 01:10 FredyRivera-dev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@bot /style

sayakpaul avatar Oct 21 '25 05:10 sayakpaul

Style bot fixed some files and pushed the changes.

github-actions[bot] avatar Oct 21 '25 05:10 github-actions[bot]