Skip to content

vllm.model_executor.models.nemotron3_5_transcribe_audio

Audio tower of Nemotron-3.5-Transcribe.

A native port of the inference path of NeMo's AudioPerceptionModule with a ParallelExpertEncoder:

waveform -> log-mel -> Parallel Expert Encoder -> Linear -> decoder width

The Parallel Expert Encoder runs an ASR TransformerEncoder and a streaming Sortformer speaker encoder over the same mel features. Both run in windows of window_frames encoder frames with left and right context, and the speaker encoder carries a speaker cache and a FIFO between windows. Thresholded speaker activity is added to the normalized ASR states through a fixed sinusoidal kernel. Module names follow NeMo so the checkpoint loads by prefix.

Classes:

Functions:

  • align_frames –

    Pad with the last frame, or truncate, (B, T, S) to target_len frames.

  • downsample_preds –

    Average (B, T, S) probabilities over windows of factor frames.

  • normalize_per_feature –

    NeMo normalize_batch(x, seq_len, "per_feature") on (B, C, T) features.

AudioPreprocessor

Bases: Module

Holds the featurizer under NeMo's preprocessor.featurizer name.

FeatureStacking

Bases: Module

Stack factor consecutive frames and project them to the model width.

MelSpectrogram

Bases: Module

Log-mel features as NeMo FilterbankFeatures computes them at inference.

Dither is off and no normalization is applied; frames past each row's length are set to pad_value. The filterbank and window come from the checkpoint and are held in the model dtype, as in the reference, and are upcast to float32 for the computation.

MultiHeadAttention

Bases: Module

Methods:

  • forward –

    Attend within each row of the packed (N, d_model) frames.

forward(x, packed, cos, sin)

Attend within each row of the packed (N, d_model) frames.

Nemotron3_5TranscribeAudioTower

Bases: Module

Waveform to decoder-width embeddings: mel, Parallel Expert Encoder, Linear.

Methods:

  • encode –

    Encode each clip into its embeddings, returned in input order.

  • forward –

    Encode padded (B, N) float32 audio into one embedding tensor per row.

  • load_weights –

    Load NeMo perception.* tensors, named without the perception..

encode(signals, num_samples_cpu)

Encode each clip into its embeddings, returned in input order.

Every row of a batch runs every window of the batch's longest clip, so a clip is batched only with clips that span as many windows.

forward(audio, num_samples, num_samples_cpu)

Encode padded (B, N) float32 audio into one embedding tensor per row.

num_samples_cpu holds the lengths on the host, so the window bounds and the output lengths need no device-to-host copy.

load_weights(weights)

Load NeMo perception.* tensors, named without the perception..

PackedFrames dataclass

The valid frames of a padded (B, T) batch, packed row after row.

rows indexes the flattened batch and positions holds each frame's position in its row. cu_seqlens, max_seqlen and sequence_lengths are in the format of the attention backend.

ParallelExpertEncoder

Bases: Module

NeMo ParallelExpertEncoder online inference with a transformer ASR encoder.

forward takes unnormalized (B, C, T) mel features and returns the fused (B, d_model, T') states.

Attributes:

  • dtype (dtype) –

    The model dtype, which quantized layers' weights may not have.

dtype property

The model dtype, which quantized layers' weights may not have.

RotaryEmbedding

NeMo RotaryPositionalEncoding: NeoX rotation of the first rot_dim dims.

Angles are computed in float32 on the CPU and stored in the activation dtype before use, as the reference does, so rotations match bit for bit.

SortformerModules

Bases: Module

Speaker head and speaker cache of NeMo SortformerModules at inference.

Methods:

  • speaker_probs –

    Upsampled speaker probabilities, (B, T * upsample_factor, n_spk).

  • update –

    NeMo SortformerModules.streaming_update (synchronous).

_compress_spkcache(emb_seq, preds)

Keep the spkcache_len most informative frames, as NeMo does.

speaker_probs(hidden, lengths)

Upsampled speaker probabilities, (B, T * upsample_factor, n_spk).

update(state, chunk, preds, lc, rc)

NeMo SortformerModules.streaming_update (synchronous).

SortformerSpeakerEncoder

Bases: Module

Streaming inference of the high-resolution Sortformer in NeMo's PEE.

Mirrors SortformerEncLabelModel.forward_streaming_step for synchronous streaming without speaker permutation. Each step returns speaker probabilities on the encoder frame grid for the window's core frames.

Methods:

  • step –

    Process one window of (B, C, T) mel features.

step(features, lengths, state, left_offset, right_offset, lengths_cpu=None)

Process one window of (B, C, T) mel features.

Returns the new state and the core frames' speaker probabilities on the encoder grid.

SpeakerCacheState dataclass

Synchronous streaming state of the Sortformer speaker encoder.

TransformerEncoder

Bases: Module

NeMo TransformerEncoder with RoPE and full attention, at inference.

forward takes (B, C, T) mel features, or (B, T, d_model) pre-encoded embeddings with bypass_pre_encode=True, and returns (B, d_model, T') states with their lengths. Only each row's valid frames run through the layers, packed for variable-length attention; the padded positions of the output are zero. lengths_cpu, the lengths on the host, lets the packing skip a device-to-host copy.

Methods:

  • pack –

    Index each row's valid frames; rows without any are left out.

pack(lengths_cpu, num_frames, device)

Index each row's valid frames; rows without any are left out.

_TowerLinear

Bases: ReplicatedLinear

A replicated linear layer over the last dimension of any input shape.

vLLM's quantized kernels take (tokens, features); the tower's activations are (batch, frames, features).

_linear(in_features, out_features, *, bias, quant_config, prefix)

A linear layer the checkpoint's quantization config applies to by name.

align_frames(preds, target_len)

Pad with the last frame, or truncate, (B, T, S) to target_len frames.

downsample_preds(preds, factor)

Average (B, T, S) probabilities over windows of factor frames.

normalize_per_feature(x, seq_len)

NeMo normalize_batch(x, seq_len, "per_feature") on (B, C, T) features.