Skip to content

test: cover the fourth config-overlay pattern in a VLM architecture (Qwen25VL) - #54

Merged
solderzzc merged 1 commit into
mainfrom
test/vlm-qwen25vl-unit-tests
Aug 16, 2026
Merged

test: cover the fourth config-overlay pattern in a VLM architecture (Qwen25VL)#54
solderzzc merged 1 commit into
mainfrom
test/vlm-qwen25vl-unit-tests

Conversation

@solderzzc

Copy link
Copy Markdown
Member

Companion to #53. Follow-up to ml-explore#147-ml-explore#149 — `MLXVLM/Models/Qwen25VL.swift` (844 lines) was the second-largest remaining zero-coverage file.

What's different about it

A fourth distinct config pattern: here it's the text configuration, not just the base one, that overlays the top-level container. `Qwen25VLConfiguration.init` decodes `VisionConfiguration` from the nested `vision_config` key, then decodes both `TextConfiguration` and `BaseConfiguration` straight from the same top-level decoder. Several fields (`hidden_size`, `num_attention_heads`, `num_hidden_layers`, ...) are declared in both structs under the same key — one JSON field populates two parallel properties rather than one being derived from the other.

A crash trap, found by running it

One field has no default and crashes construction if omitted: `rope_scaling.mrope_section` (`Attention.init` `fatalError`s without it — found this the hard way, first attempt omitted it). Its values are doubled and cumulatively summed into split points along the head dimension, so `sum(mrope_section) * 2` must not exceed `head_dim` — a config with too large a section list fails at a slice, not at decode time. Both are recorded in the type doc.

The vision tower separately carries a windowed/full-attention split (`fullatt_block_indexes`) that only engages on the image-forward path — outside this PR's scope, same as the rest of the VLM tests this session (construction + text-only forward).

Verification

```
Qwen25VL.swift: 0% → 26.7% line coverage
Full suite: 128 tests, 23 suites, passing (120 before, +8 across this PR and its GlmOcr sibling)
```

🤖 Generated with Claude Code

…Qwen25VL)

Follow-up to ml-explore#147-ml-explore#149. MLXVLM/Models/Qwen25VL.swift (844 lines) was the
second-largest remaining zero-coverage file, in the same follow-on as GlmOcr.

A fourth distinct config pattern: here it is the text configuration, not just
the base one, that overlays the top-level container.
Qwen25VLConfiguration.init decodes VisionConfiguration from the nested
vision_config key, then decodes both TextConfiguration and BaseConfiguration
straight from the same top-level decoder. Several fields (hidden_size,
num_attention_heads, num_hidden_layers, ...) are declared in both structs
under the same key, so one top-level JSON field populates two parallel
properties rather than one being derived from the other.

One field has no default and crashes construction if omitted:
rope_scaling.mrope_section (Attention.init fatalErrors without it). Its values
are doubled and cumulatively summed into split points along the head
dimension, so sum(mrope_section) * 2 must not exceed head_dim — a config with
too large a section list fails at a slice, not at decode time. The type doc
records both traps for whoever extends this.

The vision tower separately carries a windowed/full-attention split
(fullatt_block_indexes) that only engages on the image-forward path, outside
this PR's scope — construction plus a text-only forward pass, same as the
other VLM tests this session.

Verified with coverage: Qwen25VL.swift moves from 0% to 26.7% line coverage.
Full suite: 128 tests, 23 suites, passing (120 before, +8 across this PR and
its GlmOcr sibling).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@solderzzc
solderzzc merged commit 512dcde into main Aug 16, 2026
6 checks passed
@solderzzc
solderzzc deleted the test/vlm-qwen25vl-unit-tests branch August 16, 2026 02:55
solderzzc added a commit to SharpAI/SwiftLM that referenced this pull request Aug 16, 2026
#150)

Points at 512dcde, which carries both:

- SharpAI/mlx-swift-lm#53 — MLXVLM/Models/GlmOcr.swift, whose base config
  overlays the same top-level container as text_config/vision_config
- SharpAI/mlx-swift-lm#54 — MLXVLM/Models/Qwen25VL.swift, whose text config
  does the same, with several fields duplicated across two parallel structs

Both were, alongside Gemma4/Qwen3VL/Qwen35/LFM2VL (#147-#149), among the
largest zero-coverage files in the model layer. Coverage: GlmOcr 0% → 37.9%,
Qwen25VL 0% → 26.7%.

No SwiftLM-side code changes; verified the umbrella builds clean against the
bumped pointer.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant