Skip to content

Interaction of Complex{Dual} with rrule for ^ on Julia ≤ 1.5 #525

@mcabbott

Description

@mcabbott

In Julia 1.5 and earlier, complex dual numbers did not work well. This leads to the following interaction between the log(complex(x))) in the rrule for ^, and Zygote's forward-over-reverse Hessian calculation:

julia> hessian(x -> x[1]^x[2], [3,4])
ERROR: StackOverflowError:
Stacktrace:
 [1] Complex at ./complex.jl:12 [inlined] (repeats 2 times)
 [2] float at ./complex.jl:1016 [inlined]
 [3] log(::Complex{ForwardDiff.Dual{Nothing,Float64,2}}) at ./complex.jl:583 (repeats 79984 times)

It did not happen prior to #513 (v1.11.4) because this rule had a different special case for real x and real p, which I think got some of the edge cases wrong. Perhaps we could do both. But I'm not sure how much work is justified in fixing this. Found in CI & avoided here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions