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
AD.jacobian
much slower than Zygote.jacobian
#54
Comments
Possibly, recent changes have already reduced the performance gap. But I assume possibly the original benchmarks in this issues were not completely accurate - note that julia> import AbstractDifferentiation as AD
julia> using BenchmarkTools, Zygote
julia> f(x) = x .^ 2
f (generic function with 1 method)
julia> x = rand(100);
julia> ab = AD.ZygoteBackend()
AbstractDifferentiation.ReverseRuleConfigBackend{Zygote.ZygoteRuleConfig{Zygote.Context{false}}}(Zygote.ZygoteRuleConfig{Zygote.Context{false}}(Zygote.Context{false}(nothing)))
julia> Zygote.jacobian(f, x)
([0.09722052175255036 0.0 … 0.0 0.0; 0.0 1.4127603956877295 … 0.0 0.0; … ; 0.0 0.0 … 1.4095040963600012 0.0; 0.0 0.0 … 0.0 0.864262095462434],)
julia> AD.jacobian(ab, f, x)
([0.09722052175255036 0.0 … 0.0 0.0; 0.0 1.4127603956877295 … 0.0 0.0; … ; 0.0 0.0 … 1.4095040963600012 0.0; 0.0 0.0 … 0.0 0.864262095462434],)
julia> @benchmark Zygote.jacobian($f, $x)
BenchmarkTools.Trial: 10000 samples with 1 evaluation.
Range (min … max): 365.542 μs … 2.172 ms ┊ GC (min … max): 0.00% … 79.38%
Time (median): 375.958 μs ┊ GC (median): 0.00%
Time (mean ± σ): 384.061 μs ± 67.837 μs ┊ GC (mean ± σ): 1.61% ± 5.99%
█▆▁▃▂
▂▄▄▃▄▇█████▇▅▅▄▄▃▃▃▃▃▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▁▂▂▂▁▂▂▂▂▂ ▃
366 μs Histogram: frequency by time 437 μs <
Memory estimate: 416.30 KiB, allocs estimate: 3639.
julia> @benchmark AD.jacobian($ab, $f, $x)
BenchmarkTools.Trial: 10000 samples with 1 evaluation.
Range (min … max): 463.333 μs … 1.184 ms ┊ GC (min … max): 0.00% … 55.33%
Time (median): 474.750 μs ┊ GC (median): 0.00%
Time (mean ± σ): 482.724 μs ± 58.422 μs ┊ GC (mean ± σ): 1.46% ± 5.94%
▆█▅▃▂ ▁
███████▇▆▅▅▁▃▁▃▁▁▁▁▃▁▁▁▁▁▁▁▁▃▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▃▃▄▁▃▄▄▄▃▅▅▅▆▆ █
463 μs Histogram: log(frequency) by time 929 μs <
Memory estimate: 701.36 KiB, allocs estimate: 15919. |
That's reassuring! Indeed I was still a newbie when I did these non-interpolated benchmarks |
IMO it's a bug nevertheless - I'd expect |
Hi, and thanks for this amazing interface!
When computing jacobians, I recently noted a significant speed difference between standalone Zygote and Zygote used as an AD backend. The allocations also differ wildly. Do you happen to know where that comes from?
Here's a minimal working example:
The text was updated successfully, but these errors were encountered: