[Feature] Add VidCom2 video token pruning (#47750)

Signed-off-by: Benedikt Falk <bfalk@nvidia.com>
This commit is contained in:
nvbfalk
2026-07-28 03:20:17 +00:00
committed by GitHub
parent 7aea73d83d
commit 60915c972c
17 changed files with 421 additions and 48 deletions
+17 -4
View File
@@ -61,6 +61,7 @@ class MultiModalDummyOptionsBuiltins(TypedDict, total=False):
MMEncoderTPMode = Literal["weights", "data"]
MMCacheType = Literal["shm", "lru"]
VideoPruningMethod = Literal["evs", "vidcom2"]
MMTensorIPC = Literal["direct_rpc", "torch_shm"]
MMDummyOptions: TypeAlias = dict[str, BaseDummyOptions]
"""
@@ -189,9 +190,14 @@ class MultiModalConfig:
estimating the peak memory usage of the activation of multimodal encoder and
embedding cache."""
video_pruning_rate: float | None = Field(default=None, ge=0.0, lt=1.0)
"""Sets pruning rate for video pruning via Efficient Video Sampling.
Value sits in range [0;1) and determines fraction of media tokens
from each video to be pruned.
"""Fraction of video tokens to prune from each video. Value sits in range
[0;1); pruning is enabled when it is greater than 0. The pruning algorithm
is selected by `video_pruning_method`.
"""
video_pruning_method: VideoPruningMethod = "evs"
"""Video token pruning algorithm applied when `video_pruning_rate` > 0:
- "evs": Efficient Video Sampling.
- "vidcom2": Video Compression Commander.
"""
mm_tensor_ipc: MMTensorIPC = "direct_rpc"
"""IPC (inter-process communication) method for multimodal tensors.
@@ -360,4 +366,11 @@ class MultiModalConfig:
)
def is_multimodal_pruning_enabled(self):
return self.video_pruning_rate is not None and self.video_pruning_rate > 0
return self.get_video_pruning_spec() is not None
def get_video_pruning_spec(self) -> tuple[VideoPruningMethod, float] | None:
"""Return `(method, rate)` when video pruning is enabled, else None.
`rate` is the fraction of video tokens to prune."""
if self.video_pruning_rate is not None and self.video_pruning_rate > 0:
return (self.video_pruning_method, float(self.video_pruning_rate))
return None