Skip to content

Re-enable dim=4 in strided matmul test with proper cross-BLAS tolerances#2949

Draft
antonwolfy wants to merge 4 commits into
masterfrom
revert-gh-2912
Draft

Re-enable dim=4 in strided matmul test with proper cross-BLAS tolerances#2949
antonwolfy wants to merge 4 commits into
masterfrom
revert-gh-2912

Conversation

@antonwolfy

@antonwolfy antonwolfy commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Summary

gh-2912 introduced two temporary test workarounds after a CI failure on ubuntu-latest:

  • widened the tolerance on TestMatvec::test_axes to factor=40;
  • disabled the dim=4 iteration in TestMatmul::test_strided1.

Both failures share the same benign root cause, so this PR re-enables the disabled coverage and replaces the ad-hoc mitigations with documented, dtype-aware tolerances:

  • test_axes (matvec, float64) — keeps factor=40. dpnp computes matvec via oneMKL gemm_batch while NumPy uses OpenBLAS gemv; the summation order differs and the float64 result deviates at the noise floor (~1.4e-14), which exceeds the default 8e-15 tolerance.
  • test_strided1 (matmul) — re-enables dim=4. dpnp copies the strided input to c-contiguous and runs it through oneMKL gemm_batch, again against NumPy's OpenBLAS. For float32, the length-20 contraction deviates by ~1.87e-5, just above the old factor=16 bound (~1.81e-5), so the tolerance is bumped to factor=24 for float32 only (pass-bound ~2.27e-5). Integer input is compared exactly and is unaffected.

Root cause

Neither discrepancy is a dpnp correctness bug. Both are expected floating-point non-associativity between two different BLAS backends (oneMKL vs OpenBLAS), surfaced when the conda-forge NumPy in CI advanced its bundled OpenBLAS. There is nothing to fix upstream, so documented tolerances are the correct handling and let us keep full test coverage (including dim=4).

  • 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?

@antonwolfy antonwolfy self-assigned this Jun 15, 2026
@github-actions

github-actions Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Array API standard conformance tests for dpnp=0.21.0dev3=py313h509198e_8 ran successfully.
Passed: 1373
Failed: 2
Skipped: 5

@coveralls

coveralls commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

Coverage Status

coverage: 78.118% (-0.009%) from 78.127% — revert-gh-2912 into master

@github-actions

Copy link
Copy Markdown
Contributor

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

…test

The revert of gh-2912 removed the widened tolerance on
TestMatvec::test_axes, which reintroduced a CI failure on ubuntu-latest:
dpnp computes matvec via oneMKL gemm_batch while NumPy uses OpenBLAS
gemv, so the summation order differs and the float64 result deviates at
the noise floor (~1.4e-14), exceeding the default 8e-15 tolerance.

Restore factor=40 on test_axes (with an explanatory comment) while
keeping the rest of the revert, i.e. re-enabling dim=4 in
TestMatmul::test_strided1, whose factor=16 tolerance already absorbs any
cross-BLAS discrepancy.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@antonwolfy antonwolfy changed the title Rever changes in the tests done in gh-2912 Re-enable dim=4 in strided matmul test and keep matvec tolerance Jul 15, 2026
@antonwolfy antonwolfy added this to the 0.21.0 release milestone Jul 15, 2026
@antonwolfy antonwolfy marked this pull request as ready for review July 15, 2026 15:49
@antonwolfy antonwolfy marked this pull request as draft July 16, 2026 08:00
Re-enabling dim=4 in TestMatmul::test_strided1 reintroduced the CI
failure gh-2912 had worked around by skipping it: for float32 the
strided matmul deviates by ~1.87e-5, just above the factor=16 bound
(~1.81e-5). The cause is benign cross-BLAS non-associativity -- dpnp
copies the strided input to c-contiguous and runs oneMKL gemm_batch,
while NumPy uses OpenBLAS, so the length-20 float32 contraction
accumulates in a different order.

Bump the tolerance to factor=24 (pass-bound ~2.27e-5) for float32 only;
integer input is compared exactly, so the factor does not affect it.
This keeps dim=4 covered without masking real regressions in the exact
path.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@antonwolfy antonwolfy changed the title Re-enable dim=4 in strided matmul test and keep matvec tolerance Re-enable dim=4 in strided matmul test with proper cross-BLAS tolerances Jul 16, 2026
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