Skip to content

test: add a coverage report that names where the suites are blind - #146

Merged
solderzzc merged 1 commit into
mainfrom
test/coverage-measurement
Aug 15, 2026
Merged

test: add a coverage report that names where the suites are blind#146
solderzzc merged 1 commit into
mainfrom
test/coverage-measurement

Conversation

@solderzzc

Copy link
Copy Markdown
Member

Tier 4 of #128 — which asked for --enable-code-coverage to find blind spots objectively rather than by eye. This runs it and aggregates the output into something readable.

Why both suites

Reading either alone misleads. From the umbrella package the model architectures look like 0% — not because they are untested, but because their tests live in the submodule. Measured separately:

suite area coverage
SwiftLM package server 24.4%
inference core 57.7%
SwiftBuddy app 5.3%
mlx-swift-lm model architectures (LLM) 24.1%
model architectures (VLM) 0.3%
MLXLMCommon 41.3%

Two findings

#128's named example is confirmed, and it's the worst case. MLXVLM/Models/Gemma4.swift — where SharpAI/mlx-swift-lm#45's changes landed — has no tests, and at 1771 lines it is the single largest untested file in the model layer.

The pattern around it is the bigger story. The VLM half of the model layer sits at 0.3% across 13,304 lines. Every one of these is at zero:

1771  Gemma4.swift        1015  LFM2VL.swift      831  Gemma3.swift
1423  Qwen3VL.swift        938  GlmOcr.swift      773  Pixtral.swift
1041  Qwen35.swift         844  Qwen25VL.swift    767  FastVLM.swift

CI does run vision and omni end-to-end tests, so these paths are exercised — but nothing touches them at unit level. That is why a shape or dtype mistake inside one surfaces as a wrong answer about an image rather than as a failing assertion, which is a considerably more expensive way to find out.

Deliberately not wired into CI

A coverage gate rejects work for touching an already-thin file, and invites tests written to move a number rather than to catch anything. The run also costs a full debug rebuild of both packages. This is a tool for answering "where are we blind" when someone asks — not a check to pass.

The caveat, which the script prints itself

Coverage measures execution, not correctness. A covered line may be asserted on by nothing at all. Treat a low number as a question and a high number as no answer.

./scripts/coverage-report.sh            # both suites
./scripts/coverage-report.sh package    # SwiftLM only
./scripts/coverage-report.sh submodule  # mlx-swift-lm only

🤖 Generated with Claude Code

Tier 4 of #128, which asked for `--enable-code-coverage` to find blind spots
objectively rather than by eye. This runs it and aggregates the result into
something readable: coverage per area, plus the largest files no test executes.

Both suites are measured, because reading either alone misleads. From the
umbrella package the model architectures look like 0%, which is not because they
are untested but because their tests live in the submodule. Measured separately:

  SwiftLM package        server 24.4%, inference core 57.7%, SwiftBuddy 5.3%
  mlx-swift-lm submodule LLM models 24.1%, VLM models 0.3%, MLXLMCommon 41.3%

Two findings worth acting on.

#128 named `MLXVLM/Models/Gemma4.swift` as having no tests despite being where
SharpAI/mlx-swift-lm#45's changes landed. Measurement confirms it and adds that
it is the single largest untested file in the model layer, at 1771 lines.

More striking is the pattern around it: the VLM half of the model layer is at
**0.3% over 13,304 lines** — Qwen3VL, Qwen35, LFM2VL, GlmOcr, Qwen25VL, Gemma3,
Pixtral, FastVLM are all at zero. CI does run vision and omni end-to-end tests,
so these paths are exercised; nothing touches them at unit level, which is why a
shape or dtype mistake inside one surfaces only as a wrong image answer.

Deliberately not wired into CI. A coverage gate rejects work for touching an
already-thin file and invites tests written to raise a number, and the run costs
a full debug rebuild of both packages. This is a tool to answer "where are we
blind" when someone asks, not a check to pass.

The script says so itself: coverage measures execution, not correctness — a
covered line may be asserted on by nothing at all.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
solderzzc added a commit to SharpAI/mlx-swift-lm that referenced this pull request Aug 15, 2026
Coverage measurement (SharpAI/SwiftLM#146) put the entire VLM half of the model
layer at 0.3% over 13,304 lines, with zero test files under Tests/MLXLMTests
touching MLXVLM at all. MLXVLM/Models/Gemma4.swift — where #45's changes
landed, and the file issue ml-explore#128 named specifically — is 1,771 lines and none
of them ran.

Vision models are exercised end to end by the vision and omni CI jobs, so the
gap was never "this code doesn't run" — it was that a shape or dtype fault
inside one surfaces as a wrong answer about an image rather than a failing
assertion, discovered downstream and expensively.

Four tests, tiny random-init configs in the style of the existing Gemma4Tests:
config decoding for both the text and vision halves, instantiation, a
text-only forward pass (the path every request without an image attachment
takes), and determinism. Establishes shape and finiteness, not numerical
correctness — real checkpoints remain the only way to judge output quality.

Full suite: 108 tests, 18 suites, passing.

Co-authored-by: Aegis AI Assistant <simba@aegis-ai.dev>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
@solderzzc
solderzzc merged commit 618fd23 into main Aug 15, 2026
14 checks passed
@solderzzc
solderzzc deleted the test/coverage-measurement branch August 15, 2026 04:53
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