Skip to content

vllm.model_executor.models.kanana_v

Classes:

Functions:

  • build_mlp –

    Simple SiLU-activated MLP used as a projector readout.

  • build_pos_embeds –

    Build positional embeddings for the visual encoder output.

CustomQwen2VLVE

Bases: Qwen2VisionTransformer

Thin wrapper around the Qwen2-VL used as a vision encoder.

This mirrors the original HF-based vision encoder used in Kanana-V, but reuses vLLM's optimized Qwen2VisionTransformer building blocks.

Methods:

  • forward –

    Run the vision transformer and optionally return intermediate states.

_from_config(config) classmethod

Drop-in replacement for the HF _from_config constructor.

forward(pixel_values, grid_thw, output_hidden_states=None, return_dict=None)

Run the vision transformer and optionally return intermediate states.

Unlike the base Qwen2VisionTransformer, this wrapper exposes the pre-merger patch-level representations and a HF-style BaseModelOutput so that the existing projector / abstractor code can be reused.

DynamicCAbstractor

Bases: Module

Dynamic C-Abstractor based on RegNet blocks.

Methods:

  • forward –

    Apply the dynamic abstractor over flattened visual embeddings.

forward(flattened_visual_embeds, grid_thw, **unused_kwargs)

Apply the dynamic abstractor over flattened visual embeddings.

KananaVImagePixelInputs

Bases: TensorSchema

Dimensions: - np: The total number of patches over all images in the batch - cps: Number of channels * patch_size * patch_size - ni: Number of images

KananaVMultiModalProcessor

Bases: BaseMultiModalProcessor[KananaVProcessingInfo]

vLLM multimodal processor for Kanana-V (text + image).

_apply_hf_processor_main(mm_items, hf_kwargs)

Run the underlying HF processor on text and image data.

PatchMerge

Bases: Module

Merge neighboring patches spatially to reduce resolution.

Methods:

  • forward –

    Merge patches by merge_size x merge_size.

forward(x, channel_last=False)

Merge patches by merge_size x merge_size.

build_mlp(depth, hidden_size, output_hidden_size)

Simple SiLU-activated MLP used as a projector readout.

build_pos_embeds(config, num_input_tokens, vision_hidden_size)

Build positional embeddings for the visual encoder output.