---
title: "Boosting multimodal inference performance by >10% with a single Python dictionary"
description: "SGLang's single-threaded scheduler was wasting host time on multimodal workloads by calling torch.UntypedStorage._new_shared_cuda for every tensor received over CUDA IPC, repeatedly reopening the same few memory-pool handles."
url: "https://swe.quest/articles/boosting-multimodal-inference-performance-by-10-with-a-single-python-dictionary-89ba3b03f48e9ebc"
canonical: "https://modal.com/blog/boosting-multimodal-inference-performance-by-greater-than-10-with-a-single-python-dictionary"
source: "Modal"
published: "2026-05-04"
difficulty: "hard"
kind: "Case study"
reading_minutes: 7
tags: ["inference","performance","python","caching"]
---

# Boosting multimodal inference performance by \>10% with a single Python dictionary

A post on [Modal](https://swe.quest/sources/modal.md), published 2026-05-04, 7 min read, Case study. Original: [https://modal.com/blog/boosting-multimodal-inference-performance-by-greater-than-10-with-a-single-python-dictionary](https://modal.com/blog/boosting-multimodal-inference-performance-by-greater-than-10-with-a-single-python-dictionary)

## Summary

SGLang's single-threaded scheduler was wasting host time on multimodal workloads by calling torch.UntypedStorage.\_new\_shared\_cuda for every tensor received over CUDA IPC, repeatedly reopening the same few memory-pool handles. Profiling with py-spy flamegraphs traced the overhead through process\_input\_requests and hash\_feature to PyTorch's wrapper bookkeeping. A lock-on-write Python dict caching one storage per pool handle removed the hotspot. On Qwen2.5-VL-3B on an H100 it raised throughput 16%, cut mean TTFT 13% and TPOT 17%, and also improved tail latencies. Decode got faster too because any delay in the single scheduler thread stalls batch dispatch, and the change ships in SGLang v0.5.10 behind SGLANG\_USE\_IPC\_POOL\_HANDLE\_CACHE=1.

Written by swe.quest, not by the author.

**Difficulty:** Hard: written for specialists in the field

## Topics

- [Inference & serving](https://swe.quest/tags/inference.md) (AI & ML)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)
- [Python](https://swe.quest/tags/python.md) (Languages)
- [Caching](https://swe.quest/tags/caching.md) (Backend & APIs)

## Prerequisites

- LLM inference serving ([easy posts on Inference & serving](https://swe.quest/tags/inference.md?difficulty=easy))
- CUDA memory basics
- Python profiling ([easy posts on Python](https://swe.quest/tags/python.md?difficulty=easy))
- KV cache ([easy posts on Caching](https://swe.quest/tags/caching.md?difficulty=easy))

## Keywords

SGLang, py-spy, CUDA IPC, PyTorch, Qwen2.5-VL, H100

## Related posts

- [Host overhead is killing your inference efficiency](https://swe.quest/articles/host-overhead-is-killing-your-inference-efficiency-42291cc0b68e5c36.md): Modal · 2025-11-18 · Medium · 7 min read · Inference & serving, Performance engineering, Hardware
  GPU idle time while the CPU prepares work (host overhead) shows up as low GPU kernel utilization and directly multiplies inference cost; 50% overhead means GPU spend is 2x what it could be.
- [Boost your throughput with dynamic batching](https://swe.quest/articles/boost-your-throughput-with-dynamic-batching-c7c722ba8af78c33.md): Modal · 2024-09-16 · Medium · 4 min read · Inference & serving, Performance engineering, Serverless, Python
  Modal added a \`@modal.batched()\` decorator that groups incoming requests into batches flushed when either \`max\_batch\_size\` is reached or \`wait\_ms\` elapses, avoiding the unbounded waits of fixed-size batching.
- [Run FLUX.1-dev three times faster](https://swe.quest/articles/run-flux-1-dev-three-times-faster-ae60b80e0a362206.md): Modal · 2025-06-18 · Medium · 9 min read · Inference & serving, Performance engineering, Python, Computer vision, Serverless
  FLUX.1-dev image generation on Modal drops from ~6.75s to under three seconds per 1024x1024 image.
- [ThunderAgent: 2x Faster Agentic Inference for Synthetic Data Generation at Scale](https://swe.quest/articles/thunderagent-2x-faster-agentic-inference-for-synthetic-data-generation-at-scale-7560ef73731954d5.md): Together AI · 2026-07-29 · Hard · 6 min read · Inference & serving, AI agents, Scheduling, Performance engineering, LLMs
  ThunderAgent is a scheduling layer between agent clients and inference backends that treats each multi-turn agentic workflow as a schedulable program instead of independent requests, preventing KV cache thrashing when agents pause for tool calls.
- [How to serve trillions of tokens for trillion-parameter coding agents](https://swe.quest/articles/how-to-serve-trillions-of-tokens-for-trillion-parameter-coding-agents-0508c7c515fa8a14.md): Modal · 2026-09-23 · Hard · 32 min read · Inference & serving, LLMs, Caching, Performance engineering, Hardware
  Modal describes how it serves Moonshot AI's trillion-parameter Kimi K2.6 model for coding-agent traffic at trillions of tokens.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
