Skip to content

vllm.model_executor.models.radio

RADIO vision encoder, matching the RadioModel in the Transformers library.

The module tree mirrors the Transformers RadioModel (embeddings and an encoder.layer stack of norm1/attention/layer_scale1/norm2/ mlp/layer_scale2 blocks). The vLLM-specific deviations are the fused attention.qkv (a QKVParallelLinear for TP/quantization, vs the split query/key/value in HF) and running input normalization in the processor instead of an input_conditioner module; the attention backend and MLP reuse vLLM's MMEncoderAttention and InternMLP. load_weights maps both native Transformers and legacy remote-code checkpoint keys onto this tree via hf_to_vllm_mapper.

Classes:

  • RadioAttention –

    RADIO self-attention: a fused qkv projection feeding the vLLM

  • RadioLayer –

    RADIO transformer block, mirroring the Transformers RadioLayer

  • RadioLayerScale –

    LayerScale matching the Transformers RadioLayerScale: a lambda1

  • RadioModel –
  • RadioPatchEmbeddings –

    Cropped Position Embedding (CPE) patch generator, matching Transformers'

  • RadioVisionEncoder –

    RADIO encoder stack, mirroring the Transformers RadioEncoder module

Functions:

RadioAttention

Bases: Module

RADIO self-attention: a fused qkv projection feeding the vLLM attention backend, with optional QK-normalization and dynamic-resolution packed attention (via mask_meta). The fused counterpart of the Transformers RadioAttention (which keeps query/key/value and output.dense split); load_weights bridges the two.

RadioLayer

Bases: Module

RADIO transformer block, mirroring the Transformers RadioLayer (norm1 / attention / layer_scale1 / norm2 / mlp / layer_scale2). drop_path is an inference-time Identity; the MLP reuses InternMLP (fc1/fc2, matching RadioMLP).

RadioLayerScale

Bases: Module

LayerScale matching the Transformers RadioLayerScale: a lambda1 parameter scaling the residual branch.

RadioModel

Bases: Module

Methods:

  • load_weights –

    Load RADIO checkpoint weights, remapping legacy remote-code and

_inter_image_mask_metadata(imgs_sizes, device)

Build mask metadata from image pixel sizes. Adds num_skip to each sequence length (cls/register tokens) to match patch generator output.

_mask_metadata_from_seq_lens(seq_lens, device)

Build mask metadata from sequence lengths (already including cls/register tokens, i.e. patch_count + num_skip per item).

_pack_uniform_batch(hidden_states)

Pack [B, n, hidden] into [1, B*n, hidden] plus its varlen metadata.

FA/Triton synthesise this cu_seqlens anyway; TORCH_SDPA splits it per item.

load_weights(weights)

Load RADIO checkpoint weights, remapping legacy remote-code and native Transformers keys onto this module tree via hf_to_vllm_mapper.

RadioPatchEmbeddings

Bases: Module

Cropped Position Embedding (CPE) patch generator, matching Transformers' RadioPatchEmbeddings, with additional support for dynamic multi-resolution packing and video temporal compression.

Methods:

  • forward_video –

    Process video frames with temporal compression.

forward_video(x)

Process video frames with temporal compression.

Groups T consecutive frames into tubelets before embedding.

Parameters:

  • x

    (Tensor) –

    [num_frames, 3, H, W] tensor of video frames

Returns:

  • Tensor –

    Embedded patches with temporal compression applied.

RadioVisionEncoder

Bases: Module

RADIO encoder stack, mirroring the Transformers RadioEncoder module tree (a layer ModuleList of RadioLayer).

radio_config_from_args(args, *, image_size=224, patch_size=16, norm_mean=None, norm_std=None, video_temporal_patch_size=1)

Build a RadioConfig from the timm-style args of remote-code checkpoints.