Skip to content

vllm.model_executor.models.glmasr

Classes:

GlmAsrDummyInputsBuilder

Bases: BaseDummyInputsBuilder[GlmAsrProcessingInfo]

Builder for dummy inputs used in profiling and testing.

Generates dummy text prompts and audio data that match the expected format for GLM-ASR model inputs. Used for memory profiling and performance benchmarking.

GlmAsrEmbeddingInputs

Bases: TensorSchema

Dimensions: - bn: Batch size - naf: Number of audio features - hs: Hidden size (must match the hidden size of language model backbone)

GlmAsrEncoder

Bases: Module

Optimized GLM-ASR Audio Encoder with vLLM native implementation.

This encoder processes audio features through convolutional layers followed by transformer layers with rotary position embeddings. Optimized for performance with: - QKVParallelLinear for fused attention projections - Tensor parallelism support via ColumnParallelLinear/RowParallelLinear - Quantization support - Flash Attention (SDPA)

Methods:

  • forward –

    Forward pass through the encoder.

_get_feat_extract_output_lengths(input_lengths)

Compute the output length after convolutions.

Parameters:

  • input_lengths

    (Tensor) –

    Input sequence lengths [batch_size]

Returns:

forward(input_features)

Forward pass through the encoder.

Parameters:

  • input_features

    (Tensor) –

    [batch_size, num_mel_bins, seq_len]

Returns:

  • _GlmAsrEncoderOutput ( _GlmAsrEncoderOutput ) –

    Object with .last_hidden_state attribute containing [batch_size, seq_len', hidden_size] where seq_len' is the sequence length after convolutions

GlmAsrEncoderAttention

Bases: Module

Optimized Multi-headed Grouped Query Attention for GLM-ASR encoder.

Uses vLLM's QKVParallelLinear for fused projections, ApplyRotaryEmb for rotary position embeddings, and MMEncoderAttention for hardware-optimized attention computation with automatic backend selection.

Methods:

forward(hidden_states, rotary_pos_emb_cos, rotary_pos_emb_sin)

Parameters:

  • hidden_states

    (Tensor) –

    [batch_size, seq_len, hidden_size]

  • rotary_pos_emb_cos

    (Tensor) –

    [seq_len, rotary_dim/2] - cosine of rotary embeddings

  • rotary_pos_emb_sin

    (Tensor) –

    [seq_len, rotary_dim/2] - sine of rotary embeddings

Returns:

  • Tensor –

    [batch_size, seq_len, hidden_size]

GlmAsrEncoderLayer

Bases: Module

Optimized Transformer encoder layer for GLM-ASR. Combines attention and MLP with residual connections and layer norms.

Methods:

forward(hidden_states, rotary_pos_emb_cos, rotary_pos_emb_sin)

Parameters:

  • hidden_states

    (Tensor) –

    [batch_size, seq_len, hidden_size]

  • rotary_pos_emb_cos

    (Tensor) –

    [seq_len, rotary_dim/2] - cosine of rotary embeddings

  • rotary_pos_emb_sin

    (Tensor) –

    [seq_len, rotary_dim/2] - sine of rotary embeddings

Returns:

  • Tensor –

    [batch_size, seq_len, hidden_size]

GlmAsrEncoderMLP

Bases: Module

Optimized MLP for GLM-ASR encoder. Uses vLLM's parallel linear layers for better performance.

GlmAsrEncoderRotaryEmbedding

Bases: Module

Rotary Position Embedding for GLM-ASR encoder.

Computes rotary position embeddings on-demand for efficiency. Only caches inv_freq as a buffer; cos/sin are computed during forward to avoid wasted computation during initialization and ensure correct device placement.

Methods:

  • forward –

    Compute rotary position frequencies for given sequence length.

forward(seq_len)

Compute rotary position frequencies for given sequence length.

Parameters:

  • seq_len

    (int) –

    The sequence length to compute embeddings for.

Returns:

  • Tensor –

    Frequency tensor with shape [seq_len, dim/2]. Use .cos() and

  • Tensor –

    .sin() to get the rotary embedding components.

GlmAsrFeatureInputs

Bases: TensorSchema

Dimensions: - num_chunks: Number of audio chunks (flattened) - nmb: Number of mel bins - num_audios: Number of original audio files

GlmAsrForConditionalGeneration

Bases: Module, SupportsMultiModal, SupportsPP, SupportsLoRA, SupportsTranscription

Methods:

_get_audio_token(model_config) classmethod

Get the audio token from processor.

Similar to get_placeholder_str but returns single token.

get_generation_prompt(stt_params) classmethod

Get the generation prompt to be used for transcription requests.

GlmAsrMultiModalDataParser

Bases: MultiModalDataParser

Custom parser for GLM-ASR multimodal data.

Extends the base parser to handle GLM-ASR specific audio data formats, including both pre-computed audio embeddings and raw audio features.

GlmAsrMultiModalProcessor

Bases: BaseMultiModalProcessor['GlmAsrProcessingInfo']

GLM-ASR processor that inherits directly from BaseMultiModalProcessor for better performance and cleaner implementation.

GlmAsrMultiModalProjector

Bases: Module

Projects audio encoder outputs to language model hidden space.

This projector uses a two-layer MLP to map audio features from the encoder's intermediate size to the language model's hidden size. Uses vLLM's parallel linear layers for tensor parallelism support.

Architecture
  • Linear layer: intermediate_size -> hidden_size * 2
  • Activation function (e.g., GELU)
  • Linear layer: hidden_size * 2 -> hidden_size

GlmAsrProcessingInfo

Bases: BaseProcessingInfo

Processing information provider for GLM-ASR model.

Provides access to model configuration, processor, and feature extractor needed for audio preprocessing and multimodal integration.

_GlmAsrEncoderOutput

Simple output container compatible with transformers' BaseModelOutput.

This lightweight container holds the encoder output and is compatible with the transformers library's output format while being more efficient than a full dataclass.

Attributes:

  • last_hidden_state –

    Final layer hidden states from the encoder. Shape: [batch_size, seq_len, hidden_size]

_glmasr_field_config(hf_inputs)

Configure multimodal field batching strategy for GLM-ASR.

Determines how to batch audio inputs based on whether chunking is used. When chunk_counts is present, features are flattened across chunks; otherwise, they are batched normally.

Parameters:

  • hf_inputs

    (Mapping[str, Tensor]) –

    Dictionary of preprocessed inputs from HuggingFace processor.

Returns: