@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / 7f40e9e516
Fork 0

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 7, 22:45 UTC

[Refactor] Remove dead private func `_fp8_perm` and `_extract_mask_for_item` (#35068)

Signed-off-by: yewentao256 <zhyanwentao@126.com>

Wentao Ye committed Feb 23, 2026 at 08:05 UTC 7f40e9e5164af6af34bcbd5945356d416e29e71a
2 files changed -46
vllm/model_executor/layers/fused_moe/utils.py
-10
@@ -284,16 +284,6 @@ def moe_kernel_quantize_input(
284 return A, A_scale
285
286
287 -def _fp8_perm(m: torch.Tensor, idx: torch.Tensor) -> torch.Tensor:
288 - """
289 - A permutation routine that works on fp8 types.
290 - """
291 - if torch.is_floating_point(m) and m.dtype.itemsize == 1:
292 - return m.view(dtype=torch.uint8)[idx, ...].view(dtype=m.dtype)
293 - else:
294 - return m[idx, ...]
295 -
296 -
287 def normalize_scales_shape(scales: torch.Tensor | None) -> torch.Tensor | None:
288 if scales is not None:
289 if scales.numel() == 1:
vllm/model_executor/models/glmasr_utils.py
-36
@@ -130,39 +130,3 @@ def _group_audio_embeddings(
130 grouped_embeddings.append(torch.cat(audio_chunks, dim=0))
131 current_idx += count
132 return tuple(grouped_embeddings)
133 -
134 -
135 -def _normalize_to_tensor(mask: torch.Tensor | list[torch.Tensor]) -> torch.Tensor:
136 - """Convert mask to tensor, handling both list and tensor formats."""
137 - if isinstance(mask, list):
138 - return (
139 - torch.stack(mask)
140 - if mask and isinstance(mask[0], torch.Tensor)
141 - else torch.tensor(mask)
142 - )
143 - return mask
144 -
145 -
146 -def _extract_mask_for_item(
147 - feature_attention_mask: torch.Tensor | list[torch.Tensor],
148 - chunk_counts: torch.Tensor | list[int] | None,
149 - item_idx: int,
150 -) -> torch.Tensor:
151 - """Extract attention mask for a specific audio item."""
152 - if chunk_counts is None:
153 - # Single item per audio
154 - mask = feature_attention_mask[item_idx]
155 - if isinstance(feature_attention_mask, torch.Tensor):
156 - return mask.unsqueeze(0)
157 - return _normalize_to_tensor(mask)
158 -
159 - # Multiple chunks per audio: calculate slice indices
160 - counts = _as_list_chunk_counts(chunk_counts)
161 - start_idx = sum(counts[:item_idx])
162 - end_idx = start_idx + counts[item_idx]
163 -
164 - # Extract slice
165 - if isinstance(feature_attention_mask, torch.Tensor):
166 - return feature_attention_mask[start_idx:end_idx]
167 - mask_slice = feature_attention_mask[start_idx:end_idx]
168 - return _normalize_to_tensor(mask_slice)