Repository navigation
ci: report C++ line coverage from the Metal test run - #25
Conversation
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) <noreply@anthropic.com>
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) <noreply@anthropic.com>
|
Review follow-up for head 35ad1c9: before approval, please bring in the validated #22 stack including #24, update/retarget this PR as needed, and link a green instrumented Fork Tests run on the resulting head. The current metal-build-and-test check is red. Please verify that all test stages complete and attach the coverage report from that successful run; a report produced after a partial failed run should not be used as the baseline. The coverage-reporting approach itself is reasonable. For the later 80% initiative, keep the denominator explicit: this measures instrumented host code, not Metal shader coverage. I am not asking for an 80% threshold in this enabling PR. |
|
Reply written by Claude (agent) on David Tai's behalf. Agreed. This PR stays stacked on |
…#28) * ci: report C++ line coverage from the Metal test run 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) <noreply@anthropic.com> * ci: drop generated files and Python headers from the coverage report 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) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Proposed changes
This PR adds C++ line coverage to the
Fork Testsjob (.github/workflows/fork-tests.yml). There is no coverage floor.CFLAGSandCXXFLAGSadd-fprofile-instr-generate -fcoverage-mapping. Both builds inbuild-macos(the wheel and the C++ tests) run cmake from scratch, and cmake reads these variables. The flags cannot go through the cmake arguments, becausesetup.pysplitsCMAKE_ARGSat spaces.LLVM_PROFILE_FILEto${{ runner.temp }}/profiles/%p-%m.profraw. Each test process writes one profile for each instrumented binary. A job-levelenvcannot read therunnercontext (actionlint:context "runner" is not allowed here), so the test step sets the path. The build steps then write no profiles into the report.xcrun llvm-profdata mergemerges the profiles.xcrun llvm-cov reportreads./build/tests/tests, the installed extension (mlx/core.cpython-312-darwin.so) and the libraries inmlx/lib(libmlx.dylib,libjaccl.dylib). The Python tests run the library code inlibmlx.dylib, not in the extension.-ignore-filename-regexdrops/tests/,/_deps/,/python/,/.venv/and/site-packages/.coverage-reportartifact withactions/upload-artifactv7.0.1 (the SHA thatbuild_and_test.ymlalready uses).Metal shaders cannot be covered. The
.metalkernels run on the GPU, and clang coverage instruments only the host C and C++ code.Runner probe result
Run on the head commit: https://github.com/Layr-Labs/mlx/actions/runs/36183840975. The job is red because of the C++ failure that #24 fixes.
coverage-reporthas the full report for each file: https://github.com/Layr-Labs/mlx/actions/runs/36183840975/artifacts/10885213482Read: the build is not measurably slower, the C++ tests take about 0.2 minutes more, and the report steps take about 0.15 minutes. The cost for the Python tests shows in the first run after #22 is updated from
mainwith #24.Test plan
actionlint .github/workflows/fork-tests.yml: no findings.actionlinton a test workflow withLLVM_PROFILE_FILE: ${{ runner.temp }}/...in a job-levelenv:context "runner" is not allowed here. This is why the test step sets the path./usr/bin/python3 scripts/check_forkdiff.py --upstream-ref refs/remotes/upstream/main: 173 of 173 changed files described.gh api repos/Layr-Labs/mlx/commits/<sha> --jq .commit.verification.verifiedgivestruefor both commits.CONTRIBUTING checklist
pre-commitran on the head commit. TheCheck Lintjob passed in run https://github.com/Layr-Labs/mlx/actions/runs/36183841039.Dependencies
The base branch is
ci/fork-tests(#22). This PR does not include #24. #24 merges intomain, and #22 is then updated frommain. Until then, the C++ testgptoss mxfp4 prefill tiles preserve expert boundaries and partial rowsfails and stops the test step, so the Python tests do not run. This PR runs again after that update. Merge order: #24 intomain, #22 updated frommain, this PR intoci/fork-tests, then #22 intomain.🤖 Generated with Claude Code