Skip to content

feat(vlm): add LLaVA-OneVision image and video support - #3651

Merged
inureyes merged 6 commits into
mainfrom
feat/issue-2395
Dec 1, 2026
Merged

inureyes merged 6 commits into
mainfrom
feat/issue-2395

Conversation

@inureyes

@inureyes inureyes commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

Changes

  • Load LLaVA-OneVision's published and nested Hugging Face weight layouts, including the tied Qwen2 output embeddings on the 0.5B checkpoint.
  • Pack AnyRes image tiles and compute prompt token counts from their capped dimensions. Pool sampled video frames and append the learned separator once per clip.
  • Route images, multi-image prompts and video through the CLI and server. Add numerical packing and pooling tests, layout and activation tests, and prompt expansion coverage.

Verification

The 0.5B OV checkpoint ran on gfx1151 through the CLI and a local HTTP server. The focused suite passed all 31 tests, including the opt-in EOS regression against a real LLaVA 1.5 7B checkpoint. All 14 batched decode registry checks passed. The CLI exposed llava_onevision in its architecture listing. Formatting, environment documentation, compatibility manifest and MLX test guard checks passed.

On a 1536×1152 image, the Rust and mlx-vlm 0.8.1 runs expanded identical prompt token IDs and agreed on all 32 teacher-forced top tokens, including all nine positions with a reference gap of at least two. Removing the image downsample alone made the feature scatter fail with 9,558 rows for 7,309 placeholders. Removing the corresponding prompt cap as well produced 9,570 prompt tokens in the control versus 7,321 in the baseline, and changed one of 32 top tokens on that photograph.

On a 2304×2304 image containing seven rows of five-digit groups in 13 px DejaVu Sans Mono, the processor selected 37 tiles. With default downsampling the Rust trace matched the mlx-vlm expanded prompt and disagreed on 1/125 top tokens and 0/15 decided positions. Raising the cap to 100 patches disabled downsampling, increased the prompt length from 7,394 to 27,158, and produced 67/125 disagreements including 2/15 decided positions. Both Rust runs used the same weights, image, transcription prompt and teacher-forced targets.

Generation samples

Single image

CLI output

The image depicts two men in a sports setting, likely a football match given the blurred background that suggests a stadium filled with spectators. The man on the left is wearing a dark suit and appears to be in a state of intense emotion, possibly

HTTP output (48 completion tokens)

The image depicts two men in a sports setting, likely a football match given the blurred background that suggests a stadium filled with spectators. The man on the left is wearing a dark suit and appears to be in a state of intense emotion, possibly

Two images

CLI output

In the first photo, a bald man in a black suit is yelling at someone off-camera, while a man in a black suit points at something in the distance. The sign in the second photo reads "The Golden Crust Bakery."

HTTP output (47 completion tokens)

In the first photo, a bald man in a black suit is yelling at someone off-camera, while a man in a black suit points at something in the distance. The sign in the second photo reads "The Golden Crust Bakery."

Three-frame video

CLI output

The video captures a moment of intense emotion and focus, with the man in the black suit and tie passionately directing his attention towards the right side of the frame.

HTTP output (30 completion tokens)

The video captures a moment of intense focus and determination, with the man in the black suit passionately directing his attention towards the right side of the frame.

Real-checkpoint runs used the 0.5B OV weights and the ROCm backend. The low-optimization server test binary used a 32 MiB Rust worker stack.

Closes #2395

Normalize Hugging Face weight names and load the SigLIP tower, GELU projector, image separator and Qwen2 decoder. Use the packed AnyRes dimensions to expand image placeholders and pool sampled video frames before scattering media into the prompt.

Cover weight layouts, activation defaults, feature values, pooled clip boundaries, and interleaved media markers.

Refs #2395
@inureyes inureyes added status:review Under review type:enhancement New features, capabilities, or significant additions priority:medium Medium priority area:models Model architectures, weights, loading, metadata modelsize:small 4-bit checkpoint <= 10GB; fast iteration, safe for smoke tests modeltype:vlm Vision-language model arch:dense Dense transformer decoder labels Dec 1, 2026
# Conflicts:
#	src/models/batched_decode_coverage_tests.rs
# Conflicts:
#	src/models/detection_tests.rs
Record the exercised CLI and server media paths and the decided-token regression produced by disabling AnyRes downsampling on small text.
@inureyes inureyes added status:done Completed and removed status:review Under review labels Dec 1, 2026
@inureyes
inureyes marked this pull request as ready for review December 1, 2026 22:48
@inureyes
inureyes merged commit 2ec292f into main Dec 1, 2026
34 of 36 checks passed
@inureyes
inureyes deleted the feat/issue-2395 branch December 1, 2026 22:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arch:dense Dense transformer decoder area:models Model architectures, weights, loading, metadata modelsize:small 4-bit checkpoint <= 10GB; fast iteration, safe for smoke tests modeltype:vlm Vision-language model priority:medium Medium priority status:done Completed type:enhancement New features, capabilities, or significant additions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(vlm): add LLaVA-OneVision (llava_onevision) support

1 participant