-
Notifications
You must be signed in to change notification settings - Fork 63
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
Reverse mode gradient is up to 100x slower in Enzyme v0.12 #1409
Comments
gdalle
changed the title
Reverse mode gradient is 10x slower in Enzyme v0.12
Reverse mode gradient is slower in Enzyme v0.12
Apr 29, 2024
gdalle
changed the title
Reverse mode gradient is slower in Enzyme v0.12
Reverse mode gradient is up to 10x slower in Enzyme v0.12
Apr 29, 2024
gdalle
changed the title
Reverse mode gradient is up to 10x slower in Enzyme v0.12
Reverse mode gradient is up to 100x slower in Enzyme v0.12
Apr 29, 2024
I can reproduce this on Enzyme
julia> bench_outofplace(10)
17.932 ns (1 allocs: 144 bytes)
julia> bench_outofplace(100)
54.717 ns (1 allocs: 896 bytes)
julia> bench_outofplace(1000)
347.222 ns (1 allocs: 8.000 KiB)
julia> bench_outofplace(10)
1.653 μs (31 allocs: 2.016 KiB)
julia> bench_outofplace(100)
1.722 μs (31 allocs: 2.750 KiB)
julia> bench_outofplace(1000)
2.521 μs (31 allocs: 9.875 KiB) julia> versioninfo()
Julia Version 1.10.2
Commit bd47eca2c8a (2024-03-01 10:14 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: macOS (arm64-apple-darwin22.4.0)
CPU: 12 × Apple M3 Pro
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-15.0.7 (ORCJIT, apple-m1)
Threads: 1 default, 0 interactive, 1 GC (on 6 virtual cores) |
My guess is that the recent change to use make zero and thus support more
than just Julia arrays was the cause here.
Will try to look at this week and restore normal array perf.
…On Mon, Apr 29, 2024 at 5:46 AM Guillaume Dalle ***@***.***> wrote:
I think it is a consequence of #1401
<#1401>
Enzyme v0.11
julia> using Chairmarks, Enzyme
julia> f(x) = sum(abs2, x)
f (generic function with 1 method)
julia> @be (x=rand(100), g=rand(100)) gradient!(Enzyme.Reverse, _.g, f, _.x)
Benchmark: 2542 samples with 86 evaluations
min 344.081 ns
median 346.872 ns
mean 346.897 ns
max 537.256 ns
(jl_mrTnl6) pkg> st
Status `/tmp/jl_mrTnl6/Project.toml`
[0ca39b1e] Chairmarks v1.2.1
⌃ [7da242da] Enzyme v0.11.20
Info Packages marked with ⌃ have new versions available and may be upgradable.
Enzyme v0.12
julia> using Chairmarks, Enzyme
f
julia> f(x) = sum(abs2, x)
f (generic function with 1 method)
julia> @be (x=rand(100), g=rand(100)) gradient!(Enzyme.Reverse, _.g, f, _.x)
Benchmark: 2533 samples with 6 evaluations
min 3.513 μs (28 allocs: 1.547 KiB, <0.01% compile time)
median 3.915 μs (28 allocs: 1.547 KiB, 0.84% compile time)
mean 4.809 μs (28 allocs: 1.547 KiB, 0.04% gc time, 0.84% compile time)
max 2.012 ms (28 allocs: 1.547 KiB, 99.10% gc time, 12.06% compile time)
(jl_CnUVZ6) pkg> st
Status `/tmp/jl_CnUVZ6/Project.toml`
[0ca39b1e] Chairmarks v1.2.1
[7da242da] Enzyme v0.12.0
—
Reply to this email directly, view it on GitHub
<#1409>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAJTUXE7M3PYVO36JTQRUWDY7YJJDAVCNFSM6AAAAABG57R52OVHI2DSMVQWIX3LMV43ASLTON2WKOZSGI3DQNJYGM2TKNA>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Thanks! If you need beta testers, let me know! |
On a slower laptop: Enzyme 0.11 julia> bench_inplace(10)
141.000 ns
julia> bench_inplace(100)
866.000 ns
julia> bench_outofplace(10)
140.321 ns (1 allocs: 144 bytes)
julia> bench_outofplace(100)
907.133 ns (1 allocs: 896 bytes) PR on Enzyme 0.12 julia> bench_inplace(10)
5.569 μs (28 allocs: 1.547 KiB, <0.01% compile time)
julia> bench_inplace(100)
6.383 μs (28 allocs: 1.547 KiB, 0.03% compile time)
julia> bench_outofplace(10)
5.483 μs (29 allocs: 1.688 KiB, 0.03% compile time)
julia> bench_outofplace(100)
6.405 μs (29 allocs: 2.422 KiB, <0.01% compile time) Still not there it seems |
Should be fixed by #1415 please reopen if it persists |
fixed indeed, good job! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think it is a consequence of the type instability spotted in #1401
Setup:
Out-of-place benchmarks:
In-place benchmarks (may be imprecise due to
evals = 1
, see https://chairmarks.lilithhafner.com/v1.2.1/tutorial#Common-pitfalls):The text was updated successfully, but these errors were encountered: