Commit 2b1f539
committed
Support gemma-4-12B unified (encoder-free) multimodal model
The gemma-4-12B "unified" variant is encoder-free: it consumes raw 48px
merged pixel patches (patch_dim 6912) and raw 640-sample waveform frames
directly, rather than the SigLIP image / Conformer log-mel audio contract
of the standard gemma-4 (E2B/E4B) model.
Register "gemma4_unified" as an MMM model type and route it to
Gemma4MultiModalProcessor with a unified flag that adjusts two things:
* Vision: no pixel-value trimming. The unified vision graph strips
padding patches internally (position == -1), so the full padded
(max_soft_tokens, 6912) pixel_values and position_ids are fed as-is
instead of being trimmed to actual_soft_tokens * pooling^2.
* Audio: each 640-sample frame is exactly one audio soft token, so the
audio-token count equals the number of frames (no Conv2d stride-2
subsampling as in the Conformer speech encoder).
Everything else (prompt image/audio token expansion, embedding fusion,
per-layer-input decoder wiring) is shared with the standard gemma4 path.
The paired preprocessing ops live in onnxruntime-extensions
(Gemma4ImageTransform at patch_size=48/pooling=1, Gemma4UnifiedAudioFrames).
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>1 parent 3c4b66e commit 2b1f539
4 files changed
Lines changed: 25 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
170 | 178 | | |
171 | 179 | | |
172 | 180 | | |
| |||
285 | 293 | | |
286 | 294 | | |
287 | 295 | | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
292 | 308 | | |
293 | 309 | | |
294 | 310 | | |
| |||
320 | 336 | | |
321 | 337 | | |
322 | 338 | | |
323 | | - | |
| 339 | + | |
324 | 340 | | |
325 | 341 | | |
326 | 342 | | |
| |||
365 | 381 | | |
366 | 382 | | |
367 | 383 | | |
368 | | - | |
| 384 | + | |
369 | 385 | | |
370 | 386 | | |
371 | 387 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
974 | 974 | | |
975 | 975 | | |
976 | 976 | | |
| 977 | + | |
977 | 978 | | |
978 | 979 | | |
979 | 980 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
| 66 | + | |
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| |||
0 commit comments