interleaved_vlm
interleaved_vlm
¶
Base decoder for interleaved (vision-language-model(VLM), action-expert) architectures, like pi0 and SmolVLA.
InterleavedLayerType
¶
Bases: StrEnum
Layer routing types for interleaved VLM/action-expert decoders.
InterleavedVLMAttentionState
dataclass
¶
InterleavedVLMAttentionState(attention_mask, key_padding_mask, vlm_prefix_attention_mask, position_ids, expert_position_ids, expert_action_rope, prefix_token_count, action_token_count)
Masks, positions, and RoPE tensors shared by interleaved VLA decoders.
Attributes:
| Name | Type | Description |
|---|---|---|
attention_mask |
Tensor
|
Expert-first attention mask with shape
|
key_padding_mask |
Tensor
|
Key padding mask in original prefix-first order with
shape |
vlm_prefix_attention_mask |
Tensor | None
|
Additive (huggingface convention) VLM self-attention mask with shape
|
position_ids |
Tensor
|
Prefix-first position ids with shape
|
expert_position_ids |
Tensor
|
Action expert position ids with shape
|
expert_action_rope |
tuple[Tensor, Tensor]
|
Rotary embeddings for action expert tokens. |
prefix_token_count |
int
|
Number of prefix tokens. |
action_token_count |
int
|
Number of action expert tokens. |
BaseInterleavedVLMDecoder
¶
BaseInterleavedVLMDecoder(input_keys, action_space, action_heads, observation_space, observation_horizon, prediction_horizon, device, vlm_backbone, requires_actions=True)
Bases: VLMBackboneDecoderMixin, ActionDecoder, ABC
Base class for VLA decoders with interleaved VLM and action expert layers.
Initialize decoder input wiring for a configured VLM backbone.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_keys
|
list[str]
|
Encoded feature keys consumed by the action expert,
excluding the raw observation keys consumed by |
required |
action_space
|
ActionSpace
|
Task action-space metadata. |
required |
action_heads
|
dict[str, ActionHead]
|
Exactly one joint action head mapping expert tokens to the full continuous action vector. |
required |
observation_space
|
ObservationSpace
|
Task observation-space metadata. |
required |
observation_horizon
|
int
|
Number of observation timesteps in each sample. |
required |
prediction_horizon
|
int
|
Number of action timesteps predicted per sample. |
required |
device
|
str
|
Device used by decoder modules. |
required |
vlm_backbone
|
GenerativeVLM
|
VLM backbone that consumes normalized/tokenized
observations and emits prefix embeddings with shape
|
required |
requires_actions
|
bool
|
Whether the decoder forward pass requires ground-truth actions. |
True
|
Source code in src/versatil/models/decoding/decoders/interleaved_vlm.py
encoder_cache_enabled
property
¶
Whether VLM prefix caching is currently enabled.
enable_encoder_cache
¶
Enable reusable VLM prefix caching for inference.
Source code in src/versatil/models/decoding/decoders/interleaved_vlm.py
disable_encoder_cache
¶
Disable reusable VLM prefix caching and clear stored cache.
Source code in src/versatil/models/decoding/decoders/interleaved_vlm.py
set_encoder_cache_suppressed
¶
Freeze or unfreeze the cache toggles during attribution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
suppressed
|
bool
|
While True, enable/disable calls are ignored. |
required |
Source code in src/versatil/models/decoding/decoders/interleaved_vlm.py
set_vlm_backbone
¶
Attach a VLM backbone and initialize architecture-specific layers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vlm_backbone
|
GenerativeVLM
|
VLM backbone exposing transformer layers, RoPE, text
config, hidden size, and a prefix builder returning embeddings
with shape |
required |
Source code in src/versatil/models/decoding/decoders/interleaved_vlm.py
build_action_expert
abstractmethod
¶
Build decoder-specific action expert layers from VLM internals.
Note
This is called by BaseInterleavedVLMDecoder.set_vlm_backbone()
after the full VLM backbone is attached.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vlm_layers
|
ModuleList
|
Transformer layers copied or referenced by the decoder. |
required |
rotary_emb
|
Module
|
Rotary embedding module used by the VLM layers. |
required |
vlm_hidden_dimension
|
int
|
Hidden dimension of VLM prefix tokens. |
required |
vlm_text_config
|
PretrainedConfig
|
HuggingFace text config for the VLM language tower. |
required |