[Perf] Defer MM embeds loading off the event loop (#49477)

Signed-off-by: Guan-Ming (Wesley) Chiu <105915352+guan404ming@users.noreply.github.com>
This commit is contained in:
Guan-Ming Chiu
2026-07-23 13:58:50 +00:00
committed by GitHub
parent 638d6e9757
commit 80c7683923
2 changed files with 70 additions and 24 deletions
+28
View File
@@ -593,6 +593,20 @@ class MediaConnector:
return image_embedding_io.load_base64("", data)
async def fetch_image_embedding_async(
self,
data: str,
) -> torch.Tensor:
"""
Asynchronously load image embedding from a URL.
"""
image_embedding_io = ImageEmbeddingMediaIO()
loop = asyncio.get_running_loop()
return await loop.run_in_executor(
global_thread_pool, image_embedding_io.load_base64, "", data
)
def fetch_audio_embedding(
self,
data: str,
@@ -603,3 +617,17 @@ class MediaConnector:
audio_embedding_io = AudioEmbeddingMediaIO()
return audio_embedding_io.load_base64("", data)
async def fetch_audio_embedding_async(
self,
data: str,
) -> torch.Tensor:
"""
Asynchronously load audio embedding from a URL.
"""
audio_embedding_io = AudioEmbeddingMediaIO()
loop = asyncio.get_running_loop()
return await loop.run_in_executor(
global_thread_pool, audio_embedding_io.load_base64, "", data
)