Spaces:
Sleeping
Sleeping
File size: 12,627 Bytes
f5961bc | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 | # SmolVLA Architecture Diagrams
Reference diagrams for understanding the SmolVLA model structure and what
the `--model-health` report measures.
---
## 1. High-level data flow
```
Camera Images (512x512) Task String Robot State Noisy Actions
+--------+ +--------+ "pick up the (joint (from flow
| side | | up | red block" positions) matching)
+---+----+ +---+----+ | | |
| | | | |
v v v v v
+------------------+ +---------------+ +---------------+ +---------------+
| SigLIP Vision | | Tokenizer | | state_proj | | action_in_proj|
| Encoder | | | | (Linear) | | (Linear) |
| (frozen) | | | | | | + time MLP |
| 12L, 12H | | | | trainable | | trainable |
+--------+---------+ +-------+-------+ +-------+-------+ +-------+-------+
| | | |
1024 patches token embeds 1 token 10 tokens
| | | |
v | | |
+-------------------+ | | |
| Connector | | | |
| (pixel shuffle) | | | |
| trainable | | | |
+--------+----------+ | | |
| | | |
64 tokens | | |
| | | |
+-----------+-----------+ | |
| | |
v | |
+-----------------------+ | |
| PREFIX SEQUENCE | | |
| [vision] [language] +<--------------------+ |
| [state] | VLM dim (960) |
+-----------+-----------+ |
| |
| +-----------------+
| |
v v
+---------------------------------------------------+
| SmolVLMWithExpert (16 layers) |
| |
| PREFIX -------------------> VLM Text Model |
| (vision+lang+state) (frozen) |
| 960-dim, 15 heads |
| |
| SUFFIX -------------------> Action Expert |
| (noisy actions+time) (trainable) |
| 480-dim, 8 heads |
| |
| (see attention diagrams below) |
+--------------------------+--------------------------|
|
| Expert output (last 10 tokens)
v
+-------------------+
| action_out_proj |
| (Linear) |
| trainable |
+---------+---------+
|
v
Predicted Actions
(10 steps x 6 DOF)
```
---
## 2. The three attention components
These are the three distinct attention operations that the health report
measures for entropy and head redundancy.
### A. SigLIP Vision (12 layers, 12 heads)
Standard self-attention inside the vision encoder. Happens before anything
enters SmolVLMWithExpert. Image patches attend to other image patches.
```
patch_1 patch_2 patch_3 ... patch_1024
| | | |
v v v v
+----------------------------------------------+
| SigLIP Self-Attention |
| |
| Each patch can see all patches. |
| |
| Q <-- patches K <-- patches |
| (1024 x 1024 attention matrix) |
+----------------------------------------------+
Report label: "SigLIP Vision (12L, 12H)"
```
### B. VLM+Expert Joint Self-Attention (16 layers, 15 heads)
Runs during prefill (initial encoding). VLM and Expert tokens are
concatenated into one sequence and attend to each other in a single
attention call.
```
VLM tokens (prefix) Expert tokens (suffix)
[vision][lang][state] [action+time]
| |
v v
+-------------+ +-------------+
| VLM layer | | Expert layer|
| q/k/v proj | | q/k/v proj |
+------+------+ +------+------+
| |
+-------------+---------------+
|
v
torch.cat(dim=seq)
|
v
+----------------------------------------------+
| JOINT Self-Attention |
| |
| All tokens see all tokens: |
| vision <--> vision |
| vision <--> language |
| vision <--> action |
| action <--> language |
| action <--> action |
| ... etc |
| |
| Q <-- [VLM+Expert] K <-- [VLM+Expert] |
| Q_len == K_len (self-attention) |
+----------------------------------------------+
Report label: "VLM+Expert Joint Self-Attn (16L, 15H)"
```
### C. Expert-to-VLM Cross-Attention (16 layers, 8 heads)
Runs during generation (autoregressive action decoding). The Expert
generates queries from its own hidden states, but keys and values come
from the VLM's cached representations, re-projected through the Expert's
k_proj and v_proj. Repeats 10 times (one per action token).
```
VLM KV Cache Expert hidden states
(built during prefill) (current action token)
| |
| v
| +---------------+
| | Expert q_proj |
| +-------+-------+
| |
| re-projected through |
| Expert k_proj / v_proj |
v |
+-------------+ |
| Expert K, V |<-- VLM cache |
| (from VLM) | re-projected |
+------+------+ |
| |
+---------------+-------------------+
|
v
+----------------------------------------------+
| CROSS-Attention |
| |
| Expert reads VLM: |
| action --> vision (what to grab?) |
| action --> language (what was asked?) |
| action --> state (current pose?) |
| |
| VLM does NOT read Expert here. |
| |
| Q <-- Expert tokens (few) |
| K <-- VLM prefix (many) |
| Q_len != K_len (cross-attention) |
+----------------------------------------------+
Report label: "Expert-to-VLM Cross-Attn (16L, 8H)"
```
---
## 3. Execution timeline
```
IMAGE ENCODING PREFILL GENERATION
+--------------+ +------------------+ +------+------+ +------+
| SigLIP | | Joint Self-Attn | | XA | XA | | XA |
| 12 layers +--->| 16 layers +--->| #1 | #2 |...>| #10 |
| (A) | | (B) | | | | | |
+--------------+ +------------------+ +------+------+ +------+
<--- 10 action steps --->
Report: Report: Report:
"SigLIP Vision" "VLM+Expert "Expert-to-VLM
Joint Self-Attn" Cross-Attn"
12L x 12H 16L x 15H 16L x 8H
(x10 steps, averaged)
```
---
## 4. What the health report measures
### Section 1: Weight Spectral Analysis (alpha)
Analyzes weight matrices directly (no data needed). Each transformer layer
contains multiple weight matrices (q_proj, k_proj, v_proj, o_proj,
gate_proj, up_proj, down_proj). A power-law is fit to each matrix's
singular values; the exponent (alpha) indicates training quality.
```
+----------------------------------+-------------+---------------------+
| Component | Wt Matrices | What it is |
+----------------------------------+-------------+---------------------+
| Expert (trainable) | 112 = 16x7 | Action decoder |
| VLM Text Model (frozen) | 113 = 16x7+ | Language model |
| Vision Encoder (frozen) | 74 = 12x~6 | SigLIP |
| Connector (trainable) | 1 | Pixel shuffle |
| Projections (trainable) | too small | state/action linear |
+----------------------------------+-------------+---------------------+
Healthy: alpha 2-4 Undertrained: 4-6 Severe: >6
```
### Section 2: Attention Entropy
Requires a forward pass with real data. Measures how spread out each
attention head's focus is (normalized by log of sequence length).
```
Collapsed: <0.10 Healthy: 0.10-0.80 Unfocused: >0.80 Dead: >0.95
```
### Section 3: Head Redundancy
Same forward pass data. Measures pairwise cosine similarity between
flattened head attention patterns within each layer. Heads should learn
different patterns.
```
Diverse: <0.70 High redundancy: >0.70 Collapsed: >0.90
```
---
## 5. Trainable vs frozen components
```
FROZEN (pretrained, not updated during fine-tuning)
+----------------------------------------------------+
| SigLIP Vision Encoder |
| 12 layers, 12 heads, 74 weight matrices |
+----------------------------------------------------+
| VLM Text Model (SmolLM2) |
| 16 layers, 15 heads, 113 weight matrices |
+----------------------------------------------------+
TRAINABLE (learned during fine-tuning)
+----------------------------------------------------+
| Action Expert |
| 16 layers, 8 heads, 112 weight matrices |
+----------------------------------------------------+
| Connector (pixel shuffle) |
| 1 weight matrix |
+----------------------------------------------------+
| state_proj, action_in_proj, action_out_proj |
| (too small for spectral analysis) |
+----------------------------------------------------+
```
|