vllm.multimodal.gpu_ipc_memory
¶
Admission control for frontend GPU-side multimodal work.
When multimodal media is decoded on the GPU in the API-server (frontend)
process, the decoded buffers compete for the same device memory that the
engine reserves for weights, activations, and the KV cache. To keep the
frontend's GPU usage within a sequestered budget (see
MultiModalConfig.mm_ipc_gpu_memory_gb), decode paths acquire the number of
bytes they need from a process-global MultiModalGPUMemoryPool before
allocating on the device and release them once the device memory is freed.
The pool is a simple byte-counting semaphore: acquire blocks until enough
budget is free, so concurrent requests serialize rather than oversubscribe the
GPU. It lives only in the frontend process; the engine carves the matching
amount out of its KV-cache budget so the headroom physically exists.
Classes:
-
MultiModalGPUMemoryLease–A handle for bytes acquired from a
MultiModalGPUMemoryPool. -
MultiModalGPUMemoryPool–Blocking byte-counting semaphore for frontend GPU multimodal memory.
Functions:
-
get_mm_gpu_ipc_pool–Return the process-global pool, or
Nonewhen gating is disabled. -
maybe_init_mm_gpu_ipc_pool–Create and install the global pool from the configured GiB budget.
-
reserve_mm_ipc_gpu_memory–Return KV-cache memory remaining after frontend multimodal reservations.
-
set_mm_gpu_ipc_pool–Install the process-global pool (frontend process only).
MultiModalGPUMemoryLease
¶
A handle for bytes acquired from a MultiModalGPUMemoryPool.
Releasing is idempotent and the lease doubles as a context manager so the budget is returned even if the decode raises.
MultiModalGPUMemoryPool
¶
Blocking byte-counting semaphore for frontend GPU multimodal memory.
Thread-safe in both directions: acquire (blocking) and release are
typically called from the renderer's multimodal executor threads.
Methods:
-
acquire–Reserve
nbytes, blocking until that much budget is free.
acquire(nbytes)
¶
Reserve nbytes, blocking until that much budget is free.
Raises ValueError if nbytes exceeds the pool's total capacity,
since such a request could never be satisfied.
get_mm_gpu_ipc_pool()
¶
Return the process-global pool, or None when gating is disabled.
maybe_init_mm_gpu_ipc_pool(mm_ipc_gpu_memory_gb, api_process_count=1)
¶
Create and install the global pool from the configured GiB budget.
Returns None (and leaves gating disabled) when the budget is 0. When
multiple API-server processes share one engine, each process gets an equal
slice of the user-provided frontend budget.
reserve_mm_ipc_gpu_memory(available_kv_cache_memory_bytes, mm_config, api_process_count=1)
¶
Return KV-cache memory remaining after frontend multimodal reservations.
The reservation covers:
- The total
mm_ipc_gpu_memory_gbbudget for transient decoded-frame buffers. This budget is divided among API processes, so it is not multiplied byapi_process_count. - For GPU video backends, a fixed upper bound for each API process's
retained decoder surfaces and CUDA context. The PyNvVideoCodec surface
reservation scales with its configured
hw_decodersvalue, and the entire decoder reservation scales withapi_process_countbecause these resources are not shared between processes.
Parameters:
-
(available_kv_cache_memory_bytes¶int) –KV-cache capacity before reserving memory for frontend multimodal processing.
-
(mm_config¶MultiModalConfig | None) –Multimodal configuration, or
Nonewhen multimodal processing is disabled. -
(api_process_count¶int, default:1) –Number of frontend API processes sharing the GPU. Values below one are treated as one.
Returns:
-
int–KV-cache capacity after subtracting the frontend reservation.
Raises:
-
ValueError–If the reservation leaves no memory for the KV cache.
set_mm_gpu_ipc_pool(pool)
¶
Install the process-global pool (frontend process only).