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

Add option to specify ForwardDiff chunk size #126

Open
touste opened this issue Jul 8, 2020 · 4 comments
Open

Add option to specify ForwardDiff chunk size #126

touste opened this issue Jul 8, 2020 · 4 comments

Comments

@touste
Copy link

touste commented Jul 8, 2020

Hi, it would be nice to have this option available (and propagate it to Optim.jl as well), this setting can have a great impact on performances/allocations in some situations (see for ex: https://discourse.julialang.org/t/large-memory-allocation-in-forwarddiff/42581/14).

Thanks!

@longemen3000
Copy link
Contributor

longemen3000 commented Jun 4, 2021

if i remember correctly, the constructors accept a chunk keyword:
on OnceDifferentiable:

OnceDifferentiable(f, x::AbstractArray,
F::Real = real(zero(eltype(x))),
DF::AbstractArray = alloc_DF(x, F); inplace = true, autodiff = :finite,
chunk::ForwardDiff.Chunk = ForwardDiff.Chunk(x)) =

on TwiceDIfferentiable:
function TwiceDifferentiable(f, x::AbstractArray, F::Real = real(zero(eltype(x)));
autodiff = :finite, inplace = true)

@pkofod
Copy link
Member

pkofod commented Jun 9, 2021

Yes if you define the objective type yourself it is possible. I supposed OP is asking for this to be a keyword for optimize?

@touste
Copy link
Author

touste commented Jun 9, 2021

Hi, I did indeed wish for it to be available in optimize. However since then I think I have a better understanding of the functionalities of the packages, and it is possible to use optimize with a OnceDifferentiable of TwiceDifferentiable function, which accept this option, so it indirectly solves the problem. Perhaps a heads up in the doc of Optim.jl could let users know about the possibility to use OnceDifferentiable or TwiceDifferentiable functions? Otherwise feel free to close the issue.

@pkofod
Copy link
Member

pkofod commented Jun 9, 2021

Perhaps a heads up in the doc of Optim.jl could let users know about the possibility to use OnceDifferentiable or TwiceDifferentiable functions?

Yeah, I had originally chosen not to focus too much on this because I wasn't sure whether or not I wanted users to use them directly :) But it would solve the problem for now. I do think that it makes sense to allow for chunk size to be et in optimize as well though.

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

3 participants