Skip to content

[Bug]: Per-request media_io_kwargs let one small video request allocate gigabytes in trtllm-serve #20988

Description

@LeizhenZhang

System Info

TensorRT-LLM main (687359e), trtllm-serve with a video-capable multimodal model. CPU-side decode, no GPU needed to reproduce.

Who can help?

@NVIDIA/trt-llm-runtime-devs (CODEOWNERS for tensorrt_llm/serve and tensorrt_llm/inputs)

Reproduction

ChatCompletionRequest.media_io_kwargs (openai_protocol.py, "Per-request override for the server's --media_io_kwargs") is merged into VideoMediaIO with no bounds. _load_video_by_cv2 samples min(num_frames, frame_count, duration * fps) frames and stacks them, then converts to float32 for format="pt".

  1. Encode 1000 black 1280x720 frames with OpenCV mp4v (1.2 MB file).
  2. Send it as a video_url data URI with "media_io_kwargs": {"video": {"num_frames": 500, "fps": 1000}}.

Expected behavior

The server bounds the number of decoded frames (or the decoded byte size) independently of what the client asks for.

Actual behavior

Measured with the real chat_utils.parse_chat_messages_coroutines and VideoMediaIO:

num_frames requested Decoded Peak RSS Wall time
10 (default) 0.10 GiB 0.85 GiB 5.5 s
500 5.15 GiB float32 12.2 GiB 195 to 264 s
1000 tried to allocate (1000, 720, 1280, 3) float32 = 11 GiB, stopped only by the test's 24 GiB address-space cap 165 to 247 s

The 200 MiB limit on the encoded video does not bound the decoded size, and the client controls the frame count.

Additional notes

The right bound is a policy choice for maintainers, so this issue comes without a PR. Possible fixes: cap request-supplied num_frames at the server's configured value or a hard maximum, and/or cap frames x height x width before stacking.

Activity

  1. added
    Multimodal
    on Oct 26, 2026
  2. added 3 commits that reference this issue on Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Multimodal

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions