Skip to content

vllm.model_executor.models.qwen2_5_omni_thinker

Inference-only Qwen2.5-Omni model (thinker part).

Classes:

Functions:

Qwen2_5OmniAudioFeatureInputs

Bases: TensorSchema

Dimensions: - na: Number of audios - nmb: Number of mel bins - msl: Maximum sequence length - tsl: Total sequence length

Qwen2_5OmniThinkerForConditionalGeneration

Bases: Module, SupportsMultiModal, SupportsPP, SupportsLoRA, SupportsMRoPE, Qwen2_5OmniConditionalGenerationMixin

Methods:

_compute_audio_token_count(audio_feature_length)

Compute audio tokens from feature length.

_compute_interleaved_positions(start_idx, data)

Compute positions for interleaved video+audio chunks.

Returns: (position_ids, total_token_count)

_get_audio_for_video_mapping(mm_features)

Map video offset -> paired audio_feature_length for use_audio_in_video.

When use_audio_in_video=True, audio is interleaved within video chunks. The pairing is based on feature order in mm_features.

Returns:

  • tuple[dict[int, int], set[int]] –

    Tuple of (video_offset -> audio_feature_length mapping, set of paired audio offsets to skip)

get_mm_mapping()

Get the module prefix in multimodal models

get_mrope_input_positions(input_tokens, mm_features)

Compute M-RoPE input positions using mm_features directly.

Example for use_audio_in_video case

(V_i are vision position ids, A_i are audio position ids)

|V_1 ... V_n|A_1 ... A_n|V_n+1 ... V_2n|A_n+1 ... A_2n|... |vision chunk 1|audio chunk 1|vision chunk 2|audio chunk 2 |...

iter_mm_features(mm_features)

Iterate over multimodal features sorted by position offset.

Yields: (offset, modality, feature_data) where feature_data contains: - image: {"grid_t", "grid_h", "grid_w", "t_factor"} - video: {"grid_t", "grid_h", "grid_w", "t_factor", "use_audio_in_video", "audio_feature_length"} - audio: {"audio_feature_length"}

Qwen2_5OmniThinkerMultiModalProcessor

Bases: BaseMultiModalProcessor[_I]

Methods:

_derive_audio_from_video_placeholders(placeholders, mm_prompt_updates)

Helper to derive audio placeholders from video placeholders when use_audio_in_video=True.

_maybe_apply_prompt_updates(mm_items, mm_res)

Qwen2.5-Omni reimplements this function to handle use_audio_in_video.

omni_get_updates_use_audio_in_video(thinker_config, audio_len, video_grid_thw, video_second_per_grid_t) classmethod

Get video prompt updates when use_audio_in_video is True.

In this case, audio and vision update ids will be split into chunks and interleaved (details in _omni_get_input_positions_tensor).

<|video_bos|><|VIDEO|><|video_eos|> => <|video_bos|><|audio_bos|>(... chunks ...)<|audio_eos|><|video_eos|>

Qwen2_5OmniThinkerProcessingInfo

Bases: Qwen2AudioProcessingInfo, Qwen2_5_VLProcessingInfo

Methods:

get_target_channels()

Return target audio channels for Qwen2.5 Omni models (mono).

check_interleaved_audio_video(is_video, is_audio, num_video, num_audio)

Check if video and audio positions are interleaved in any per-video span.

For use_audio_in_video=True, each video placeholder is expanded into one local span containing only video/audio pad tokens, bounded by non-pad tokens such as audio_start/audio_end. Check each contiguous V/A span independently instead of requiring all V/A tokens in the whole sequence to form one global dense range; otherwise multi-video requests can be misclassified as non-interleaved because of the boundary tokens between videos.

get_omni_modality_masks(input_ids, multimodal_embeddings, is_multimodal, token_ids)

Position mask per modality in token_ids, restricted to is_multimodal.

Built from the batch placement the encoder gather attaches to each embedding. Without it, falls back to reading input_ids on the host; that read is deliberately not allow-listed so VLLM_GPU_SYNC_CHECK flags a lost placement.

may_interleave_audio_video(multimodal_embeddings)

Whether the batch may hold interleaved audio-in-video tokens.

Judged from the modality the encoder gather sets on each embedding, so it needs no host read of input_ids. Untagged embeddings count as possibly interleaved.

merge_interleaved_embeddings(inputs_embeds, multimodal_embeddings, is_video, is_audio, is_multimodal)

Merge embeddings for interleaved audio-in-video sequences.

When use_audio_in_video=True, video and audio tokens are interleaved in the token sequence, but embeddings are provided as separate contiguous tensors. This function scatters each modality by the modality attribute attached to each embedding tensor (set during encoder gather) and also supports image embeddings in the same interleaved request.

Parameters:

  • inputs_embeds

    (Tensor) –

    The input embeddings tensor to merge into.

  • multimodal_embeddings

    (MultiModalEmbeddings) –

    List of embedding tensors (video, audio, image).

  • is_video

    (Tensor) –

    Boolean mask for video token positions.

  • is_audio

    (Tensor) –

    Boolean mask for audio token positions.

  • is_multimodal

    (Tensor) –

    Boolean mask for all multimodal token positions.

Returns:

  • Tensor –

    The merged inputs_embeds tensor with multimodal embeddings scattered

  • Tensor –

    to their correct positions.

unpad_and_flat_audio_features(input_audio_features, audio_feature_lengths)

Unpad and flatten stacked or ragged per-audio features.