You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is fairly hard to test, but it basically stems from `float(1//50)::Float64`, which means that this was always doing some float64 stuff, even when it should've been doing fastpow stuff. The test case just really required a Float32:
```julia
using DiffEqCallbacks, OrdinaryDiffEq, Tracker
Base.prevfloat(r::Tracker.TrackedReal) = Tracker.track(prevfloat, r)
Tracker.@Grad function prevfloat(r::Real)
prevfloat(Tracker.data(r)), Δ -> (Δ,)
end
Base.nextfloat(r::Tracker.TrackedReal) = Tracker.track(nextfloat, r)
Tracker.@Grad function nextfloat(r::Real)
nextfloat(Tracker.data(r)), Δ -> (Δ,)
end
function rober(u, p::TrackedArray, t)
y₁, y₂, y₃ = u
k₁, k₂, k₃ = p
return Tracker.collect([-k₁ * y₁ + k₃ * y₂ * y₃,
k₁ * y₁ - k₂ * y₂^2 - k₃ * y₂ * y₃,
k₂ * y₂^2])
end
p = TrackedArray([1.9f0, 1.0f0, 3.0f0])
u0 = TrackedArray([1.0f0, 0.0f0, 0.0f0])
tspan = TrackedArray([0.0f0, 1.0f0])
prob = ODEProblem{false}(rober, u0, tspan, p)
p = TrackedArray([1.9f0, 1.0f0, 3.0f0])
u0 = TrackedArray([1.0f0, 0.0f0, 0.0f0])
tspan = TrackedArray([0.0f0, 1.0f0])
prob = ODEProblem{false}(rober, u0, tspan, p)
saved_values = SavedValues(eltype(tspan), eltype(p))
cb = SavingCallback((u, t, integrator) -> integrator.EEst * integrator.dt, saved_values)
solve(remake(prob, u0 = u0, p = p, tspan = tspan),
Tsit5(),
sensealg = SensitivityADPassThrough(),
callback = cb)
@test !all(iszero.(Tracker.gradient(
p -> begin
solve(remake(prob, u0 = u0, p = p, tspan = tspan),
Tsit5(),
sensealg = SensitivityADPassThrough(),
callback = cb)
return sum(saved_values.saveval)
end,
p)[1]))
```
Thus downstream tests with FastPower.jl used catches this, and it's somewhat hard to construct a case that's this sensitive to the type.
0 commit comments