Skip to content

Run dpnp.tensor tests in coverage workflow - #3094

Open
antonwolfy wants to merge 5 commits into
masterfrom
coverage-include-tensor-tests
Open

antonwolfy wants to merge 5 commits into
masterfrom
coverage-include-tensor-tests

Conversation

@antonwolfy

@antonwolfy antonwolfy commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

This PR extends the coverage workflow to also run dpnp.tensor tests, which are currently excluded by SKIP_TENSOR_TESTS=1.

Because of that, dpnp/tensor code is measured only through what dpnp tests happen to reach, and some lines end up covered by chance.

For example, line 809 of dpnp/tensor/_elementwise_common.py is reached deterministically only by dpnp/tests/tensor/elementwise/test_add.py::test_add_order. In the coverage run it is reached only by TestDotFor0Dim in the third-party tests, and only when the random dtype-pair sampling of for_all_dtypes_combination happens to include a float32 x int32/int64 pair. The line is missed in about 1/3 of runs (251 of 744 Coveralls builds since dpnp.tensor was introduced in #2856), which shows up as ±0.003% coverage noise on PRs without any source changes.

Note, enabling --tensor-cpp-coverage in CI is left for a follow-up. It may also need -ignore-filename-regex rules for libtensor kernel headers, similar to the existing ones for backend/kernels.

  • Have you provided a meaningful PR description?
  • Have you added a test, reproducer or referred to an issue with a reproducer?
  • Have you tested your changes locally for CPU and GPU devices?
  • Have you made sure that new changes do not introduce compiler warnings?
  • Have you checked performance impact of proposed changes?
  • Have you added documentation for your changes, if necessary?
  • Have you added your changes to the changelog?

Run dpnp.tensor tests in a separate pytest session that appends to the
coverage data of the main dpnp session, and merge the LLVM profiles of
both sessions.

Add --skip-tensor-tests option to keep the previous behavior, and
--tensor-cpp-coverage option to build dpnp.tensor pybind11 extensions
with coverage instrumentation and include them into C++ coverage.

Raise coverage workflow timeouts to account for the extra session.
@antonwolfy antonwolfy added this to the 0.21.0 release milestone Oct 12, 2026
@antonwolfy antonwolfy self-assigned this Oct 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

View rendered docs @ https://intelpython.github.io/dpnp/pull/3094/index.html

@github-actions

github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Array API standard conformance tests for dpnp=0.21.0dev13=np2py314h8d9cdd5_10 ran successfully.
Passed: 1376
Failed: 0
Skipped: 6

@coveralls

coveralls commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator

Coverage Status

No base build to compare — coverage-include-tensor-tests into master

@antonwolfy
antonwolfy marked this pull request as ready for review October 12, 2026 17:21
Comment thread scripts/gen_coverage.py Outdated
run(
pytest_cmd
# report once, on the combined data of the last session
+ (["--cov-report="] if args.run_tensor_tests else cov_report)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the tensor tests fail or hit OOM we lose coverage reports from both sessions.
Since these tests may hit OOM (#2860), I suggest keeping cov_report in the first session too.

The second session will overwrite coverage-python.lcov anyway and printing term-missing twice will show coverage from each session

Suggested change
+ (["--cov-report="] if args.run_tensor_tests else cov_report)
# the tensor session below re-reports on the combined data
+ cov_report

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, good point. Instead of reporting in both sessions, the coverage job is now split into separate steps: build, dpnp tests, dpnp.tensor tests and coverage report generation.

  • The dpnp.tensor tests step has its own timeout and retries (also on timeout), so an OOM/abort or a hang of the tensor tests re-runs only that step, without rebuilding dpnp and re-running dpnp tests.
  • The pytest sessions don't generate reports anymore. A separate step produces them from the combined .coverage data, with the same lcov output as pytest-cov.

Note that reporting in the first session wouldn't keep the coverage on its own: if the tensor session is killed, the job fails and the Coveralls upload is skipped, while the dpnp tests data stays in .coverage anyway.

antonwolfy and others added 3 commits October 13, 2026 14:29
Add --stage option to gen_coverage.py to run build, dpnp tests,
dpnp.tensor tests and report generation separately. Coverage reports
are now generated by the report stage from the combined data of all
test sessions.

Run each stage as a separate workflow step, so dpnp.tensor tests have
their own timeout and are retried (also on timeout) without rebuilding
dpnp and re-running dpnp tests.
The oneAPI compiler is installed with apt and is not in PATH unless
setvars.sh is sourced, which the build and report stages require.

This branch has not been deployed

No deployments
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.

3 participants