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

WIP: GPU-compatibility of Jacobians #406

Closed
wants to merge 1 commit into from

Conversation

ChrisRackauckas
Copy link
Member

MWE:

using ForwardDiff
A = cu(-rand(3,3))
u = cu([1.0;0.0;0.0])
du = similar(u)
f(du,u) = mul!(du,A,u)
ForwardDiff.jacobian(f,du,u)

@ChrisRackauckas
Copy link
Member Author

@vchuravy any idea why this would fallback to the Base broadcasting?

using ForwardDiff, CuArrays
x = CuArray([ForwardDiff.Dual(1.0f0,(0.0f0,0.0f0)) for i in 1:10])
CuArrays.allowscalar(false)
ForwardDiff.partials.(Float32,x,1)

@KristofferC
Copy link
Collaborator

#351

The reason that PR got reverted needs to be checked here.

@ChrisRackauckas
Copy link
Member Author

I see. As a continuation of #353 @maleadt . The routes I'm thinking of are:

  1. Requires.jl, add overloads for CuArrays. Would you accept that?
  2. We may just add overloads for this in Requires of DiffEqBase. DiffEqBase has a faster @.. broadcast which gets rid of the timing issues of changing to broadcast (Julia v1.0 broadcast is quite slow :( ), and I'm not sure we could have no performance loss without using this.
  3. We may just make sure the color-autodiff form of this into SparseDiffTools.jl.

Of course, not having it in ForwardDiff.jl is a hassle, and having the piracy version in DiffEqBase is a little awkward, but my main priority is to get it working for DiffEq and then find out where to put the code later.

duals[i] = Dual{T,V,N}(x[i], seeds[i])
end
i = 1:N
@views duals[i] .= Dual{T,V,N}.(x[i], seeds)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps these @views could be reduced in "strength" by putting them where they are needed, e.g. only on the x[i]? And could the usage of @. be consistent among the changes (it's not used here, but used in other places).

@charleskawczynski
Copy link
Contributor

I think we can close this now that #472 has merged.

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

Successfully merging this pull request may close these issues.

None yet

3 participants