Comments (7)
Did you try the master branch? Hopefully the recent simplifications already improved things.
from abstractdifferentiation.jl.
Not yet, I'm calling it a day but adding some JET tests is my next order of business
from abstractdifferentiation.jl.
Did you actually check type stability? Or is it just a general comment that there could be issues?
from abstractdifferentiation.jl.
I switched my package ImplicitDifferentiation from ChainRulesCore + ZygoteRuleConfig to AbstractDifferentiation + Zygote and that brought type instabilities which were not there before. Not sure if it is Zygote's fault or not, but given how the code here looks I'd be very surprised if we can't improve it.
You're right though, first thing we want to do is diagnose it. I'm thinking we run JET.test_opt
on each interface function for each backend and see how we fare
from abstractdifferentiation.jl.
Thanks for the collaboration by the way, it's energizing and I'm learning a lot
from abstractdifferentiation.jl.
Can you post an MWE?
from abstractdifferentiation.jl.
Of course the type instabilities are backend-dependent, and if every function is reimplemented in a type-stable backend we won't see them.
Thus I had to go for the ChainRules wrapper, which rebuilds everything from the rrule
up:
julia> import AbstractDifferentiation as AD
julia> import Zygote
julia> using Test
julia> f(x::Number) = abs2(x);
julia> f(x::Array) = abs2.(x);
julia> g(x) = sum(abs2, x);
julia> ad_backend = AD.ReverseRuleConfigBackend(Zygote.ZygoteRuleConfig())
AbstractDifferentiation.ReverseRuleConfigBackend{Zygote.ZygoteRuleConfig{Zygote.Context{false}}}(Zygote.ZygoteRuleConfig{Zygote.Context{false}}(Zygote.Context{false}(nothing)))
julia> @inferred AD.derivative(ad_backend, f, 1.0)
(2.0,)
julia> @inferred AD.second_derivative(ad_backend, f, 1.0)
ERROR: return type Tuple{Float64} does not match inferred return type Tuple
Stacktrace:
[1] error(s::String)
@ Base ./error.jl:35
[2] top-level scope
@ ~/Downloads/ad.jl:11
julia> @inferred AD.jacobian(ad_backend, f, [1.0])
ERROR: return type Tuple{Matrix{Float64}} does not match inferred return type Any
Stacktrace:
[1] error(s::String)
@ Base ./error.jl:35
[2] top-level scope
@ ~/Downloads/ad.jl:12
julia> @inferred AD.hessian(ad_backend, g, [1.0])
ERROR: return type Tuple{Matrix{Float64}} does not match inferred return type Any
Stacktrace:
[1] error(s::String)
@ Base ./error.jl:35
[2] top-level scope
@ ~/Downloads/ad.jl:13
This demonstrates type instabilities in the fallback structure of the package itself, not the extension
from abstractdifferentiation.jl.
Related Issues (20)
- Define a function for v' J v
- Expose tests through public API in src HOT 2
- Add docs for how to implement API as an AD HOT 2
- API Docs for end-users HOT 5
- `pushforward_function` and `pullback_function` are confused by tuples vs single input
- Only support tuples and not single inputs/outputs HOT 7
- Use DocStringExtensions.jl
- Add JET tests for linting and type instabilities
- AbstractDifferentiation stable docs 404 HOT 1
- Lazy jacobians could implement more of the LinearAlgebra interface
- New version timeline HOT 11
- Inconsistency in value_and_pushforward_function vs value_and_pullback_function outputs HOT 6
- Regression in type inferrability HOT 5
- Get rid of ugly macro? HOT 6
- `value_and_pullback_function` doesn't do what its docstring says HOT 3
- Configurable ForwardDiff tag
- Maybe AbstractDifferentiation should shrink to a collection of names? HOT 1
- Comparison with DifferentiationInterface.jl HOT 2
- Handling of thunks and tangents HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from abstractdifferentiation.jl.