Skip to content

ci: count the Python bindings in python/src in the C++ coverage report - #31

Merged
Gajesh2007 merged 6 commits into
mainfrom
ci/coverage-python-bindings
Oct 2, 2026
Merged

Gajesh2007 merged 6 commits into
mainfrom
ci/coverage-python-bindings

Conversation

@davidtai

@davidtai davidtai commented Sep 30, 2026 •

Copy link
Copy Markdown

Proposed changes

The C++ coverage report of Fork Tests ignores python/src, the C++ code of the Python bindings, with the /python/ pattern in -ignore-filename-regex. The Python tests run this code through the installed wheel, and the step already passes the extension module to llvm-cov as an -object.

  • The /python/ pattern is removed from -ignore-filename-regex. The patterns for the build folders, the tests, the virtual environment, the Python headers, mlx/3rdparty/ and mlx/backend/cuda/ do not change.
  • A new first row, "Total", counts mlx/ and python/src together. A new row counts python/src alone. The row "All of mlx/" and the per-directory rows do not change.
  • The report function takes one or more directories, so one report can cover mlx/ and python/src.
  • The sentence under the table now says that the denominator is the host C++ code under mlx/ and the Python bindings in python/src.
  • The coverage-report artifact (report.txt) is now the report for the Total row.

No library code changes. fork.yaml already lists .github/workflows/fork-tests.yml, so no fork.yaml change is needed.

Results

Fork Tests run on head 76dd8d4: https://github.com/Layr-Labs/mlx/actions/runs/36744294779 (success). Before is #29's run 36587584091 on head 02720cc. Values are from the TOTAL rows in the step log and from the coverage-report artifact.

Row Lines before Lines after Line coverage before Line coverage after Branches after Functions after
Total 50737 69051 70.08% 76.62% 64.57% 75.36%
All of mlx/ 50737 50737 70.08% 70.08% 62.69% 72.64%
python/src not counted 18314 not counted 94.73% 78.95% 90.68%

The rows for mlx/backend/metal, mlx/backend/cpu, mlx/backend/common, mlx/distributed and mlx/io do not change (within one line of the run on #29). Every file in the artifact is under mlx/ or python/src/, so removing the /python/ pattern adds no other files.

Job time: 24 min 33 s before, 26 min 41 s after. The report step takes 7 s in both runs. The difference is in the build (+1 min) and test (+1 min) steps, which this PR does not change.

Test plan

  • actionlint .github/workflows/fork-tests.yml: no findings.
  • /usr/bin/python3 scripts/check_forkdiff.py --upstream-ref refs/remotes/upstream/main: passes.
  • The Fork Tests run on this head is the test.

CONTRIBUTING checklist

  • Formatting: not applicable, only a workflow file changes; actionlint passes on it.
  • Tests: not applicable, no library code; the Fork Tests run of this PR is the test.
  • Benchmarks: not applicable, no library code changes.

Dependencies

Merge this PR after #28 and #29. This branch is based on ci/coverage-scope (#29's head, 02720cc), which is based on #28. The PR base is ci/coverage-scope, so the diff shows only this change.

Authorship

Written by Claude (Opus 5.5) under David Tai's direction.

  • ☐ I understand it is strictly prohibited to use AI to write PR description
  • AI usage disclosure: this change and this description were written by Claude (Opus 5.5) under David Tai's direction.

🤖 Generated with Claude Code

davidtai and others added 5 commits September 28, 2026 19:53
Build with clang coverage instrumentation through CFLAGS and CXXFLAGS.
Both builds in build-macos run cmake from scratch and read them. The
test step writes one profile for each process and instrumented binary.

After the tests, merge the profiles and report line coverage for the C++
test binary and the installed Python extension and libraries. Write the
totals to the job summary and upload the full report as an artifact.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The first report counted the generated sources in the two build
folders and the headers of the uv Python. Ignore every path under a
build folder and the uv Python folder, so that the totals count only
the mlx sources.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The job summary now shows one table with Lines, Branches and Functions for
all host C++ under mlx/ and for backend/metal, backend/cpu, backend/common,
distributed and io, each against the 80% target. The target is reported
only.

The report now also leaves out the Metal shader source in
mlx/backend/metal/kernels/, the CUDA backend and the vendored pocketfft
header. The step reads each value from the llvm-cov TOTAL row by its
column name and fails when a value is missing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The kernels exclude dropped steel/conv/params.h, a header that host C++
includes and that has coverage records. The shader source has no records,
so the exclude is removed. The text says "link" instead of "run", and a
comment notes that value_of rejects the "-" of a column without counters.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The Python tests run the bindings through the installed wheel, but the
report dropped python/src with an ignore pattern. The report now counts
python/src in the total and shows it in its own row. The rows for mlx/
and its directories do not change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Gajesh2007
Gajesh2007 changed the base branch from ci/coverage-scope to main October 2, 2026 22:49
…ndings

# Conflicts:
#	.github/workflows/fork-tests.yml
@Gajesh2007
Gajesh2007 merged commit b07894f into main Oct 2, 2026
5 of 6 checks passed
@davidtai
davidtai deleted the ci/coverage-python-bindings branch October 4, 2026 22:00
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.

2 participants