[Bugfix][Multimodal] Recover PyNvVideoCodec decoder slots after failures (#59597)

Signed-off-by: Daniel Afrimi <dafrimi@nvidia.com>
Signed-off-by: danielafrimi <45691845+danielafrimi@users.noreply.github.com>
Signed-off-by: Daniel Afrimi <dafrimi@oci-hsg-cs-001-login-02.cm.cluster>
Co-authored-by: OpenAI Codex <noreply@openai.com>
Co-authored-by: Daniel Afrimi <dafrimi@oci-hsg-cs-001-login-02.cm.cluster>
Co-authored-by: tomeras91 <57313761+tomeras91@users.noreply.github.com>
This commit is contained in:
danielafrimi
2026-10-15 09:17:19 +03:00
committed by GitHub
co-authored by OpenAI Codex Daniel Afrimi tomeras91
parent c5f8adc0b1
commit a9fe30e9f6
8 changed files with 912 additions and 88 deletions
+36 -1
View File
@@ -18,6 +18,7 @@ from vllm.multimodal.video_decoders import PYNVVIDEOCODEC_VIDEO_BACKEND
from vllm.multimodal.video_decoders.pynvvideocodec import (
PYNVVIDEOCODEC_CUDA_CONTEXT_BYTES,
PYNVVIDEOCODEC_DECODER_GPU_MEMORY_BYTES,
get_pynvvideocodec_decoder_gpu_memory_bytes,
)
from vllm.utils.mem_constants import GiB_bytes
@@ -27,12 +28,18 @@ def _mm_config(
mm_ipc_gpu_memory_gb: float = 0,
video_backend: str | None = None,
hw_decoders: int | None = None,
max_width: int | None = None,
max_height: int | None = None,
) -> MultiModalConfig:
video_kwargs: dict[str, object] = (
{} if video_backend is None else {"video_backend": video_backend}
)
if hw_decoders is not None:
video_kwargs["hw_decoders"] = hw_decoders
if max_width is not None:
video_kwargs["max_width"] = max_width
if max_height is not None:
video_kwargs["max_height"] = max_height
return MultiModalConfig(
mm_ipc_gpu_memory_gb=mm_ipc_gpu_memory_gb,
@@ -43,9 +50,11 @@ def _mm_config(
def _pynvvideocodec_decoder_budget(
api_process_count: int = 1,
hw_decoders: int = 2,
max_width: int | None = None,
max_height: int | None = None,
) -> int:
return api_process_count * (
PYNVVIDEOCODEC_DECODER_GPU_MEMORY_BYTES * hw_decoders
get_pynvvideocodec_decoder_gpu_memory_bytes(max_width, max_height) * hw_decoders
+ PYNVVIDEOCODEC_CUDA_CONTEXT_BYTES
)
@@ -246,3 +255,29 @@ def test_reserve_mm_ipc_gpu_memory_uses_configured_hw_decoders(
assert reserve_mm_ipc_gpu_memory(available_bytes, mm_config) == (
available_bytes - _pynvvideocodec_decoder_budget(hw_decoders=3)
)
def test_reserve_mm_ipc_gpu_memory_scales_for_configured_decoder_dimensions(
monkeypatch: pytest.MonkeyPatch,
):
monkeypatch.setenv("VLLM_VIDEO_LOADER_BACKEND", "opencv")
available_bytes = 8 * GiB_bytes
max_width = 7680
max_height = 4320
mm_config = _mm_config(
video_backend=PYNVVIDEOCODEC_VIDEO_BACKEND,
max_width=max_width,
max_height=max_height,
)
assert reserve_mm_ipc_gpu_memory(available_bytes, mm_config) == (
available_bytes
- _pynvvideocodec_decoder_budget(
max_width=max_width,
max_height=max_height,
)
)
assert (
get_pynvvideocodec_decoder_gpu_memory_bytes(max_width, max_height)
> PYNVVIDEOCODEC_DECODER_GPU_MEMORY_BYTES
)