`tril` and `triu` on `JLSparseMatrixCSC` both raise a method error

Aperta Adatta ai principianti
#881 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
74/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
julia
Ambito
backend, testing

Direzione di ricerca

La segnalazione indica le righe 145 e 152 di src/host/sparse.jl, dove triu e tril chiamano coo_type(A). Inizia leggendo questi metodi e verificando come i tipi di matrici sparse definiscono coo_type; la riproduzione usa una matrice Float32 2×2 e confronta JLArrays con CUDA. Il lavoro è completato quando entrambe le operazioni funzionano con JLSparseMatrixCSC e conservano le voci fuori diagonale previste.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Description

Both tril(A, 0) and triu(A, 0) throw the same MethodError on a 2×2 Float32 JLSparseMatrixCSC. The matrix is constructed successfully. Both operations succeed on a CuSparseMatrixCSC constructed from the same input.

Reproduction

Run in a Julia project with the packages listed below and a CUDA-capable GPU.

using JLArrays: JLSparseMatrixCSC
using CUDA.cuSPARSE: CuSparseMatrixCSC
using SparseArrays: sparse
using LinearAlgebra: tril, triu

host = sparse(Float32[0 2; 3 0])
for (backend, CSC) in (("JLArrays", JLSparseMatrixCSC), ("CUDA", CuSparseMatrixCSC))
    A = CSC(host)
    for op in (tril, triu)
        try
            result = op(A, 0)
            println(backend, " ", op, ": ", Array(result))
        catch err
            println(backend, " ", op, ": ", first(eachsplit(sprint(showerror, err), '\n')))
        end
    end
end

Observed output

JLArrays tril: MethodError: no method matching coo_type(::Type{JLSparseMatrixCSC{Float32, Int64}})
JLArrays triu: MethodError: no method matching coo_type(::Type{JLSparseMatrixCSC{Float32, Int64}})
CUDA tril: Float32[0.0 0.0; 3.0 0.0]
CUDA triu: Float32[0.0 2.0; 0.0 0.0]

Expected behavior

With offset zero, both operations should retain the main diagonal. For this input, tril should retain the lower entry A[2, 1] == 3, and triu should retain the upper entry A[1, 2] == 2. The CUDA results above show the expected matrices.

Additional context

In GPUArrays.jl 12.3.0, the stack traces point to src/host/sparse.jl:152 for tril and src/host/sparse.jl:145 for triu. Both methods call coo_type(A), and both report that no method matches coo_type(::Type{JLSparseMatrixCSC{Float32, Int64}}).

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
Lingua principale
Julia
Stelle
462
Fork
109
Merge medio
4g 11h
PR unite (30g)
26

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di JuliaGPU/GPUArrays.jl

Tutte le issue di JuliaGPU/GPUArrays.jl

Issue simili

Altre issue su Julia

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.