Skip to content

feat: video input support for Gemma 4 Unified (gemma4_unified) #164

Closed

Description

@inureyes

Add video input support to the Gemma 4 Unified (gemma4_unified) runtime. The architecture (added in #151 / #153) supports text + image + audio, but video input is gated behind an explicit "not yet supported" error and was an intentional deferral.

Current state

src/server/model_worker.rs:947 rejects video for gemma4_unified:

"video input is not yet supported for gemma4_unified models; ..."

The model config already carries the video plumbing: video_token_id (258884), vision_soft_tokens_per_video_frame (70). The encoder-free vision embedder and the image path already exist; video is "images per frame" with video_token_id placeholders.

Goal

Accept --video (and the server's video content parts) for gemma4_unified: extract frames (uniform FPS resample via ffmpeg, as the existing VLM video path does), patchify each frame through the existing encoder-free vision embedder, and scatter the per-frame soft tokens into video_token_id placeholder spans.

Touchpoints

  • src/vision/processors/gemma4_unified.rs — frame extraction + per-frame patchify (reuse the image patchify; vision_soft_tokens_per_video_frame).
  • src/vision/gemma4_unified.rs — get_video_features / merge into video_token_id placeholders (mirror the image scatter).
  • src/commands/generate_vlm.rs / src/server/model_worker.rs — remove the gate, wire the video input path.
  • Reuse the bidirectional blockwise mask over image/video spans (video tokens are type 2).

Acceptance criteria

  • mlxcel generate -m mlx-community/gemma-4-12b-it-4bit --video clip.mp4 -p "Describe this video." produces a coherent, grounded description.
  • Text / image / audio / image+audio paths are unaffected.
  • Server video content parts work through /v1/chat/completions.
  • Frame-extraction FPS matches the existing VLM video convention (default 2.0 fps).

Activity

  1. added
    type:enhancement
    priority:medium
    area:models
    on Jun 5, 2026
  2. added this to the 0.4 milestone on Jun 21, 2026
  3. added
    status:in-progress
    status:review
    status:done
    and removed
    status:in-progress
    status:review
    on Jun 22, 2026
  4. added a commit that references this issue on Jun 23, 2026
    d35ef06
  5. self-assigned this
    on Aug 31, 2026
  6. added 3 commits that reference this issue on Oct 27, 2026
    bdbfeb7
    d2242d4
    5477468
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:modelspriority:mediumstatus:donetype:enhancement

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions