Skip to content

Define LU factorization for JLArray - #757

Draft
ChrisRackauckas-Claude wants to merge 1 commit into
JuliaGPU:mainfrom
ChrisRackauckas-Claude:agent/jlarray-lu
Draft

Define LU factorization for JLArray#757
ChrisRackauckas-Claude wants to merge 1 commit into
JuliaGPU:mainfrom
ChrisRackauckas-Claude:agent/jlarray-lu

Conversation

@ChrisRackauckas-Claude

@ChrisRackauckas-Claude ChrisRackauckas-Claude commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Ignore this PR until reviewed by @ChrisRackauckas.

Summary

JLArrays now defines LinearAlgebra.lu for JLArray matrices by explicitly copying to the host representation before calling host LU. Matching ldiv! methods copy right-hand sides through host memory so the returned factorization can be used by solver code without triggering JLArray to Ptr conversion.

This addresses the regression described in SciML/OrdinaryDiffEq.jl#4179. JLArrays 0.3.2 intentionally rejects implicit CPU pointer conversion, while the generic LinearAlgebra LU path still reaches LAPACK with a JLArray.

Verification

Before the fix, on the unmodified branch:

julia --project=test --startup-file=no -e 'using JLArrays, LinearAlgebra; A = jl([2.0 1.0; 1.0 3.0]); lu(A; check = false)'

failed with:

ERROR: Illegal conversion of a JLArray to a Ptr
[3] getrf!(A::JLArray{Float64, 2}, ipiv::JLArray{Int64, 1}; check::Bool)
    @ LinearAlgebra.LAPACK .../LinearAlgebra/src/lapack.jl:587

With this patch:

julia --project=test --startup-file=no test/jlarrays_lu.jl

passed:

Test Summary: | Pass  Total  Time
JLArray LU    |    3      3  1.3s

The OrdinaryDiffEq reproduction also passed for both TRBDF2 and Rodas5P:

(SciMLBase.ReturnCode.Success, SciMLBase.ReturnCode.Success, [0.04713496106370036, 0.04713496106370036, 0.04713496106370036])

The full GPUArrays suite passed:

Test Summary: |  Pass  Total      Time
  Overall     | 21022  21022  16m23.0s
   SUCCESS
    Testing GPUArrays tests passed

Also ran typos on the changed files and git diff --check. GPU-specific backends and downstream packages were not tested.

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
@ChrisRackauckas

Copy link
Copy Markdown
Member

It was effectively doing this before the pointer conversion was removed

@kshyatt

kshyatt commented Aug 14, 2026

Copy link
Copy Markdown
Member

Brother what is this PR description

@ChrisRackauckas

Copy link
Copy Markdown
Member

ehh have your llm summarize it.

@ChrisRackauckas

Copy link
Copy Markdown
Member

Anything left here?

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.

3 participants