Skip to content

vllm.v1.worker.gpu.model_states.mm_pruning

Classes:

  • MultiModalPruner –

    Recomputes M-RoPE positions for multimodal models that prune embeddings

Functions:

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

  • strip –

    Draft forward: strip the appended position channels only.

_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.

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.

strip(mm_embeds)

Draft forward: strip the appended position channels only.

Stripping is per-embedding, so no per-request segmentation is needed. The speculator reuses the target's already-recomputed positions, hence there is no position write-back here.

maybe_create_mm_pruner(model_config, model, rope_state, encoder_cache)

Create a MultiModalPruner if the model prunes embeddings and uses M-RoPE.

uses_multimodal_pruning(model_config, model)

Whether the model prunes multimodal embeddings (e.g. EVS).