Skip to content
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

Bad compilation time with static arrays and intervals #504

Open
dpsanders opened this issue Feb 1, 2021 · 3 comments
Open

Bad compilation time with static arrays and intervals #504

dpsanders opened this issue Feb 1, 2021 · 3 comments

Comments

@dpsanders
Copy link

The following should be a simple calculation, but uses 2GB (!) in the compilation process...:

julia> using ForwardDiff, StaticArrays, IntervalArithmetic

julia> f(x) = 2 .* x .* x
f (generic function with 1 method)

julia> X = @SVector [0..1 for i in 1:6];

julia> @time ForwardDiff.jacobian(f, X)
 11.818110 seconds (67.27 M allocations: 2.401 GiB, 13.76% gc time, 100.00% compilation time)
6×6 SMatrix{6, 6, Interval{Float64}, 36} with indices SOneTo(6)×SOneTo(6):
 [0, 4]  [0, 0]  [0, 0]  [0, 0]  [0, 0]  [0, 0]
 [0, 0]  [0, 4]  [0, 0]  [0, 0]  [0, 0]  [0, 0]
 [0, 0]  [0, 0]  [0, 4]  [0, 0]  [0, 0]  [0, 0]
 [0, 0]  [0, 0]  [0, 0]  [0, 4]  [0, 0]  [0, 0]
 [0, 0]  [0, 0]  [0, 0]  [0, 0]  [0, 4]  [0, 0]
 [0, 0]  [0, 0]  [0, 0]  [0, 0]  [0, 0]  [0, 4]
@KristofferC
Copy link
Collaborator

but uses 2GB (!) in the compilation process...:

What would a reasonable number for Julia to use to compile this according to you?

You can try to lower the chunk size, which usually reduces compile time.

@dpsanders
Copy link
Author

@KristofferC: That's fair; I guess a naive version should require a lot less space and time, but there is a lot of compilation complication due e.g. to tagging that is not actually required (I believe) for this calculation.

@KristofferC
Copy link
Collaborator

This now fails with

julia> @time ForwardDiff.jacobian(f, X)
ERROR: ArgumentError: `isfinite` is purposely not supported for intervals. See instead `isbounded`
Stacktrace:
  [1] isfinite(::Interval{Float64})
    @ IntervalArithmetic ~/.julia/packages/IntervalArithmetic/7FL3g/src/intervals/real_interface.jl:104
  [2] _mul_partials
    @ ~/JuliaPkgs/ForwardDiff.jl/src/partials.jl:104 [inlined]
  [3] dual_definition_retval(::Val{…}, val::Interval{…}, deriv1::Interval{…}, partial1::ForwardDiff.Partials{…}, deriv2::Interval{…}, partial2::ForwardDiff.Partials{…})
    @ ForwardDiff ~/JuliaPkgs/ForwardDiff.jl/src/dual.jl:207
  [4] *
    @ ~/JuliaPkgs/ForwardDiff.jl/src/dual.jl:275 [inlined]
  [5] newf
    @ ~/.julia/packages/StaticArrays/LSPcF/src/broadcast.jl:186 [inlined]
  [6] macro expansion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants