Skip to content

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:

Functions:

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_gb budget for transient decoded-frame buffers. This budget is divided among API processes, so it is not multiplied by api_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_decoders value, and the entire decoder reservation scales with api_process_count because 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 None when 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).