Repository navigation
Description
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 intovideo_token_idplaceholders (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
feat: add video input support for Gemma 4 Unified (gemma4_unified) (l…
fix(models): correct gemma sliding-window prefill beyond the window
fix(models): correct gemma sliding-window prefill beyond the window (#…
fix(cli): render Gemma 4 audio user turn after the prompt text (#798)
feat: add video input support for Gemma 4 Unified (gemma4_unified) (l…
fix(models): correct gemma sliding-window prefill beyond the window (l…
fix(cli): render Gemma 4 audio user turn after the prompt text (lablu…