Skip to content

fix(models): correct Molmo v1 image decoding seams - #1099

Merged
inureyes merged 3 commits into
mainfrom
fix/issue-1087-molmo-v1-output
Aug 10, 2026
Merged

inureyes merged 3 commits into
mainfrom
fix/issue-1087-molmo-v1-output

Conversation

@inureyes

@inureyes inureyes commented Aug 10, 2026 •

Copy link
Copy Markdown
Member

Summary

Fixes two Molmo v1 seams that corrupt image-conditioned generation: flat Molmo-7B-D-0924 configs now default omitted rope_impl to the checkpoint's effective LLaMA rotate-half layout, and image preprocessing now preserves reference padding and fractional mask values for pad_and_partial_pad.

What changed

  • Default missing Molmo v1 rope_impl to llama while preserving explicit interleave as MLX traditional RoPE.
  • Pad raw black before normalization so padded pixels become normalized black values instead of zero-valued normalized-space pixels.
  • Preserve per-patch float coverage in image_masks, including partial border patches, instead of thresholding masks to booleans.
  • Add deterministic regression tests for the affected flat config omission, explicit RoPE controls, normalized black padding, and the known 640x480 9/14 partial border patch.

Validation

  • cargo fmt --all -- --check
  • cargo test -p mlxcel models::molmo::tests
  • cargo test -p mlxcel vision::processors::molmo::tests
  • cargo test -p mlxcel --test molmo_parity
  • cargo clippy -p mlxcel --lib --tests -- -D warnings
  • cargo build --release --features cuda --bin mlxcel --bin mlxcel-server --locked on NVIDIA GB10 (sm_121)
  • Real-checkpoint CLI A/B with /home/inureyes/models/mlx/molmo-7b and the 640x480 COCO cats image: the pre-fix 749-token prompt reproduced the issue output byte-for-byte; the fixed build generated a coherent description of two cats sleeping on a red couch under a pink blanket.
  • Real-checkpoint mlxcel-server validation through POST /v1/chat/completions with the same image and prompt on the normal BatchScheduler path (--parallel 1): coherent output matched the CLI, with prompt_tokens=749, completion_tokens=40, and total_tokens=789.

The legacy --no-batch server mode was also attempted and failed before generation with its existing zero-capacity CachePool admission error. That path is independent of the Molmo decoder/preprocessor changes; the normal production scheduler path completed the required server generation successfully.

Closes #1087

Default omitted Molmo v1 rope_impl to the checkpoint effective LLaMA rotate-half layout instead of the stale interleave dataclass default, so flat Molmo-7B-D-0924 configs no longer select the wrong MLX RoPE layout.

Match Molmo v1 preprocessing to the reference by padding raw black before normalization and preserving fractional patch coverage for pad_and_partial_pad instead of thresholding masks to booleans.

Validation: cargo fmt --all -- --check; cargo test -p mlxcel models::molmo::tests; cargo test -p mlxcel vision::processors::molmo::tests; cargo test -p mlxcel --test molmo_parity; cargo clippy -p mlxcel --lib --tests -- -D warnings.

Closes #1087
@inureyes inureyes added status:review Under review type:bug Bug fixes, error corrections, or issue resolutions priority:medium Medium priority area:models Model architectures, weights, loading, metadata labels Aug 10, 2026
@inureyes
inureyes merged commit 45dea24 into main Aug 10, 2026
8 checks passed
@inureyes
inureyes deleted the fix/issue-1087-molmo-v1-output branch August 10, 2026 15:46
@inureyes inureyes added status:done Completed and removed status:review Under review labels Aug 10, 2026
@inureyes inureyes self-assigned this Aug 27, 2026
be-free-snowboy pushed a commit to freestylejs/snowbrain-mlxcel that referenced this pull request Oct 27, 2026
## Summary

Fixes two Molmo v1 seams that corrupt image-conditioned generation: flat Molmo-7B-D-0924 configs now default omitted `rope_impl` to the checkpoint's effective LLaMA rotate-half layout, and image preprocessing now preserves reference padding and fractional mask values for `pad_and_partial_pad`.

## What changed

- Default missing Molmo v1 `rope_impl` to `llama` while preserving explicit `interleave` as MLX traditional RoPE.
- Pad raw black before normalization so padded pixels become normalized black values instead of zero-valued normalized-space pixels.
- Preserve per-patch float coverage in `image_masks`, including partial border patches, instead of thresholding masks to booleans.
- Add deterministic regression tests for the affected flat config omission, explicit RoPE controls, normalized black padding, and the known 640x480 `9/14` partial border patch.

## Validation

- [x] `cargo fmt --all -- --check`
- [x] `cargo test -p mlxcel models::molmo::tests`
- [x] `cargo test -p mlxcel vision::processors::molmo::tests`
- [x] `cargo test -p mlxcel --test molmo_parity`
- [x] `cargo clippy -p mlxcel --lib --tests -- -D warnings`
- [x] `cargo build --release --features cuda --bin mlxcel --bin mlxcel-server --locked` on NVIDIA GB10 (sm_121)
- [x] Real-checkpoint CLI A/B with `/home/inureyes/models/mlx/molmo-7b` and the 640x480 COCO cats image: the pre-fix 749-token prompt reproduced the issue output byte-for-byte; the fixed build generated a coherent description of two cats sleeping on a red couch under a pink blanket.
- [x] Real-checkpoint `mlxcel-server` validation through `POST /v1/chat/completions` with the same image and prompt on the normal BatchScheduler path (`--parallel 1`): coherent output matched the CLI, with `prompt_tokens=749`, `completion_tokens=40`, and `total_tokens=789`.

The legacy `--no-batch` server mode was also attempted and failed before generation with its existing zero-capacity `CachePool` admission error. That path is independent of the Molmo decoder/preprocessor changes; the normal production scheduler path completed the required server generation successfully.

Closes lablup#1087
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 priority:medium Medium priority status:done Completed type:bug Bug fixes, error corrections, or issue resolutions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: molmo-7b generates incoherent output on image prompts while molmo2-4b is correct

1 participant