From 316dad4e008634ef39fa404d7e79babaa06b9757 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Thu, 27 Jun 2024 10:12:46 +0800 Subject: [PATCH 1/6] Remove recompile_invalidations `@recompile_invalidations` should only be used in very specific scenarios, and this is not one of those scenarios. Also, there are big changes being done with https://github.com/SciML/CommonWorldInvalidations.jl. With that, we only need to `@recompile_invalidations` on a few entry points. In particular, Static.jl, Symbolics.jl, and preferably ForwardDiff.jl and StaticArrays.jl would adopt it too. But this means that in order to handle all of this effectively, in SciML we only need to apply it on Static.jl, Symbolics.jl, and SciMLBase.jl and the whole ecosystem should be fine. In any case, this library doesn't need it. It shouldn't make a tangible difference in compile times, while it increases precompile times by a lot. --- src/NonlinearSolve.jl | 98 +++++++++++++++++++++---------------------- 1 file changed, 48 insertions(+), 50 deletions(-) diff --git a/src/NonlinearSolve.jl b/src/NonlinearSolve.jl index 180c47954..afb2f18f9 100644 --- a/src/NonlinearSolve.jl +++ b/src/NonlinearSolve.jl @@ -5,56 +5,54 @@ if isdefined(Base, :Experimental) && isdefined(Base.Experimental, Symbol("@max_m end using Reexport: @reexport -using PrecompileTools: @recompile_invalidations, @compile_workload, @setup_workload - -@recompile_invalidations begin - using ADTypes: ADTypes, AutoFiniteDiff, AutoForwardDiff, AutoPolyesterForwardDiff, - AutoZygote, AutoEnzyme, AutoSparse - # FIXME: deprecated, remove in future - using ADTypes: AutoSparseFiniteDiff, AutoSparseForwardDiff, - AutoSparsePolyesterForwardDiff, AutoSparseZygote - - using ArrayInterface: ArrayInterface, can_setindex, restructure, fast_scalar_indexing, - ismutable - using ConcreteStructs: @concrete - using DiffEqBase: DiffEqBase, AbstractNonlinearTerminationMode, - AbstractSafeBestNonlinearTerminationMode, AbsNormTerminationMode, - AbsSafeBestTerminationMode, AbsSafeTerminationMode, - AbsTerminationMode, NormTerminationMode, RelNormTerminationMode, - RelSafeBestTerminationMode, RelSafeTerminationMode, - RelTerminationMode, SimpleNonlinearSolveTerminationMode, - SteadyStateDiffEqTerminationMode - using FastBroadcast: @.. - using FastClosures: @closure - using FiniteDiff: FiniteDiff - using ForwardDiff: ForwardDiff, Dual - using LazyArrays: LazyArrays, ApplyArray, cache - using LinearAlgebra: LinearAlgebra, ColumnNorm, Diagonal, I, LowerTriangular, Symmetric, - UpperTriangular, axpy!, cond, diag, diagind, dot, issuccess, - istril, istriu, lu, mul!, norm, pinv, tril!, triu! - using LineSearches: LineSearches - using LinearSolve: LinearSolve, LUFactorization, QRFactorization, ComposePreconditioner, - InvPreconditioner, needs_concrete_A, AbstractFactorization, - DefaultAlgorithmChoice, DefaultLinearSolver - using MaybeInplace: @bb - using Printf: @printf - using Preferences: Preferences, @load_preference, @set_preferences! - using RecursiveArrayTools: recursivecopy!, recursivefill! - using SciMLBase: AbstractNonlinearAlgorithm, JacobianWrapper, AbstractNonlinearProblem, - AbstractSciMLOperator, _unwrap_val, has_jac, isinplace, NLStats - using SparseArrays: AbstractSparseMatrix, SparseMatrixCSC - using SparseDiffTools: SparseDiffTools, AbstractSparsityDetection, - ApproximateJacobianSparsity, JacPrototypeSparsityDetection, - NoSparsityDetection, PrecomputedJacobianColorvec, - SymbolicsSparsityDetection, auto_jacvec, auto_jacvec!, - auto_vecjac, init_jacobian, num_jacvec, num_jacvec!, num_vecjac, - num_vecjac!, sparse_jacobian, sparse_jacobian!, - sparse_jacobian_cache - using StaticArraysCore: StaticArray, SVector, SArray, MArray, Size, SMatrix - using SymbolicIndexingInterface: SymbolicIndexingInterface, ParameterIndexingProxy, - symbolic_container, parameter_values, state_values, - getu, setu -end +using PrecompileTools: @compile_workload, @setup_workload + +using ADTypes: ADTypes, AutoFiniteDiff, AutoForwardDiff, AutoPolyesterForwardDiff, + AutoZygote, AutoEnzyme, AutoSparse +# FIXME: deprecated, remove in future +using ADTypes: AutoSparseFiniteDiff, AutoSparseForwardDiff, + AutoSparsePolyesterForwardDiff, AutoSparseZygote + +using ArrayInterface: ArrayInterface, can_setindex, restructure, fast_scalar_indexing, + ismutable +using ConcreteStructs: @concrete +using DiffEqBase: DiffEqBase, AbstractNonlinearTerminationMode, + AbstractSafeBestNonlinearTerminationMode, AbsNormTerminationMode, + AbsSafeBestTerminationMode, AbsSafeTerminationMode, + AbsTerminationMode, NormTerminationMode, RelNormTerminationMode, + RelSafeBestTerminationMode, RelSafeTerminationMode, + RelTerminationMode, SimpleNonlinearSolveTerminationMode, + SteadyStateDiffEqTerminationMode +using FastBroadcast: @.. +using FastClosures: @closure +using FiniteDiff: FiniteDiff +using ForwardDiff: ForwardDiff, Dual +using LazyArrays: LazyArrays, ApplyArray, cache +using LinearAlgebra: LinearAlgebra, ColumnNorm, Diagonal, I, LowerTriangular, Symmetric, + UpperTriangular, axpy!, cond, diag, diagind, dot, issuccess, + istril, istriu, lu, mul!, norm, pinv, tril!, triu! +using LineSearches: LineSearches +using LinearSolve: LinearSolve, LUFactorization, QRFactorization, ComposePreconditioner, + InvPreconditioner, needs_concrete_A, AbstractFactorization, + DefaultAlgorithmChoice, DefaultLinearSolver +using MaybeInplace: @bb +using Printf: @printf +using Preferences: Preferences, @load_preference, @set_preferences! +using RecursiveArrayTools: recursivecopy!, recursivefill! +using SciMLBase: AbstractNonlinearAlgorithm, JacobianWrapper, AbstractNonlinearProblem, + AbstractSciMLOperator, _unwrap_val, has_jac, isinplace, NLStats +using SparseArrays: AbstractSparseMatrix, SparseMatrixCSC +using SparseDiffTools: SparseDiffTools, AbstractSparsityDetection, + ApproximateJacobianSparsity, JacPrototypeSparsityDetection, + NoSparsityDetection, PrecomputedJacobianColorvec, + SymbolicsSparsityDetection, auto_jacvec, auto_jacvec!, + auto_vecjac, init_jacobian, num_jacvec, num_jacvec!, num_vecjac, + num_vecjac!, sparse_jacobian, sparse_jacobian!, + sparse_jacobian_cache +using StaticArraysCore: StaticArray, SVector, SArray, MArray, Size, SMatrix +using SymbolicIndexingInterface: SymbolicIndexingInterface, ParameterIndexingProxy, + symbolic_container, parameter_values, state_values, + getu, setu @reexport using SciMLBase, SimpleNonlinearSolve From ecc8251f987adf2079edb6f4099a87b993159ded Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Thu, 27 Jun 2024 10:24:40 +0800 Subject: [PATCH 2/6] Update src/NonlinearSolve.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- src/NonlinearSolve.jl | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/NonlinearSolve.jl b/src/NonlinearSolve.jl index afb2f18f9..e1ab2f90f 100644 --- a/src/NonlinearSolve.jl +++ b/src/NonlinearSolve.jl @@ -18,11 +18,10 @@ using ArrayInterface: ArrayInterface, can_setindex, restructure, fast_scalar_ind using ConcreteStructs: @concrete using DiffEqBase: DiffEqBase, AbstractNonlinearTerminationMode, AbstractSafeBestNonlinearTerminationMode, AbsNormTerminationMode, - AbsSafeBestTerminationMode, AbsSafeTerminationMode, - AbsTerminationMode, NormTerminationMode, RelNormTerminationMode, - RelSafeBestTerminationMode, RelSafeTerminationMode, - RelTerminationMode, SimpleNonlinearSolveTerminationMode, - SteadyStateDiffEqTerminationMode + AbsSafeBestTerminationMode, AbsSafeTerminationMode, AbsTerminationMode, + NormTerminationMode, RelNormTerminationMode, RelSafeBestTerminationMode, + RelSafeTerminationMode, RelTerminationMode, + SimpleNonlinearSolveTerminationMode, SteadyStateDiffEqTerminationMode using FastBroadcast: @.. using FastClosures: @closure using FiniteDiff: FiniteDiff From 482c851106b427e1324dd780d0eaefb6c7bec3fd Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Thu, 27 Jun 2024 10:24:45 +0800 Subject: [PATCH 3/6] Update src/NonlinearSolve.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- src/NonlinearSolve.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/NonlinearSolve.jl b/src/NonlinearSolve.jl index e1ab2f90f..8b20a44e7 100644 --- a/src/NonlinearSolve.jl +++ b/src/NonlinearSolve.jl @@ -10,8 +10,8 @@ using PrecompileTools: @compile_workload, @setup_workload using ADTypes: ADTypes, AutoFiniteDiff, AutoForwardDiff, AutoPolyesterForwardDiff, AutoZygote, AutoEnzyme, AutoSparse # FIXME: deprecated, remove in future -using ADTypes: AutoSparseFiniteDiff, AutoSparseForwardDiff, - AutoSparsePolyesterForwardDiff, AutoSparseZygote +using ADTypes: AutoSparseFiniteDiff, AutoSparseForwardDiff, AutoSparsePolyesterForwardDiff, + AutoSparseZygote using ArrayInterface: ArrayInterface, can_setindex, restructure, fast_scalar_indexing, ismutable From 4ce32db6ce9753d109f9650a0e8b05b1d96aa712 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Thu, 27 Jun 2024 10:24:51 +0800 Subject: [PATCH 4/6] Update src/NonlinearSolve.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- src/NonlinearSolve.jl | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/NonlinearSolve.jl b/src/NonlinearSolve.jl index 8b20a44e7..ea7b3ed73 100644 --- a/src/NonlinearSolve.jl +++ b/src/NonlinearSolve.jl @@ -44,10 +44,9 @@ using SparseArrays: AbstractSparseMatrix, SparseMatrixCSC using SparseDiffTools: SparseDiffTools, AbstractSparsityDetection, ApproximateJacobianSparsity, JacPrototypeSparsityDetection, NoSparsityDetection, PrecomputedJacobianColorvec, - SymbolicsSparsityDetection, auto_jacvec, auto_jacvec!, - auto_vecjac, init_jacobian, num_jacvec, num_jacvec!, num_vecjac, - num_vecjac!, sparse_jacobian, sparse_jacobian!, - sparse_jacobian_cache + SymbolicsSparsityDetection, auto_jacvec, auto_jacvec!, auto_vecjac, + init_jacobian, num_jacvec, num_jacvec!, num_vecjac, num_vecjac!, + sparse_jacobian, sparse_jacobian!, sparse_jacobian_cache using StaticArraysCore: StaticArray, SVector, SArray, MArray, Size, SMatrix using SymbolicIndexingInterface: SymbolicIndexingInterface, ParameterIndexingProxy, symbolic_container, parameter_values, state_values, From 8a69073cd0ad00cd5a1d91fe16a0b14593344803 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Thu, 27 Jun 2024 10:24:56 +0800 Subject: [PATCH 5/6] Update src/NonlinearSolve.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- src/NonlinearSolve.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/NonlinearSolve.jl b/src/NonlinearSolve.jl index ea7b3ed73..830a18196 100644 --- a/src/NonlinearSolve.jl +++ b/src/NonlinearSolve.jl @@ -28,8 +28,8 @@ using FiniteDiff: FiniteDiff using ForwardDiff: ForwardDiff, Dual using LazyArrays: LazyArrays, ApplyArray, cache using LinearAlgebra: LinearAlgebra, ColumnNorm, Diagonal, I, LowerTriangular, Symmetric, - UpperTriangular, axpy!, cond, diag, diagind, dot, issuccess, - istril, istriu, lu, mul!, norm, pinv, tril!, triu! + UpperTriangular, axpy!, cond, diag, diagind, dot, issuccess, istril, + istriu, lu, mul!, norm, pinv, tril!, triu! using LineSearches: LineSearches using LinearSolve: LinearSolve, LUFactorization, QRFactorization, ComposePreconditioner, InvPreconditioner, needs_concrete_A, AbstractFactorization, From f3e13c9c6f58bb3fd61ca6e04bae4be6d1947e75 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Thu, 27 Jun 2024 10:25:01 +0800 Subject: [PATCH 6/6] Update src/NonlinearSolve.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- src/NonlinearSolve.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/NonlinearSolve.jl b/src/NonlinearSolve.jl index 830a18196..781f6eae9 100644 --- a/src/NonlinearSolve.jl +++ b/src/NonlinearSolve.jl @@ -49,8 +49,8 @@ using SparseDiffTools: SparseDiffTools, AbstractSparsityDetection, sparse_jacobian, sparse_jacobian!, sparse_jacobian_cache using StaticArraysCore: StaticArray, SVector, SArray, MArray, Size, SMatrix using SymbolicIndexingInterface: SymbolicIndexingInterface, ParameterIndexingProxy, - symbolic_container, parameter_values, state_values, - getu, setu + symbolic_container, parameter_values, state_values, getu, + setu @reexport using SciMLBase, SimpleNonlinearSolve