[TTFX] Use Packages Extensions to drop Zygote and others when not used.
TaylorDiff is depending on a lot of stuff it should not, which tanks my TTFX.
As already noted in https://github.com/JuliaDiff/TaylorDiff.jl/issues/52#issuecomment-1707801903_ , It would be very beneficial to leverage package preferences to avoid, say, having Zygote and ReverseDiff as dependencies. Formally, the composability with the AD systems is not a core functionality of the package and could be loaded ONLY when those AD systems are loaded.
Taking a second look at this, It appear to me that it is only the last two files derivatives.jl and chainrules.jl that are really problematic.
-
In
derivatives.jl, there is a dependency on the (old) SlicedMap.jl, which brings a lot of stuff with it. Since it is only used for three calls to theirmapfunctions, maybe you could reconsider and ditch it ? If you are worried about your perfs on Zygote stuff, then read point 2) -
In
chainrules.jl, the code is there to support a usecase with Zygote and/or with other AD systems. This code should definitely go into one (or two?) package extensions files so that loading Zygote and Chainrules is not necessary if I do not use them. The special overloades from SlicedMap.jl that are there for Zygote perfs could also be part of this package extension.
Tell me what you think
-
The dependency SlicedMap.jl has been removed. We have introduced a more efficient implementation.
-
We are loading Zygote.jl for solving some issues in it, we will consider integrating ZygoteRules.jl as a weak dependency in the future. We can't remove Chainrules.jl, because we need to use 'frule's.
For SliceMap: Thanks for removing it !
For Zygote : by weak-dep you mean package extension, right ?
Zygote has been added as an extension in https://github.com/JuliaDiff/TaylorDiff.jl/commit/c11dd72ce8dc2eaf1ffc2def171edd50ebe72632