From 8e4857e282a462af4280c8e52eb20a0efa6618a1 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 20 Aug 2025 17:53:23 -0400 Subject: [PATCH 1/2] Remove LazyArrays.jl dependency MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Removed LazyArrays from Project.toml dependencies - Replaced BroadcastArray(@~ .-(λ .* tu)) with simple broadcast .-(λ .* tu) in adjoint.jl - Updated tests to check for AbstractMatrix instead of BroadcastArray - All tests pass successfully --- Project.toml | 2 -- src/LinearSolve.jl | 1 - src/adjoint.jl | 2 +- test/Project.toml | 5 +++++ test/adjoint.jl | 9 ++++----- 5 files changed, 10 insertions(+), 9 deletions(-) create mode 100644 test/Project.toml diff --git a/Project.toml b/Project.toml index 8b141718d..cbf882b88 100644 --- a/Project.toml +++ b/Project.toml @@ -12,7 +12,6 @@ EnumX = "4e289a0a-7415-4d19-859d-a7e5c4648b56" GPUArraysCore = "46192b85-c4d5-4398-a991-12ede77f4527" InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240" Krylov = "ba0b0d4f-ebba-5204-a429-3ac8c609bfb7" -LazyArrays = "5078a376-72f3-5289-bfd5-ec5146d43c02" Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" MKL_jll = "856f044c-d86e-5d09-b602-aeab76dc8ba7" @@ -105,7 +104,6 @@ Krylov = "0.10" KrylovKit = "0.10" KrylovPreconditioners = "0.3" LAPACK_jll = "3" -LazyArrays = "2.3" Libdl = "1.10" LinearAlgebra = "1.10" MPI = "0.20" diff --git a/src/LinearSolve.jl b/src/LinearSolve.jl index eca4f0692..c85d8579c 100644 --- a/src/LinearSolve.jl +++ b/src/LinearSolve.jl @@ -15,7 +15,6 @@ using LinearAlgebra: LinearAlgebra, BlasInt, LU, Adjoint, BLAS, Bidiagonal, Bunc cholesky, cholesky!, diagind, dot, inv, ldiv!, ldlt!, lu, lu!, mul!, norm, qr, qr!, svd, svd! -using LazyArrays: @~, BroadcastArray using SciMLBase: SciMLBase, LinearAliasSpecifier, AbstractSciMLOperator, init, solve!, reinit!, solve, ReturnCode, LinearProblem using SciMLOperators: SciMLOperators, AbstractSciMLOperator, IdentityOperator, diff --git a/src/adjoint.jl b/src/adjoint.jl index 281a1ee69..5ffedaa0e 100644 --- a/src/adjoint.jl +++ b/src/adjoint.jl @@ -84,7 +84,7 @@ function CRC.rrule(::typeof(SciMLBase.solve), prob::LinearProblem, end tu = adjoint(sol.u) - ∂A = BroadcastArray(@~ .-(λ .* tu)) + ∂A = .-(λ .* tu) ∂b = λ ∂prob = LinearProblem(∂A, ∂b, ∂∅) diff --git a/test/Project.toml b/test/Project.toml new file mode 100644 index 000000000..c7ab92111 --- /dev/null +++ b/test/Project.toml @@ -0,0 +1,5 @@ +[deps] +FiniteDiff = "6a86dc24-6348-571c-b903-95158fe2bd41" +ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" +RecursiveFactorization = "f2c3362d-daeb-58d1-803e-2bc74f2840b4" +Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f" diff --git a/test/adjoint.jl b/test/adjoint.jl index d599162df..3ecf0a8b5 100644 --- a/test/adjoint.jl +++ b/test/adjoint.jl @@ -1,7 +1,6 @@ using Zygote, ForwardDiff using LinearSolve, LinearAlgebra, Test using FiniteDiff, RecursiveFactorization -using LazyArrays: BroadcastArray n = 4 A = rand(n, n); @@ -19,7 +18,7 @@ end f(A, b1) # Uses BLAS dA, db1 = Zygote.gradient(f, A, b1) -@test dA isa BroadcastArray +@test dA isa AbstractMatrix dA2 = ForwardDiff.gradient(x -> f(x, eltype(x).(b1)), copy(A)) db12 = ForwardDiff.gradient(x -> f(eltype(x).(A), x), copy(b1)) @@ -37,7 +36,7 @@ _ff = (x, _ff(copy(A), copy(b1)) dA, db1 = Zygote.gradient(_ff, copy(A), copy(b1)) -@test dA isa BroadcastArray +@test dA isa AbstractMatrix dA2 = ForwardDiff.gradient(x -> f(x, eltype(x).(b1)), copy(A)) db12 = ForwardDiff.gradient(x -> f(eltype(x).(A), x), copy(b1)) @@ -58,7 +57,7 @@ function f3(A, b1, b2; alg = KrylovJL_GMRES()) end dA, db1, db2 = Zygote.gradient(f3, A, b1, b1) -@test dA isa BroadcastArray +@test dA isa AbstractMatrix dA2 = FiniteDiff.finite_difference_gradient( x -> f3(x, eltype(x).(b1), eltype(x).(b1)), copy(A)) @@ -83,7 +82,7 @@ function f4(A, b1, b2; alg = LUFactorization()) end dA, db1, db2 = Zygote.gradient(f4, A, b1, b1) -@test dA isa BroadcastArray +@test dA isa AbstractMatrix dA2 = ForwardDiff.gradient(x -> f4(x, eltype(x).(b1), eltype(x).(b1)), copy(A)) db12 = ForwardDiff.gradient(x -> f4(eltype(x).(A), x, eltype(x).(b1)), copy(b1)) From b2c898966d965a51790deb14b3e4c278876a5bd1 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Thu, 21 Aug 2025 06:58:41 -0400 Subject: [PATCH 2/2] Delete test/Project.toml --- test/Project.toml | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 test/Project.toml diff --git a/test/Project.toml b/test/Project.toml deleted file mode 100644 index c7ab92111..000000000 --- a/test/Project.toml +++ /dev/null @@ -1,5 +0,0 @@ -[deps] -FiniteDiff = "6a86dc24-6348-571c-b903-95158fe2bd41" -ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" -RecursiveFactorization = "f2c3362d-daeb-58d1-803e-2bc74f2840b4" -Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"