vllm.model_executor.models.gemma4_unified ¶
Gemma 4 Unified multimodal model (encoder-free image + audio + video).
The Unified Gemma4 variant has no SigLIP vision tower and no audio tower. Raw pixel patches are projected directly to LM space via a Dense+LayerNorm pipeline with factorized 2D positional embeddings (Gemma4UnifiedVisionEmbedder), then routed through the same Gemma4MultimodalEmbedder used by the tower-based variant. Audio inputs are raw waveform frames projected directly through the multimodal embedder.
This module subclasses Gemma4ForConditionalGeneration from gemma4_mm rather than reimplementing it from scratch. Only the multimodal pipeline differs; the language model, MTP integration, bidirectional attention helpers, embedding/forward path, and LoRA support are all inherited unchanged.
Gemma4ImagePixelInputs ¶
Bases: TensorSchema
Pre-patchified image inputs from the Gemma4 image processor.
Dimensions
- bn: Batch size * number of images
- np: Number of patches (max_patches = max_soft_tokens * pooling_kernel_size²)
- pp: Patch pixels (patch_size² * 3)
The Gemma4 image processor outputs pixel_values as (batch, max_patches, patch_pixels) — already patchified with zero-padding for patches beyond the real image content. pixel_position_ids provides (x, y) coordinates per patch, with (-1, -1) for padding patches.
Source code in vllm/model_executor/models/gemma4_mm.py
Gemma4UnifiedForConditionalGeneration ¶
Bases: Gemma4ForConditionalGeneration
Encoder-free Gemma4 (Unified) for conditional generation.
Inherits multimodal embedding routing, PLE handling, bidirectional attention helpers, language-model forward, LoRA, and pipeline-parallel support from :class:Gemma4ForConditionalGeneration. Overrides only:
__init__— builds the encoder-free vision embedder instead of SigLIP/audio towers (LightOnOCR-style:nn.Module.__init__+ full rebuild, nosuper().__init__()).hf_to_vllm_mapper— adds themodel.vision_embedder.prefix._process_image_input/_process_video_input/_process_audio_input— encoder-free projection paths.load_weights— ignore-prefix list excludes the absent towers.get_mm_mapping— no tower entries.
Source code in vllm/model_executor/models/gemma4_unified.py
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 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 | |
_process_audio_input ¶
_process_audio_input(
audio_input: Gemma4AudioInputs,
) -> list[Tensor]
Project raw waveform-frame features directly to LM space.
No audio tower: the per-frame raw features are passed straight through the multimodal embedder, then padding is stripped.
Source code in vllm/model_executor/models/gemma4_unified.py
_process_image_input ¶
Project raw image patches directly to LM space.
No vision tower: each image's pre-patchified pixel values are embedded via Gemma4UnifiedVisionEmbedder, projected through Gemma4MultimodalEmbedder, and padding patches (pp == -1) are stripped per image.
Source code in vllm/model_executor/models/gemma4_unified.py
_process_video_input ¶
Project video frames to LM space, one frame at a time.
Frames are split per video, each frame is embedded + projected, and per-frame valid embeddings are concatenated per video.
Source code in vllm/model_executor/models/gemma4_unified.py
get_mm_mapping ¶
Module prefix mapping for the encoder-free model (no towers).
Source code in vllm/model_executor/models/gemma4_unified.py
Gemma4UnifiedProcessingInfo ¶
Bases: Gemma4ProcessingInfo
ProcessingInfo for the Gemma4 Unified variant.
Two field-name differences from the tower-based parent
- config →
Gemma4UnifiedConfig(notGemma4Config) - vision_config.
num_soft_tokens(notdefault_output_length)
Everything else (token sequencing, audio limits, video frame budget, parser construction) is inherited unchanged.
Source code in vllm/model_executor/models/gemma4_unified.py
Gemma4UnifiedVisionEmbedder ¶
Bases: Module
Encoder-free vision embedder for Gemma4 Unified variants.
Projects raw pixel patches to LM space via dense projection and factorized 2D positional embeddings. Replaces the SigLIP vision tower used by the tower-based Gemma4 variant.
Pipeline: raw patches → LN₁ → Dense → LN₂ → +factorized_posemb → LN₃.