Matrix exponential of a `1×1` `JLSparseMatrixCSC` fails with scalar indexing both disabled and enabled

Đang mở
#879 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
57/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
julia
Lĩnh vực
backend

Hướng nghiên cứu

The reported stack traces point to src/host/sparse.jl:216 and, with scalar indexing disabled, src/host/indexing.jl:50. Start by reading those paths and the sparse matrix exponential dispatch for JLSparseMatrixCSC; reproduce with the provided 1×1 Float32 example under both scalar-indexing settings. Done when exp(a) returns approximately 1.868246 with scalar indexing disabled.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Description

Calling exp(a) on a 1×1 Float32 sparse matrix fails on JLArrays under both scalar-indexing settings. With allowscalar(false), it raises a scalar-indexing error. With allowscalar(true), it reaches a missing constructor for JLSparseMatrixCSC{Float32, Int64}. CUDA returns the same matrix exponential in both runs.

Reproduction

Run the following script in a fresh Julia process with the packages listed below and a CUDA-capable GPU. The second iteration enables scalar indexing to expose the next failure.

using CUDA, JLArrays
using JLArrays: JLSparseMatrixCSC
using CUDA.cuSPARSE: CuSparseMatrixCSC
using SparseArrays: sparse
using GPUArrays: allowscalar

for enabled in (false, true)
    println("allowscalar(", enabled, "):")
    allowscalar(enabled)
    for (backend, array) in (("JLArrays", JLSparseMatrixCSC), ("CUDA", CuSparseMatrixCSC))
        try
            a = array(sparse(Float32[0.625]))
            result = exp(a)
            println(backend, ": ", Array(result))
        catch err
            println(backend, ": ", first(eachsplit(sprint(showerror, err), '\n')))
        end
    end
end

Observed output

allowscalar(false):
JLArrays: Scalar indexing is disallowed.
CUDA: Float32[1.8682458;;]

allowscalar(true):
JLArrays: MethodError: no method matching JLSparseMatrixCSC{Float32, Int64}(::SparseArrays.SparseMatrixCSC{Float32, Int64})
CUDA: Float32[1.8682458;;]

Expected behavior

For this 1×1 matrix, the only entry in the matrix exponential should be approximately 1.868246, the exponential of 0.625. I would expect the JLArrays sparse implementation to compute this value with scalar indexing disabled.

Additional context

Both input constructors succeeded under both settings. The resulting matrices had types JLSparseMatrixCSC{Float32, Int64} and CuSparseMatrixCSC{Float32, Int32}, each with size (1, 1).

Both JLArrays exceptions arose inside exp(a), before the copy to the host. In GPUArrays.jl 12.3.0, both stack traces point to src/host/sparse.jl:216. With scalar indexing disabled, the stack also includes getindex at src/host/indexing.jl:50. With it enabled, the exception identifies a host SparseMatrixCSC{Float32, Int64} as the argument to the missing constructor.

Environment

  • Julia 1.13.4 on Debian GNU/Linux 13 (x86_64, Docker)
  • GPUArrays.jl 12.3.0, JLArrays.jl 0.5.0, CUDA.jl 6.5.1
  • JLArrays CPU device: Intel Core i7-11700
  • CUDA device: NVIDIA GeForce RTX 4090, CUDA runtime 12.9.0, NVIDIA driver 595.99.02
Ngôn ngữ chính
Julia
Star
462
Fork
109
Merge trung bình
4 ngày 11 giờ
Pull request đã merge (30 ngày)
26

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của JuliaGPU/GPUArrays.jl

Tất cả issue của JuliaGPU/GPUArrays.jl

Issue tương tự

Thêm issue về Julia

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.