Skip to content

Conversation

@lkdvos
Copy link
Member

@lkdvos lkdvos commented Nov 6, 2025

This is an attempt to tackle #91 .

The main goal is to provide some way to reduce the amount of code duplication in our tests here, but additionally to think about how this might affect downstream adopters of this package.

I've set up the QR tests to give an idea of what I have in mind, feedback greatly appreciated!

@codecov
Copy link

codecov bot commented Nov 6, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
...ixAlgebraKitAMDGPUExt/MatrixAlgebraKitAMDGPUExt.jl 73.17% <ø> (-14.14%) ⬇️
src/implementations/qr.jl 93.77% <100.00%> (-2.84%) ⬇️
src/implementations/schur.jl 95.40% <100.00%> (-4.60%) ⬇️
src/implementations/svd.jl 74.83% <100.00%> (-17.45%) ⬇️

... and 15 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

test/qr.jl Outdated
m = 54
for T in BLASFloats, n in (37, m, 63)
TestSuite.seed_rng!(123)
TestSuite.test_qr(T, (m, n))
Copy link
Member

Choose a reason for hiding this comment

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

With the LAPACK methods, there is some interplay between pivoted and blocksize, but I guess the new tests do not test them simultaneously so everything is fine.

Copy link
Member Author

Choose a reason for hiding this comment

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

I was considering adding some dedicated LAPACK methods to test these very specific behaviors, so have a large testsuite to do basic testing, but then add additional tests where necessary.

@kshyatt
Copy link
Member

kshyatt commented Nov 6, 2025

I think this should be relatively easy to make work with the GPU code, but we might want to break up some of the files into multiple functions that implement subsets of the tests to avoid scalar indexing/unsupported operations in some cases.

@github-actions
Copy link

github-actions bot commented Nov 12, 2025

Your PR no longer requires formatting changes. Thank you for your contribution!

@kshyatt kshyatt mentioned this pull request Nov 13, 2025
@kshyatt kshyatt force-pushed the testsuite branch 3 times, most recently from 29dd784 to cf7839a Compare November 13, 2025 10:07
Comment on lines +47 to +53
T = eltype(A)
return if T <: Real
all((zero(T)), diagview(A))
else
all((zero(real(T))), real(diagview(A))) &&
all((zero(real(T))), imag(diagview(A)))
end
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
T = eltype(A)
return if T <: Real
all((zero(T)), diagview(A))
else
all((zero(real(T))), real(diagview(A))) &&
all((zero(real(T))), imag(diagview(A)))
end
all(x -> x abs(x), diagview(A))

Copy link
Member Author

Choose a reason for hiding this comment

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

We can do this, but it does change the tests, -eps() would have this property but it wouldn't have been properly "positive". sign(x) == 1 might work but I'm not sure how accurate that is

Copy link
Member

Choose a reason for hiding this comment

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

julia> eps()  -eps()
false

Copy link
Member Author

Choose a reason for hiding this comment

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

Fair enough, but how about:

julia> 1.0 + 1e-12im  abs(1.0 + 1e-12im)
true

😉

Jokes aside, I think our current implementation is really such that the imaginary part is hard zero and the real part is hard positive, I don't have a strong opinion about whether or not this is a requirement either (i.e. are we assuming that we can always make this exactly true for weird Number types, or is it sometimes only approximately positive?), so I'll just change this :)

Copy link
Member

Choose a reason for hiding this comment

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

Well indeed, I also think we currently require strict positivity, but I was confused by all(≈(zero(real(T))), imag(diagview(A))). Is this equivalent to all(iszero, imag(diagview(A))). If you want the latter, then clearly we want x == abs(x).

Copy link
Member

Choose a reason for hiding this comment

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

or simply all(isposdef, diagview(A)) (but this requires LinearAlgebra.isposdef)

@kshyatt
Copy link
Member

kshyatt commented Dec 2, 2025

eigh_trunc! tests are failing, I'll look into why

Edit: Diagonal strikes again

@kshyatt kshyatt force-pushed the testsuite branch 2 times, most recently from 6f21e71 to b6fd59e Compare December 5, 2025 08:51
@kshyatt
Copy link
Member

kshyatt commented Dec 5, 2025

I think the only factorization left to cover is schur, and then of course the AD tests

@kshyatt kshyatt force-pushed the testsuite branch 4 times, most recently from 81e2b9d to 178e892 Compare December 8, 2025 11:46
@lkdvos
Copy link
Member Author

lkdvos commented Dec 9, 2025

Note to self + others:

We probably want to add an additional part to the tests (presumably this does not have to be part of the suite, unless we can fit it in nicely), which tests the algorithms that are not selected automatically.
That way, the tests contain:

  • For given array type, make sure that default algorithm selection and keywords work as intended
  • For given algorithm, make sure that the supported array types work as intended

@kshyatt
Copy link
Member

kshyatt commented Dec 11, 2025

OK, I think everything is in here except for testing the different algorithms. I'll think a bit about a graceful way to do that...

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.

4 participants