Skip to content

Conversation

FredyRivera-dev
Copy link
Contributor

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 FredyRivera-dev changed the title Add thread-safe wrappers for components in pipeline Add thread-safe wrappers for components in pipeline (examples/server-async/utils/requestscopedpipeline.py) Oct 21, 2025
Copy link
Member

@sayakpaul sayakpaul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Could the wrappers be moved to a separate Python file (maybe named wrappers.py) and we use them from there in examples/server-async/utils/requestscopedpipeline.py?

WDYT?

@FredyRivera-dev
Copy link
Contributor Author

FredyRivera-dev commented Oct 21, 2025

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
Copy link
Contributor Author

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

@HuggingFaceDocBuilderDev

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.

@sayakpaul
Copy link
Member

@bot /style

Copy link
Contributor

github-actions bot commented Oct 21, 2025

Style bot fixed some files and pushed the changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants