What is cross-modal attention?
Attention is the mechanism by which a transformer decides which parts of its input to focus on when computing each output token. In single-modality transformers (e.g., a language model), this is self-attention: every token attends to every other token in the same sequence.
Cross-modal attention extends this to multiple input sequences from different modalities. In cross-attention, the query (Q) comes from one modality while the key (K) and value (V) come from another. The result is a weighted sum of values from the source modality, where the weights are determined by the similarity between the target query and the source keys.
Self-attention vs cross-attention
In self-attention, all of Q, K, V come from the same sequence. A language token attending to other language tokens is self-attention — it helps the model understand syntax and coreference within the instruction.
In cross-attention, Q comes from sequence A while K and V come from sequence B. An action token querying the image token sequence is cross-attention — the action is asking the image: “what visual features are relevant to what I need to do next?” This is how language instructions get “grounded” in visual perception.
Both types appear in VLA models. pi0.5 uses the LLM’s native attention to mix vision and language tokens. UnifoLM-VLA’s DiT explicitly alternates: even layers = cross-attention (action → vision/text), odd layers = self-attention (within state/future/action tokens).
DiT architecture in UnifoLM-VLA
The Diffusion Transformer (DiT) in UnifoLM-VLA is the action expert network. It receives the current noisy action tokens and denoises them conditioned on the visual and language context from the language model backbone.
Layer structure:
- Even layers (0, 2, 4, ...) — cross-attention mode. The action tokens serve as queries; image patch tokens and task text tokens serve as keys and values. This is where the action “reads” what the robot can see and what it has been asked to do.
- Odd layers (1, 3, 5, ...) — self-attention mode. Attention is computed within the concatenated sequence of state tokens, future tokens, and action tokens. The VLAExplain tool reports both token-level attention and module-level attention intensity (total intensity = sum of weights, reflecting overall distribution; mean intensity = average weight per token, eliminating dimensional differences).
Attention patterns across layers
VLAExplain reveals distinct patterns at different layers for both models:
- In early layers, action tokens attend primarily to visual patches — the model first establishes “where things are” in the scene.
- In middle layers, attention shifts toward language tokens — the model starts connecting visual features to the task instruction.
- In later layers, self-attention within the action sequence dominates — the model refines the action trajectory by considering how successive actions relate to each other.
These patterns are what the interactive attention matrix above lets you explore. The “Layer” slider simulates moving from early (vision-dominant) to late (action-refinement) layers.
Cross-modal attention in the language model
Both pi0.5 and UnifoLM-VLA also expose cross-modal attention within the language model backbone — the part that processes vision and language together before the action expert takes over.
VLAExplain analyses: text → image (which image patches does a text token attend to?), image → text (which text tokens does an image patch attend to?), and in pi0.5 additionally: text → state, image → state, state → text, state → image. Patterns here reflect how the language model “grounds” the instruction in the visual context.
ActionCode attribution vs cross-modal attention
It is important to distinguish these two analysis types in VLAExplain:
- ActionCode attribution — focuses on the action tokens specifically. For a given action token, it shows how much attention that token places on each input modality (image, text, state, future actions). This is a per-action interpretability view.
- Cross-modal attention — analyses the full attention matrix across all modality pairs, not just from the action. This reveals how every modality attends to every other modality across all layers.
Together they provide complementary views: ActionCode answers “what drove this specific action?” while cross-modal attention answers “how does information flow throughout the model?”
Why interpretability matters
Understanding cross-modal attention patterns has practical consequences for robot safety and debugging:
- If a robot fails to grasp an object, checking whether the action tokens attended to the correct visual region reveals whether the failure was perceptual (attended to the wrong patch) or motor (attended correctly but produced a bad action).
- If a language instruction changes but the attention pattern does not, the model may be ignoring the instruction — a dangerous failure mode in a physical environment.
- Attention anomalies (e.g., action attending entirely to language with no vision signal) can indicate distribution shift between training and deployment.
VLAExplain visualisation features
The VLAExplain Gradio app supports the following controls for cross-modal attention analysis in both pi0.5 and UnifoLM-VLA: step selector (choose which action step to inspect), layer index (examine attention at any transformer layer), head number (inspect individual attention heads), normalization method, interpolation method, color map selection, and opacity control.
For pi0.5, all modality combinations (text → image, image → text, text → state, etc.) are supported. For UnifoLM-VLA, text → image and image → text are supported in the language model; in the DiT action expert, cross-attention (action → vision/text) and self-attention (state, future tokens, actions) are both available.
Recap
- Cross-attention: Q from modality A, K/V from modality B — one modality reading another.
- Self-attention: Q, K, V all from the same modality — within-modality reasoning.
- UnifoLM-VLA DiT alternates: even layers = cross-attention (action → vision/text), odd layers = self-attention (state/future/action).
- ActionCode attribution = per-action view; cross-modal attention = full model information flow.
- VLAExplain supports step, layer, head, normalization, interpolation, colormap, and opacity controls.