[Multimodal] Simplify ViT CUDA graph interfaces (#41234)

Signed-off-by: Isotr0py <mozf@mail2.sysu.edu.cn>
This commit is contained in:
Isotr0py
2026-05-22 22:31:00 +08:00
committed by GitHub
parent fb21d8b4f9
commit f0feb15e7f
9 changed files with 151 additions and 149 deletions
+22
View File
@@ -8,6 +8,23 @@ from typing import Any
import torch
@dataclass
class EncoderItemSpec:
"""Description of a single encoder input item.
Returned by ``get_encoder_cudagraph_item_specs()`` to describe each
image or video in a batch without the manager needing to understand
model-specific input formats.
"""
input_size: int
"""Number of input patches/rows for this item."""
output_tokens: int
"""Number of output tokens after encoder processing (e.g. after
spatial merge)."""
@dataclass
class EncoderCudaGraphConfig:
"""Configuration for encoder CUDA graph management.
@@ -34,6 +51,11 @@ class EncoderCudaGraphConfig:
"""Output hidden dim of the vision encoder.
Used for DP gather buffer allocation."""
max_frames_per_video: int = 1
"""Maximum number of frames per video.
Only relevant when "video" is in ``modalities``.
Image-only models can use the default of 1."""
@dataclass
class EncoderCudaGraphCaptureInputs: