Skip to content

Add a deterministic minres test for the eps stopping criterion - #3105

Open
antonwolfy wants to merge 1 commit into
masterfrom
fix-minres-coverage-flake
Open

antonwolfy wants to merge 1 commit into
masterfrom
fix-minres-coverage-flake

Conversation

@antonwolfy

@antonwolfy antonwolfy commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

The istop = 3 branch of minres (_iterative.py L859, the epsx >= beta1 stopping test) is reached only by test_minres_x0_exact_solution. There x0 is the exact solution, so the initial residual beta1 is rounding noise (~1.5e-16) of the same order as epsx (~2e-16), and whether the branch is hit depends on the runner.

That is why Coveralls flips by one line currently on PRs with no source change.

This PR adds test_minres_x0_null_space, which uses a singular A = [[1, 0], [0, 0]], a large x0 = [0, 2**40] in its null space and a tiny b = 2**-40. All values are exact in fp64 and epsx / beta1 = 2**27, so the branch is always reached. The result matches SciPy's minres for the same input.

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

The istop = 3 branch of minres was reached only by
test_minres_x0_exact_solution, where the initial residual is rounding
noise of the same order as the eps threshold. Whether it was hit depended
on the runner, so Coveralls flipped by one line (-0.003%) on PRs with no
source change.

The new test uses a singular A with a large x0 in its null space and a
tiny b. All values are exact in fp64 and the eps test passes by a factor
of 2**27, so the branch is always reached.
@antonwolfy antonwolfy self-assigned this Oct 15, 2026
@antonwolfy antonwolfy added this to the 0.21.0 release milestone Oct 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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

@coveralls

Copy link
Copy Markdown
Collaborator

Coverage Status

coverage: 82.613%. remained the same — fix-minres-coverage-flake into master

@github-actions

Copy link
Copy Markdown
Contributor

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

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.

2 participants