vllm.multimodal.video_prune.vidcom2 ¶
Functions:
-
compute_retained_tokens_count–Number of video tokens retained after VidCom2 pruning.
-
compute_retention_mask–Compute the VidCom2 retention mask for a single video.
_multi_scale_gaussian(x, center) ¶
Sum Gaussian kernels over _ALPHAS; (T, N, C) -> (T, N) scores.
Source code in vllm/multimodal/video_prune/vidcom2.py
compute_retained_tokens_count(tokens_per_frame, num_frames, q) ¶
Number of video tokens retained after VidCom2 pruning.
The target is (1 - q) * total_tokens, i.e. a retention ratio of 1 - q averaged across frames. Because the per-frame budget is floored at one token, the global minimum is num_frames (one token per frame).
Source code in vllm/multimodal/video_prune/vidcom2.py
compute_retention_mask(video_embeds, video_size_thw, spatial_merge_size, q) ¶
Compute the VidCom2 retention mask for a single video.
Parameters:
-
(video_embeds¶Tensor) –(T*H*W/merge^2, hidden_size)post-ViT token features. -
(video_size_thw¶LongTensor | tuple[int, int, int]) –(T, H, W)grid dimensions. -
(spatial_merge_size¶int) –ViT spatial merge factor (e.g. 2).
-
(q¶float) –Pruning fraction in
[0, 1); retention ratio is1 - q.
Returns:
-
Tensor–Flat bool tensor of shape
(T*H*W/merge^2,), True for retained -
Tensor–tokens. The True count equals
compute_retained_tokens_countso -
Tensor–placeholders sized at prompt-processing time match exactly.