test: cover the fourth config-overlay pattern in a VLM architecture (Qwen25VL) - #54
Merged
Merged
Conversation
…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
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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