Skip to content

vllm.model_executor.models.qwen3_omni_moe_thinker

Inference-only Qwen3-Omni-Moe model (thinker part).

Classes:

Qwen3OmniMoeAudioAttention

Bases: Module

Multi-headed attention for Qwen3-Omni Audio Encoder using MMEncoderAttention.

Qwen3OmniMoeAudioEncoder

Bases: Module

vLLM-native Qwen3-Omni Audio Encoder.

Methods:

_get_cnn_output_lengths(input_lengths)

Compute output lengths after the three conv2d layers.

embed_audio_features(input_features, feature_lens)

Run the conv frontend and return the packed encoder tokens.

Parameters:

  • input_features

    (Tensor) –

    Mel features [num_mel_bins, total_frames] on device.

  • feature_lens

    (Tensor) –

    Per-item frame counts, on the host.

forward(input_features, feature_lens, aftercnn_lens)

Encode a flattened batch of audio features.

Parameters:

  • input_features

    (Tensor) –

    Mel features [num_mel_bins, total_frames] on device.

  • feature_lens

    (Tensor) –

    Per-item frame counts, on the host.

  • aftercnn_lens

    (Tensor) –

    Per-item encoder output lengths, on the host.

forward_transformer(hidden_states, encoder_metadata)

Run the transformer layers and output projection on packed tokens.

Takes only fixed-shape tensors, so it can be captured in a CUDA graph.

prepare_encoder_metadata(aftercnn_lens, *, max_num_windows=None, max_seqlen_override=None, device=None)

Compute the windowed-attention metadata from encoder output lengths.

Shared by the eager forward path, CUDA graph capture, and CUDA graph replay.

Parameters:

  • aftercnn_lens

    (Sequence[int]) –

    Per-item encoder output lengths.

  • max_num_windows

    (int | None, default: None ) –

    If set, pad cu_seqlens with empty windows to this many windows (needed for CUDA graph capture).

  • max_seqlen_override

    (int | None, default: None ) –

    If set, use this value for max_seqlen instead of the longest window (needed for CUDA graph capture to cover any replay).

  • device

    (device | None, default: None ) –

    Device to place cu_seqlens on. Defaults to self.device.

Qwen3OmniMoeAudioEncoderCudaGraphMixin

Bases: SupportsEncoderCudaGraph

Encoder CUDA graph support for the Qwen3-Omni audio tower.

Hosts provide audio_tower (a Qwen3OmniMoeAudioEncoder), config with an audio_config, and _parse_and_validate_audio_input(). Shared by Qwen3-Omni and Qwen3-ASR, which use the same audio tower.

The graph covers the transformer layers and the output projection. The conv frontend runs eagerly while the replay buffers are prepared: it is a few large kernels, and its activations grow with the number of mel chunks, so capturing it would pin a large private graph pool.

Qwen3OmniMoeAudioEncoderLayer

Bases: Module

Transformer encoder layer for Qwen3-Omni Audio Encoder.

Methods:

forward(hidden_states, cu_seqlens, max_seqlen, sequence_lengths=None)

Args: hidden_states: Input tensor of shape (seq_len, hidden_size) cu_seqlens: Cumulative sequence lengths max_seqlen: Maximum sequence length in the batch

Qwen3OmniMoeThinkerForConditionalGeneration

Bases: Module, SupportsMultiModal, SupportsLoRA, SupportsPP, SupportsMRoPE, SupportsEagle3, Qwen3OmniMoeConditionalGenerationMixin, SupportsTranscription, Qwen3OmniMoeAudioEncoderCudaGraphMixin

Methods:

_compute_audio_token_count(audio_feature_length)

Compute audio tokens from feature length using Qwen3-Omni formula.

_compute_interleaved_positions(start_idx, data)

Compute positions for interleaved video+audio using Qwen3 token-by-token interleaving logic.

Returns: (position_ids [3, N], 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. 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_generation_prompt(stt_params) classmethod

Construct a transcription/translation prompt for Qwen3-Omni.

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.

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"}

Qwen3OmniMoeThinkerMultiModalProcessor

Bases: Qwen2_5OmniThinkerMultiModalProcessor[_I]

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

Qwen3-Omni reimplements this function to handle use_audio_in_video.

SinusoidsPositionEmbedding

Bases: Module

Sinusoidal position embedding for audio encoder.