A high-throughput and memory-efficient inference and serving engine for LLMs
Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git
Synced Nov 6, 17:00 UTC
Remove unused EVS functions in qwen3_vl.py (#37183)
Signed-off-by: Tianyu Guo <guoty9@mail2.sysu.edu.cn>
Tianyu Guo committed
Mar 16, 2026 at 21:09 UTC
43a73f853bac76e6c95c629e4aaa0858f610eb11
1 file changed
-101
vllm/model_executor/models/qwen3_vl.py
-101
@@ -1959,107 +1959,6 @@ class Qwen3VLForConditionalGeneration(
1959
else:
1960
raise ValueError(f"Unsupported modality: {mm_feature.modality}")
1961
1962
- def _get_evs_mask_segments(
1963
- self, mm_position: PlaceholderRange, expected_frames: int
1964
- ) -> list[torch.Tensor] | None:
1965
- """Extract contiguous segments from EVS is_embed mask.
1966
-
1967
- The EVS (Efficient Video Sampling) mask marks which placeholder
1968
- positions should be filled with video embeddings. This method splits
1969
- the mask into contiguous segments, where each segment represents one
1970
- retained frame.
1971
-
1972
- This is a pure function - it does not modify any state and always
1973
- returns the same output for the same input (idempotent).
1974
-
1975
- Args:
1976
- mm_position: MultiModal position containing the is_embed mask
1977
- expected_frames: Expected number of frame segments
1978
-
1979
- Returns:
1980
- List of tensors, each containing indices for one frame segment,
1981
- or None if EVS is not enabled or validation fails.
1982
- """
1983
- is_embed_mask = getattr(mm_position, "is_embed", None)
1984
- if is_embed_mask is None:
1985
- return None
1986
-
1987
- # Find all True positions in the mask
1988
- mask_tensor = torch.as_tensor(is_embed_mask, dtype=torch.bool).view(-1)
1989
- true_indices = torch.nonzero(mask_tensor, as_tuple=False).flatten()
1990
- if true_indices.numel() == 0:
1991
- return None
1992
-
1993
- # Split into contiguous segments (where diff > 1 indicates a gap)
1994
- if true_indices.numel() == 1:
1995
- segments = [true_indices]
1996
- else:
1997
- diffs = torch.diff(true_indices)
1998
- split_points = torch.nonzero(diffs != 1, as_tuple=False).flatten()
1999
- if split_points.numel() == 0:
2000
- segments = [true_indices]
2001
- else:
2002
- segments = torch.tensor_split(
2003
- true_indices, split_points.add(1).tolist()
2004
- )
2005
-
2006
- # Validate segment count matches expected frames
2007
- if len(segments) < expected_frames:
2008
- logger.debug(
2009
- "EVS mask segments (%d) do not match expected frames (%d)",
2010
- len(segments),
2011
- expected_frames,
2012
- )
2013
- return None
2014
-
2015
- return segments[:expected_frames]
2016
-
2017
- def _extract_frame_offsets_from_mask(
2018
- self, mm_position: PlaceholderRange, expected_frames: int
2019
- ) -> list[int] | None:
2020
- """Return relative offsets for each EVS-retained frame.
2021
-
2022
- The prompt processor stores a boolean mask inside ``mm_position`` that
2023
- marks which placeholder locations should be populated with video
2024
- embeddings. By splitting that mask into contiguous runs we can recover
2025
- the start of every retained frame without probing ``input_tokens``.
2026
-
2027
- Args:
2028
- mm_position: MultiModal position containing the is_embed mask
2029
- expected_frames: Expected number of frames
2030
-
2031
- Returns:
2032
- List of starting offsets (relative to mm_position) for each frame,
2033
- or None if EVS is not enabled.
2034
- """
2035
- segments = self._get_evs_mask_segments(mm_position, expected_frames)
2036
- if segments is None:
2037
- return None
2038
-
2039
- return [int(segment[0].item()) for segment in segments]
2040
-
2041
- def _get_actual_frame_token_counts(
2042
- self, mm_position: PlaceholderRange, expected_frames: int
2043
- ) -> list[int] | None:
2044
- """Return actual token count for each EVS-retained frame.
2045
-
2046
- This function calculates the actual number of tokens per frame by
2047
- analyzing the is_embed mask, accounting for EVS pruning. Each frame
2048
- may have a different token count due to content-aware pruning.
2049
-
2050
- Args:
2051
- mm_position: MultiModal position containing the is_embed mask
2052
- expected_frames: Expected number of frames
2053
-
2054
- Returns:
2055
- List of token counts for each frame, or None if EVS is not enabled.
2056
- """
2057
- segments = self._get_evs_mask_segments(mm_position, expected_frames)
2058
- if segments is None:
2059
- return None
2060
-
2061
- return [len(seg) for seg in segments]
2062
-
1962
def get_mrope_input_positions(
1963
self,
1964
input_tokens: list[int],