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

Arrays of ForwardDiff Duals incorrectly marked as not mutable? #1611

Closed
ChrisRackauckas opened this issue Jul 5, 2024 · 4 comments
Closed

Comments

@ChrisRackauckas
Copy link
Contributor

using ForwardDiff, Enzyme
using ForwardDiff: Dual
tmp1 = ForwardDiff.Dual{ForwardDiff.Tag{Nothing, Float64}, Float64, 3}[Dual{ForwardDiff.Tag{Nothing, Float64}}(0.0,0.0,0.0,0.0), Dual{ForwardDiff.Tag{Nothing, Float64}}(0.0,0.0,0.0,0.0), Dual{ForwardDiff.Tag{Nothing, Float64}}(0.0,0.0,0.0,0.0)]
Enzyme.make_zero!(tmp1)
julia> Enzyme.make_zero!(tmp1)
ERROR: AssertionError: !(ismutable(T))
Stacktrace:
 [1] make_zero_immutable!
   @ C:\Users\accou\.julia\packages\Enzyme\baiSZ\src\compiler.jl:1440 [inlined]
 [2] make_zero!
   @ C:\Users\accou\.julia\packages\Enzyme\baiSZ\src\compiler.jl:1519 [inlined]
 [3] make_zero!(prev::Vector{Dual{ForwardDiff.Tag{Nothing, Float64}, Float64, 3}})
   @ Enzyme.Compiler C:\Users\accou\.julia\packages\Enzyme\baiSZ\src\compiler.jl:1573
 [4] top-level scope
   @ REPL[9]:1
@wsmoses
Copy link
Member

wsmoses commented Jul 6, 2024

Something is very strange here with ForwardDiff.Dual.

julia> T = ForwardDiff.Dual{ForwardDiff.Tag{Nothing, Float64}, Float64, 3}
Dual{ForwardDiff.Tag{Nothing, Float64}, Float64, 3}

julia> ismutable(T)
true

julia> v = T(0)
Dual{ForwardDiff.Tag{Nothing, Float64}}(0.0,0.0,0.0,0.0)

julia> v.
partials
value
julia> v.value = 3
ERROR: setfield!: immutable struct of type Dual cannot be changed
Stacktrace:
 [1] setproperty!(x::Dual{ForwardDiff.Tag{Nothing, Float64}, Float64, 3}, f::Symbol, v::Int64)
   @ Base ./Base.jl:41
 [2] top-level scope
   @ REPL[10]:1

@vchuravy any ideas?

@wsmoses
Copy link
Member

wsmoses commented Jul 6, 2024

oh never mind, this is an accidental use of ismutable instead of ismutabletype

@wsmoses
Copy link
Member

wsmoses commented Jul 6, 2024

Fixed by #1612

@wsmoses wsmoses closed this as completed Jul 6, 2024
@ChrisRackauckas
Copy link
Contributor Author

Can this get a tag?

ChrisRackauckas added a commit to SciML/SciMLSensitivity.jl that referenced this issue Jul 9, 2024
ChrisRackauckas added a commit to SciML/SciMLSensitivity.jl that referenced this issue Jul 21, 2024
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