[MM][CG] Enable encoder CUDA Graph for MiniCPM-V (#42785)

Signed-off-by: YunzhuLu <lucia.yunzhu@gmail.com>
Signed-off-by: Isotr0py <Isotr0py@outlook.com>
Co-authored-by: Isotr0py <Isotr0py@outlook.com>
This commit is contained in:
Yunzhu Lu
2026-09-10 06:28:48 +00:00
committed by GitHub
co-authored by Isotr0py
parent c3ccc0e957
commit 442d36031c
26 changed files with 843 additions and 103 deletions
+15 -1
View File
@@ -2,13 +2,19 @@
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
"""Data transfer objects for encoder CUDA graph management."""
from collections.abc import Callable
from collections.abc import Callable, Hashable
from dataclasses import dataclass, field
import torch
EncoderCudaGraphPaddingLogic = Callable[[torch.Tensor, torch.Tensor], None]
# Reserved mm_kwargs key: models with ``EncoderCudaGraphConfig.capture_axes``
# put the resolved per-axis keys (one per axis, in order) into the dict
# returned by ``select_encoder_cudagraph_items()``; the manager pops it before
# the kwargs are used anywhere else.
ENCODER_CUDAGRAPH_AXIS_KEYS_KWARG = "encoder_cudagraph_axis_keys"
@dataclass
class EncoderItemSpec:
@@ -88,6 +94,14 @@ class EncoderCudaGraphConfig:
)
"""Independently captured encoder paths keyed by their forward name."""
capture_axes: tuple[tuple[Hashable, ...], ...] = ()
"""Extra capture axes beyond the token budget; empty to disable.
Each entry is the ordered key set of one axis. When non-empty, one graph
is captured per token budget per combination of axis keys (cartesian
product), so the total number of captured graphs is
``num_budgets * prod(len(axis) for axis in capture_axes)``."""
@dataclass
class EncoderCudaGraphCaptureInputs: