-
Notifications
You must be signed in to change notification settings - Fork 146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create lightweight package AbstractDualNumbers or ForwardDiffBase or similar? #518
Comments
Note we already have DualNumbers.jl. I believe the plan is to move |
JuliaDiff/DualNumbers.jl#45 would be nice ... |
I think #45 is definitely the way to go, but ForwardDiff.Dual definitely needs some work to make it easy to use (beginning with pretty printing). |
i was looking at JuliaDiff/DualNumbers.jl#45, JuliaDiff/DualNumbers.jl#49 and the source code of DualNumbers.jl, and for hyphotetically embarking on such migration (lets call it FD DualNumber), i have some questions (and observations):
Are there any additional things to be done apart from the list above? |
Most of the load time of ForwardDiff is actually due to StaticArrays - that is, I think, only used for the Hessian, Jabobian, etc. functionality, so a package focused on dual-numbers should load very quickly. |
I think if it's lightweight enough there would be a chance to convince SpecialFunctions, NaNMath, etc. to support it, instead of the other way round. |
Supporting ChainRulesCore would open so many doors. StatsFuns, for example, defines a lof of |
One possibly crazy idea would be to move the minimal struct definitions to ChainRulesCore, as |
Coming from you, that's almost an endorsement @mcabbott :-) Maybe that's not that crazy at all? We don't want ChainRulesCore to become noticeably heavier, of course, now that it's making real inroads throughout the ecosystem - but maybe the cost wouldn't be high? We're currently at (Julia v1.8.0-beta3)
If it's just 5 ms more or so, maybe that would be Ok? DualNumbers are quite fundamental after all - or at least will be once there's only one version of them around. |
The package load times do suggest a certain graph of package dependencies (run in sequence in a single session):
Especially SpecialFunctions should clearly depend on a dual-numbers package and not the other way round. :-) And ChainRulesCore depending on dual-numbers would seem quite natural as well. And the potential benefits would be huge - we would quickly get a lot more dual-numbers/ForwardDiff-support throughout the ecosystem (especially in the statistics sector - DistributionsAD could just go away completely - but also in many other domains). |
ForwardDiff is not the main blocker, it's Tracker and ReverseDiff. There are only very few definitions for dual numbers remaining: https://github.com/TuringLang/DistributionsAD.jl/blob/master/src/forwarddiff.jl |
Ah, sorry, you're right of course. (Full) ChainRulesCore-support in Tracker and ReverseDiff would be so nice ... Speaking of the statistics domain there's StatsFuns, though, with several |
My apologies if this has been suggested before:
While ForwardDiff is not the heaviest of packages in the ecosystem, it's also not exactly lightweight (take 1.6 seconds to load on my system). A lightweight package AbstractDualNumbers.jl or ForwardDiffBase.jl (or similar) that just defines something like
abstract type AbstractDualNumber{Tag} <: Real end
and things likefunction AbstractDualNumbers.value end
andfunction AbstractDualNumbers.partials end
could allow packages to define custom push-forwards without depending on ForwardDiff itself.I know that there are exciting efforts underway in the Julia-AD-ecosystem for new ADs (e.g. Diffractor), but ForwardDiff is certainly not going away any time soon. A really lightweight way to define push-forwards could reduce the frequency of
@require ForwardDiff
in the ecosystem quite a bit, and also make it possible to move code from packages like DistributionsAD to Distributions, etc.The text was updated successfully, but these errors were encountered: