FluxML / FluxML/Optimisers.jl

How to handle long compile times?

Open
#153 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
Julia
Stars
96
Forks
30
PR merge metrics
No merged PRs in 30d

Description

Is there some known remedy for explosive compile times when updating deeply nested models?

```julia

julia> versioninfo()
Julia Version 1.9.2
Commit e4ee485e90 (2023-07-05 09:39 UTC)
Platform Info:
OS: Windows (x86_64-w64-mingw32)
CPU: 8 × 11th Gen Intel(R) Core(TM) i5-1145G7 @ 2.60GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-14.0.6 (ORCJIT, tigerlake)
Threads: 1 on 8 virtual cores

(@v1.9) pkg> activate --temp

(jl_pfjmCB) pkg> add Flux, Optimisers

using Flux, Optimisers

for i in 1:2:20
ts = @timed c = foldl((m,_) -> Parallel(+, Chain(m, Dense(1=>1)), m),1:i; init=Dense(1=>1))
@info "$i Create chain: $(ts.time)"
ts = @timed os = Optimisers.setup(Optimisers.Adam(0.1f0), c)
@info " Setup opt: $(ts.time)"
ts = @timed gs = gradient((f, x) -> sum(f(x)), c, ones(Float32, 1,1))
@info " Calc grad: $(ts.time)"
ts = @timed Optimisers.update(os, c, gs[1])
@info " Update pars: $(ts.time)"
end
[ Info: 1 Create chain: 0.3122138
[ Info: Setup opt: 0.4341211
[ Info: Calc grad: 8.0373625
[ Info: Update pars: 2.2199014
[ Info: 3 Create chain: 0.1156983
[ Info: Setup opt: 0.2145368
[ Info: Calc grad: 5.0142625
[ Info: Update pars: 1.6858239
[ Info: 5 Create chain: 0.1646994
[ Info: Setup opt: 0.3382421
[ Info: Calc grad: 22.8807554
[ Info: Update pars: 14.1957323
[ Info: 7 Create chain: 0.8384293
[ Info: Setup opt: 1.7405321
[ Info: Calc grad: 33.0993626
[ Info: Update pars: 1518.808826
[ Info: 9 Create chain: 4.0898057
[ Info: Setup opt: 8.6561113
[ Info: Calc grad: 121.4887817
## This one is still not finished 19 hours later :/
```

I did [this](https://github.com/DrChainsaw/NaiveNASflux.jl/blob/c5fec8728e120bcba656ac8ab815b08a1138d25f/src/autooptimiser.jl#L20-L28) to prevent spurious stalls with [NaiveGAflux](https://github.com/DrChainsaw/NaiveGAflux.jl), but maybe there is a better way.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the supplied Julia 1.9.2 benchmark with Flux and Optimisers, then inspect autooptimiser.jl lines 20–28 referenced in the issue. Compare the compile and update timings for increasingly nested models; the work is done when the cause is established and a confirmed remedy or clearly documented limitation is provided.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
machine-learning, performance
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.