vllm.v1.worker.cpu.mm_pruning
¶
Classes:
-
MultiModalPruner–Recomputes M-RoPE positions for multimodal models that prune embeddings
Functions:
-
maybe_create_mm_pruner–Create a MultiModalPruner if the model prunes embeddings and uses M-RoPE.
MultiModalPruner
¶
Recomputes M-RoPE positions for multimodal models that prune embeddings (e.g. Qwen2.5-VL / Qwen3-VL / Nemotron-Nano-VL Efficient Video Sampling).
Pruning models append their mrope-position channels to the (variable-count)
media embeddings from embed_multimodal. Those channels must be split off and
used to recompute mrope positions before the embeddings are merged.
Methods:
-
recompute–Target forward: split the appended mrope-position channels off each
Source code in vllm/v1/worker/cpu/mm_pruning.py
_num_window_embeds(req_id, query_start, query_end)
¶
Count the media items contributing embeddings to [query_start, query_end), mirroring EncoderRunner.gather_mm_embeddings' per-request windowing so the flat mm_embeds list can be re-segmented per request.
Note: This logic is intentionally duplicated here rather than being emitted from gather_mm_embeddings, to keep the main path cleaner, since this is a niche feature.
Source code in vllm/v1/worker/cpu/mm_pruning.py
recompute(mm_embeds, input_batch, req_states)
¶
Target forward: split the appended mrope-position channels off each request's media embeddings, recompute the corrected mrope positions, and stage them back into RopeState. Returns the cleaned, flattened embeddings.
Source code in vllm/v1/worker/cpu/mm_pruning.py
maybe_create_mm_pruner(model_config, model, rope_state, encoder_cache)
¶
Create a MultiModalPruner if the model prunes embeddings and uses M-RoPE.