Skip to content

Conversation

@christiangnrd
Copy link
Member

@christiangnrd christiangnrd commented Oct 20, 2025

Minor changes but with this change we'll be able to run the gpuarrays/linalg testset without running all the other testsets that start with gpuarrays/linalg.

Also slightly refactors the structure of the tests in linalg so that the output is formatted better when a test fails.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 20, 2025

Your PR requires formatting changes to meet the project's style guidelines.
Please consider running Runic (git runic master) to apply these changes.

Click here to view the suggested changes.
diff --git a/test/testsuite/linalg.jl b/test/testsuite/linalg.jl
index b042d94..00332bd 100644
--- a/test/testsuite/linalg.jl
+++ b/test/testsuite/linalg.jl
@@ -1,4 +1,4 @@
-@testsuite "linalg/core " (AT, eltypes)->begin
+@testsuite "linalg/core " (AT, eltypes) -> begin
     @testset "adjoint and transpose" begin
         @test compare(adjoint, AT, rand(Float32, 32, 32))
         @test compare(adjoint!, AT, rand(Float32, 32, 32), rand(Float32, 32, 32))
@@ -23,12 +23,12 @@
         @test compare(x -> permutedims(x, (2, 1, 3)), AT, rand(Float32, 4, 5, 6))
         @test compare(x -> permutedims(x, (3, 1, 2)), AT, rand(Float32, 4, 5, 6))
         if ComplexF32 in eltypes
-            @test compare(x -> permutedims(x, [2,1,4,3]), AT, randn(ComplexF32,3,4,5,1))
+            @test compare(x -> permutedims(x, [2, 1, 4, 3]), AT, randn(ComplexF32, 3, 4, 5, 1))
             # test UInt64 version to make sure it works properly when array length is larger than typemax of UInt32.
             AT <: GPUArrays.AbstractGPUArray && @test let
-                x = randn(ComplexF32,3,4,5,1)
-                y = permutedims(x, (2,1,4,3))
-                Array(GPUArrays._permutedims!(UInt64, AT(zero(y)), AT(x), (2,1,4,3))) ≈ y
+                x = randn(ComplexF32, 3, 4, 5, 1)
+                y = permutedims(x, (2, 1, 4, 3))
+                Array(GPUArrays._permutedims!(UInt64, AT(zero(y)), AT(x), (2, 1, 4, 3))) ≈ y
             end
         end
         # high dimensional tensor
@@ -76,8 +76,8 @@
                     continue
                 end
                 n = 128
-                areal = randn(n,n)/2
-                aimg  = randn(n,n)/2
+                areal = randn(n, n) / 2
+                aimg = randn(n, n) / 2
                 a = convert(Matrix{eltya}, eltya <: Complex ? complex.(areal, aimg) : areal)
                 @test compare(x -> LinearAlgebra.copytri!(x, uplo, conjugate), AT, a)
             end
@@ -354,7 +354,7 @@
     end
 
     @testset "lmul! and rmul!" begin
-        @testset "$T ($a,$b)" for (a,b) in [((3,4),(4,3)), ((3,), (1,3)), ((1,3), (3))], T in eltypes
+        @testset "$T ($a,$b)" for (a, b) in [((3, 4), (4, 3)), ((3,), (1, 3)), ((1, 3), (3))], T in eltypes
             @test compare(rmul!, AT, rand(T, a), Ref(rand(T)))
             @test compare(lmul!, AT, Ref(rand(T)), rand(T, b))
         end
@@ -362,26 +362,26 @@
 
     @testset "axp{b}y" begin
         @testset "$T" for T in eltypes
-            @test compare(axpby!, AT, Ref(rand(T)), rand(T,5), Ref(rand(T)), rand(T,5))
-            @test compare(axpy!, AT, Ref(rand(T)), rand(T,5), rand(T,5))
+            @test compare(axpby!, AT, Ref(rand(T)), rand(T, 5), Ref(rand(T)), rand(T, 5))
+            @test compare(axpy!, AT, Ref(rand(T)), rand(T, 5), rand(T, 5))
         end
     end
 
     @testset "dot" begin
         @testset "$T" for T in eltypes
-            @test compare(dot, AT, rand(T,5), rand(T, 5))
+            @test compare(dot, AT, rand(T, 5), rand(T, 5))
         end
     end
 
     @testset "rotate!" begin
         @testset "$T" for T in eltypes
-            @test compare(rotate!, AT, rand(T,5), rand(T,5), Ref(rand(real(T))), Ref(rand(T)))
+            @test compare(rotate!, AT, rand(T, 5), rand(T, 5), Ref(rand(real(T))), Ref(rand(T)))
         end
     end
 
     @testset "reflect!" begin
         @testset "$T" for T in eltypes
-            @test compare(reflect!, AT, rand(T,5), rand(T,5), Ref(rand(real(T))), Ref(rand(T)))
+            @test compare(reflect!, AT, rand(T, 5), rand(T, 5), Ref(rand(real(T))), Ref(rand(T)))
         end
     end
 

@christiangnrd

This comment was marked as outdated.

@christiangnrd
Copy link
Member Author

I pushed the improvements I mentioned I'd add. Now that errors are properly displayed in testset results, a failure in gpuarrays/linalg/core looks like this:

Test Summary:                                    | Pass  Fail  Error  Total     Time
  Overall                                        | 3342     2     50   3394  1m24.5s
    gpuarrays/reductions/sum prod                |  358                 358    43.5s
    gpuarrays/reductions/mapreduce               | 1125                1125    54.9s
    gpuarrays/broadcasting                       |  164                 164    56.8s
    gpuarrays/reductions/reduce                  | 1169                1169  1m12.8s
    gpuarrays/linalg                             |  396     2           398  1m14.0s
      adjoint and transpose                      |   12                  12     5.1s
      permutedims                                |    7                   7     4.5s
      symmetric                                  |    2                   2     0.5s
      triangular                                 |  188                 188    15.9s
      diagonal                                   |   32     2            34     4.9s
        Array + Diagonal                         |    1                   1     0.2s
        copy diagonal                            |    3                   3     0.0s
        cholesky + Diagonal                      |    3                   3     1.2s
        \ + Diagonal                             |    3                   3     0.5s
        mul! + Diagonal                          |   10                  10     2.6s
        ldiv! + Diagonal                         |    2     2             4     0.5s
        triu! with diagonal -2                   |    1                   1     0.0s
        triu! with diagonal -1                   |    1                   1     0.0s
        triu! with diagonal 0                    |    1                   1     0.0s
        triu! with diagonal 1                    |    1                   1     0.0s
        triu! with diagonal 2                    |    1                   1     0.0s
        tril! with diagonal -2                   |    1                   1     0.0s
        tril! with diagonal -1                   |    1                   1     0.0s
        tril! with diagonal 0                    |    1                   1     0.0s
        tril! with diagonal 1                    |    1                   1     0.0s
        tril! with diagonal 2                    |    1                   1     0.0s
      lmul! and rmul!                            |    2                   2     0.4s
      lmul! and rmul!                            |    2                   2     0.3s
      lmul! and rmul!                            |    2                   2     0.3s
      lmul! and rmul!                            |    2                   2     0.3s
      lmul! and rmul!                            |    2                   2     0.3s
      lmul! and rmul!                            |    2                   2     0.4s
      lmul! and rmul!                            |    2                   2     0.4s
      lmul! and rmul!                            |    2                   2     0.4s
      lmul! and rmul!                            |    2                   2     0.4s
      lmul! and rmul!                            |    2                   2     0.1s
      lmul! and rmul!                            |    2                   2     0.1s
      lmul! and rmul!                            |    2                   2     0.1s
      lmul! and rmul!                            |    2                   2     0.1s
      lmul! and rmul!                            |    2                   2     0.1s
      lmul! and rmul!                            |    2                   2     0.1s
      axp{b}y                                    |    2                   2     0.4s
      axp{b}y                                    |    2                   2     0.4s
      axp{b}y                                    |    2                   2     0.4s
      axp{b}y                                    |    2                   2     0.4s
      axp{b}y                                    |    2                   2     0.4s
      dot                                        |    1                   1     0.5s
      dot                                        |    1                   1     0.4s
      dot                                        |    1                   1     0.4s
      dot                                        |    1                   1     0.4s
      dot                                        |    1                   1     0.4s
      rotate!                                    |    1                   1     0.2s
      rotate!                                    |    1                   1     0.1s
      rotate!                                    |    1                   1     0.1s
      rotate!                                    |    1                   1     0.1s
      rotate!                                    |    1                   1     0.1s
      reflect!                                   |    1                   1     0.1s
      reflect!                                   |    1                   1     0.1s
      reflect!                                   |    1                   1     0.1s
      reflect!                                   |    1                   1     0.1s
      reflect!                                   |    1                   1     0.1s
      iszero and isone                           |    4                   4     0.8s
      iszero and isone                           |    4                   4     0.6s
      iszero and isone                           |    4                   4     0.6s
      iszero and isone                           |    4                   4     0.7s
      iszero and isone                           |    4                   4     0.6s
      kron                                       |   80                  80    17.2s
    gpuarrays/reductions/mapreducedim!           |  130                 130    30.9s
    gpuarrays/reductions/reducedim!              |                 1      1
    gpuarrays/math/power                         |                 1      1
    gpuarrays/indexing multidimensional          |                 1      1
    gpuarrays/linalg/norm                        |                 1      1
    gpuarrays/statistics                         |                 1      1
    gpuarrays/linalg/mul!/vector-matrix          |                 1      1
    gpuarrays/linalg/mul!/matrix-matrix          |                 1      1
    gpuarrays/ext/jld2                           |                 1      1
    random                                       |                 1      1
    gpuarrays/reductions/== isequal              |                 1      1
    execution                                    |                 1      1
    gpuarrays/indexing find                      |                 1      1
    linalg                                       |                 1      1
    gpuarrays/constructors                       |                 1      1
    gpuarrays/reductions/mapreducedim!_large     |                 1      1
    device/intrinsics/atomics                    |                 1      1
    capturing                                    |                 1      1
    profiling                                    |                 1      1
    device/intrinsics/simd                       |                 1      1
    gpuarrays/random                             |                 1      1
    mps/linalg                                   |                 1      1
    mpsgraphs/linalg                             |                 1      1
    gpuarrays/reductions/any all count           |                 1      1
    device/random                                |                 1      1
    gpuarrays/linalg/NaN_false                   |                 1      1
    gpuarrays/uniformscaling                     |                 1      1
    mtl/metal                                    |                 1      1
    device/intrinsics/arguments                  |                 1      1
    gpuarrays/indexing scalar                    |                 1      1
    mps/copy                                     |                 1      1
    device/intrinsics/synchronization            |                 1      1
    gpuarrays/math/intrinsics                    |                 1      1
    gpuarrays/alloc cache                        |                 1      1
    metallib                                     |                 1      1
    mps/ndarray                                  |                 1      1
    mpsgraphs/core                               |                 1      1
    pool                                         |                 1      1
    mps/matrix                                   |                 1      1
    mps/vector                                   |                 1      1
    mtl/size                                     |                 1      1
    gpuarrays/vectors                            |                 1      1
    mpsgraphs/random                             |                 1      1
    mps/size                                     |                 1      1
    version                                      |                 1      1
    examples                                     |                 1      1
    array                                        |                 1      1
    gpuarrays/base                               |                 1      1
    device/intrinsics/math                       |                 1      1
    kernelabstractions                           |                 1      1
    gpuarrays/reductions/minimum maximum extrema |                 1      1
    FAILURE

After this PR, it'll look like this:

Test Summary:                           | Pass  Fail  Total     Time
  Overall                               |  801     4    805  1m49.6s
    gpuarrays/linalg/NaN_false          |   18           18     8.5s
    gpuarrays/linalg/mul!/vector-matrix |   70           70    17.3s
    gpuarrays/linalg/norm               |  132          132    19.8s
    gpuarrays/linalg/mul!/matrix-matrix |  180          180    20.0s
    gpuarrays/linalg/core               |  401     4    405  1m41.7s
      adjoint and transpose             |   12           12     4.6s
      tr                                |    1            1     1.0s
      permutedims                       |    7            7     4.1s
      symmetric                         |    2            2     0.4s
      triangular                        |  188          188    14.2s
      diagonal                          |   36     4     40    35.6s
        Array + Diagonal                |    1            1     0.2s
        copy diagonal                   |    3            3     0.0s
        cholesky + Diagonal             |    3            3     0.9s
        \ + Diagonal                    |    3            3     0.4s
        mul! + Diagonal                 |   14     2     16    33.8s
          Float32                       |    8            8    17.3s
          ComplexF32                    |    6     2      8    16.5s
        ldiv! + Diagonal                |    2     2      4     0.2s
        triu! with diagonal -2          |    1            1     0.0s
        triu! with diagonal -1          |    1            1     0.0s
        triu! with diagonal 0           |    1            1     0.0s
        triu! with diagonal 1           |    1            1     0.0s
        triu! with diagonal 2           |    1            1     0.0s
        tril! with diagonal -2          |    1            1     0.0s
        tril! with diagonal -1          |    1            1     0.0s
        tril! with diagonal 0           |    1            1     0.0s
        tril! with diagonal 1           |    1            1     0.0s
        tril! with diagonal 2           |    1            1     0.0s
      lmul! and rmul!                   |   30           30     3.4s
      axp{b}y                           |   10           10     1.9s
      dot                               |    5            5     1.9s
      rotate!                           |    5            5     0.8s
      reflect!                          |    5            5     0.6s
      iszero and isone                  |   20           20     3.2s
      kron                              |   80           80    15.8s
    FAILURE

@christiangnrd christiangnrd requested a review from maleadt October 22, 2025 00:53
@christiangnrd christiangnrd changed the title [NFC] Minor test improvements Minor test improvements Oct 22, 2025
@christiangnrd
Copy link
Member Author

I added one last PR. This is definitely ready for review, the only changes I'll be making are fixes/review comments

@christiangnrd christiangnrd enabled auto-merge (squash) October 23, 2025 12:01
@christiangnrd christiangnrd merged commit 1901868 into JuliaGPU:master Oct 23, 2025
19 checks passed
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