Skip to content

feat(models): add Molmo v1 (molmo-7b) VLM architecture - #41

Merged
inureyes merged 1 commit into
mainfrom
feat/molmo-vlm
May 20, 2026
Merged

inureyes merged 1 commit into
mainfrom
feat/molmo-vlm

Conversation

@inureyes

Copy link
Copy Markdown
Member

Summary

Adds the Molmo v1 vision-language model (molmo-7b) to mlxcel. The architecture pairs a CLIP-style ViT image encoder with attention pooling and a connector into an OLMo-style text decoder, loaded through the VLM special path. The multi-crop image processor emits pixel values, per-crop masks, and the image_input_idx mapping; the VLM runtime expands the <im_patch> placeholders and additively scatters the pooled image features onto the text embeddings at the named positions before the forward pass.

What's included

  • Vision + text stacks: vision/encoders/molmo.rs (CLIP ViT + attention pooling), vision/molmo_vl.rs (additive-scatter merge keyed by image_input_idx), vision/processors/molmo.rs (multi-crop processor), and models/molmo.rs (OLMo-style decoder).
  • Full flow integration, not a standalone module: molmo model-type detection, the ModelType::MolmoVLM registry entry (enum, metadata(), ALL_MODEL_TYPES, capabilities), the loader in loading/vlm_special.rs, the VLM runtime merge path, and generate_vlm.
  • Real-model parity tests (tests/molmo_parity.rs): model-type detection, processor crop/token/image_input_idx shapes, and finite logits on both text-only and image-conditioned forward passes. Gated on a local models/molmo-7b checkout, inert in CI without it.

Folded-in fix: InternVL in mlxcel list

ModelType::InternVLChatVLM was already in the enum and metadata() but missing from ALL_MODEL_TYPES, so InternVL never appeared in mlxcel list. The slice is not compile-enforced for completeness, so no test caught it. This PR adds it (right after YoutuVLM); both InternVL and Molmo now list correctly.

Benchmarks (M5 Max)

molmo-7b flips from FAIL to a passing row — text-only 78.74 tok/s decode, VLM 84.99 tok/s decode — raising the pass count to 93 and dropping it from the known-issues list. The upstream mlx-vlm baseline for this model is a 1-token anomaly, so no percentage comparison is reported.

Verification

  • cargo fmt --all -- --check clean
  • cargo clippy --all-targets --features metal,accelerate -- -D warnings clean
  • Registry drift tests pass (all_model_types_covers_every_variant, metadata_round_trip_is_consistent, all_model_types_has_no_duplicates)
  • tests/molmo_parity.rs 4/4 pass against a real molmo-7b checkout
  • mlxcel list shows both Molmo (CLIP ViT + OLMo-style text) and InternVL (InternViT + pixel-shuffle + Qwen2)

Add support for the Molmo v1 vision-language model (`molmo-7b`). The architecture pairs a CLIP-style ViT image encoder with attention pooling and a connector into an OLMo-style text decoder, loaded through the VLM special path. The multi-crop image processor emits pixel values, per-crop masks, and the `image_input_idx` mapping; the VLM runtime uses that mapping to expand the `<im_patch>` placeholders and additively scatter the pooled image features onto the text embeddings at the named positions before the forward pass.

Wiring spans the full model flow rather than a standalone module: `molmo` model-type detection, the `ModelType::MolmoVLM` registry entry (enum variant, `metadata()` arm, `ALL_MODEL_TYPES`, capabilities), the loader in `loading/vlm_special.rs`, the VLM runtime merge path, and `generate_vlm`. Real-model parity tests in `tests/molmo_parity.rs` cover model-type detection, the processor's crop/token/`image_input_idx` shapes, and finite logits on both the text-only and image-conditioned forward passes; they are gated on a local `models/molmo-7b` checkout and stay inert without it.

This batch also restores `ModelType::InternVLChatVLM` to `ALL_MODEL_TYPES`. The variant was already present in the enum and in `metadata()`, but its absence from the slice meant InternVL never appeared in `mlxcel list`, and because the slice is not compile-enforced for completeness no existing test caught the gap. Both InternVL and Molmo now show up in `mlxcel list`.

The M5 Max benchmark tables flip `molmo-7b` from FAIL to a passing row (text-only 78.74 tok/s decode, VLM 84.99 tok/s decode), raise the pass count to 93, and drop it from the known-issues list.
@inureyes inureyes added type:enhancement New features, capabilities, or significant additions area:models Model architectures, weights, loading, metadata labels May 20, 2026
@inureyes
inureyes merged commit aaf2f0e into main May 20, 2026
4 checks passed
@inureyes
inureyes deleted the feat/molmo-vlm branch May 20, 2026 15:35
inureyes added a commit that referenced this pull request May 23, 2026
Bump version to 0.0.30. Highlights: unified pre-load memory estimator with the new mlxcel inspect subcommand and --estimate-memory preflight (#64, #65, #66, #67), Molmo v1 and InternVL VLM architectures (#41, #37), Gemma 3n / Phi-3.5 / Gemma / Jamba decode performance work (#42, #43, #44, #60, #62), and server --ctx-size as a shared parallel context budget (#57).
@inureyes inureyes added this to the 0.1 milestone Jun 21, 2026
@inureyes inureyes self-assigned this Aug 31, 2026
@inureyes inureyes added the status:done Completed label Sep 6, 2026
be-free-snowboy pushed a commit to freestylejs/snowbrain-mlxcel that referenced this pull request Oct 27, 2026
Add support for the Molmo v1 vision-language model (`molmo-7b`). The architecture pairs a CLIP-style ViT image encoder with attention pooling and a connector into an OLMo-style text decoder, loaded through the VLM special path. The multi-crop image processor emits pixel values, per-crop masks, and the `image_input_idx` mapping; the VLM runtime uses that mapping to expand the `<im_patch>` placeholders and additively scatter the pooled image features onto the text embeddings at the named positions before the forward pass.

Wiring spans the full model flow rather than a standalone module: `molmo` model-type detection, the `ModelType::MolmoVLM` registry entry (enum variant, `metadata()` arm, `ALL_MODEL_TYPES`, capabilities), the loader in `loading/vlm_special.rs`, the VLM runtime merge path, and `generate_vlm`. Real-model parity tests in `tests/molmo_parity.rs` cover model-type detection, the processor's crop/token/`image_input_idx` shapes, and finite logits on both the text-only and image-conditioned forward passes; they are gated on a local `models/molmo-7b` checkout and stay inert without it.

This batch also restores `ModelType::InternVLChatVLM` to `ALL_MODEL_TYPES`. The variant was already present in the enum and in `metadata()`, but its absence from the slice meant InternVL never appeared in `mlxcel list`, and because the slice is not compile-enforced for completeness no existing test caught the gap. Both InternVL and Molmo now show up in `mlxcel list`.

The M5 Max benchmark tables flip `molmo-7b` from FAIL to a passing row (text-only 78.74 tok/s decode, VLM 84.99 tok/s decode), raise the pass count to 93, and drop it from the known-issues list.
be-free-snowboy pushed a commit to freestylejs/snowbrain-mlxcel that referenced this pull request Oct 27, 2026
Bump version to 0.0.30. Highlights: unified pre-load memory estimator with the new mlxcel inspect subcommand and --estimate-memory preflight (lablup#64, lablup#65, lablup#66, lablup#67), Molmo v1 and InternVL VLM architectures (lablup#41, lablup#37), Gemma 3n / Phi-3.5 / Gemma / Jamba decode performance work (lablup#42, lablup#43, lablup#44, lablup#60, lablup#62), and server --ctx-size as a shared parallel context budget (lablup#57).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:models Model architectures, weights, loading, metadata status:done Completed type:enhancement New features, capabilities, or significant additions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant