Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Power of adjoint of CuSparseMatrix does not work anymore #2255

Open
albertomercurio opened this issue Jan 29, 2024 · 3 comments
Open

Power of adjoint of CuSparseMatrix does not work anymore #2255

albertomercurio opened this issue Jan 29, 2024 · 3 comments
Labels
bug Something isn't working cuda libraries Stuff about CUDA library wrappers. help wanted Extra attention is needed

Comments

@albertomercurio
Copy link
Contributor

Describe the bug

The power of the adjoint of a CuSparseMatrix does not work anymore. It is only related to Julia v1.10 and not to previous versions.

To reproduce

The Minimal Working Example (MWE) for this bug:

using CUDA
using CUDA.CUSPARSE
CUDA.allowscalar(false)
using LinearAlgebra
using SparseArrays

A = sprand(ComplexF64, 100, 100, 0.1)
A_gpu = cu(A)

julia> A_gpu'^2
ERROR: MethodError: no method matching CuSparseMatrixCSC{ComplexF64, Int32}(::Adjoint{ComplexF64, CuSparseMatrixCSC{ComplexF64, Int32}})

Closest candidates are:
  CuSparseMatrixCSC{Tv, Ti}(::CuArray{<:Integer, 1}, ::CuArray{<:Integer, 1}, ::CuArray{T, 1} where T, ::Tuple{var"#s1271", var"#s1271"} where var"#s1271"<:Integer) where {Tv, Ti<:Integer}
   @ CUDA ~/.julia/packages/CUDA/rXson/lib/cusparse/array.jl:43
  CuSparseMatrixCSC{Tv, Ti}(::Diagonal) where {Tv, Ti}
   @ CUDA ~/.julia/packages/CUDA/rXson/lib/cusparse/conversions.jl:241

Stacktrace:
 [1] convert(T::Type{CuSparseMatrixCSC{ComplexF64, Int32}}, m::Adjoint{ComplexF64, CuSparseMatrixCSC{ComplexF64, Int32}})
   @ CUDA.CUSPARSE ~/.julia/packages/CUDA/rXson/lib/cusparse/array.jl:16
 [2] to_power_type(x::Adjoint{ComplexF64, CuSparseMatrixCSC{ComplexF64, Int32}})
   @ Base ./intfuncs.jl:261
 [3] power_by_squaring(x_::Adjoint{ComplexF64, CuSparseMatrixCSC{ComplexF64, Int32}}, p::Int64)
   @ Base ./intfuncs.jl:276
 [4] ^(A::Adjoint{ComplexF64, CuSparseMatrixCSC{ComplexF64, Int32}}, p::Int64)
   @ LinearAlgebra ~/.julia/juliaup/julia-1.10.0+0.x64.linux.gnu/share/julia/stdlib/v1.10/LinearAlgebra/src/dense.jl:479
 [5] literal_pow(f::typeof(^), x::Adjoint{ComplexF64, CuSparseMatrixCSC{ComplexF64, Int32}}, ::Val{2})
   @ Base ./intfuncs.jl:351
 [6] top-level scope
   @ REPL[8]:1
 [7] top-level scope
   @ ~/.julia/packages/CUDA/rXson/src/initialization.jl:208

Version info

Details on Julia:

Julia Version 1.10.0
Commit 3120989f39b (2023-12-25 18:01 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 32 × 13th Gen Intel(R) Core(TM) i9-13900KF
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, goldmont)
  Threads: 24 on 32 virtual cores
Environment:
  JULIA_NUM_THREADS = 16

Details on CUDA:

CUDA runtime 12.3, artifact installation
CUDA driver 12.3
NVIDIA driver 546.9.0

CUDA libraries:
- CUBLAS: 12.3.4
- CURAND: 10.3.4
- CUFFT: 11.0.12
- CUSOLVER: 11.5.4
- CUSPARSE: 12.2.0
- CUPTI: 21.0.0
- NVML: 12.0.0+545.30

Julia packages:
- CUDA: 5.1.2
- CUDA_Driver_jll: 0.7.0+1
- CUDA_Runtime_jll: 0.10.1+0

Toolchain:
- Julia: 1.10.0
- LLVM: 15.0.7

1 device:
  0: NVIDIA GeForce RTX 4090 (sm_89, 20.981 GiB / 23.988 GiB available)
@albertomercurio albertomercurio added the bug Something isn't working label Jan 29, 2024
@maleadt
Copy link
Member

maleadt commented Feb 14, 2024

Works for me on 1.10 using the latest CUDA.jl.

@maleadt maleadt added the needs information Further information is requested label Feb 14, 2024
@albertomercurio
Copy link
Contributor Author

I still have the same error with Julia v1.10.1

@maleadt
Copy link
Member

maleadt commented Jul 19, 2024

The problem seems to be that Base._return_type(*, Tuple{typeof(A_gpu'), typeof(A_gpu')}), which is used by Base.to_power_type, now returns CuSparseMatrixCSC{ComplexF64, Int32} where it used to return Any. And we don't have a CuSparseMatrixCSC constructor taking an Adjoint{CuSparseMatrixCSC}. I'm not sure what the purpose is of to_power_type if power_by_squaring for p=2 simply does x*x and returns that...

@maleadt maleadt added help wanted Extra attention is needed cuda libraries Stuff about CUDA library wrappers. and removed needs information Further information is requested labels Jul 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cuda libraries Stuff about CUDA library wrappers. help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants