Skip to content

Commit 90b22a0

Browse files
Require FindFirstFunctions 3.2 for AD-valued interpolation knots
Reconstructing an interpolation inside ForwardDiff promotes both the values and the knot vector to `ForwardDiff.Dual`. On FindFirstFunctions < 3.2 the `SearchProperties` linearity probe attempted an invalid `Float64(::Dual)` conversion, breaking `LinearInterpolation` (and the other constructors) for 11+ knots — the v9.0.0 regression. FindFirstFunctions 3.2 fixes the probe upstream (SciML/FindFirstFunctions.jl#100), so no local opt-out shim is needed: bump the compat lower bound to `3.2` and keep using `something(search_properties, FindFirstFunctions.SearchProperties(t))` directly. Adds a regression test differentiating through both values and knots across 15 knots. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FvBXVKGujjeaCB3iLwsDeG
1 parent b181e3b commit 90b22a0

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ BenchmarkTools = "1"
3737
ChainRulesCore = "1.26.1"
3838
EnumX = "1.0.5"
3939
FillArrays = "1.16.0"
40-
FindFirstFunctions = "3"
40+
FindFirstFunctions = "3.2"
4141
FiniteDifferences = "0.12.31"
4242
ForwardDiff = "1"
4343
LinearAlgebra = "1.10"

test/interpolation_tests.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,23 @@ end
268268
f(tvals) = LinearInterpolation(test_uvals, tvals)(3.5)
269269
@test_nowarn ForwardDiff.gradient(f, test_tvals)
270270

271+
# Differentiate through both values and knots simultaneously with 15+ knots,
272+
# which promotes the knot vector to ForwardDiff.Dual and exercises the
273+
# SearchProperties linearity probe (regression for the v9.0.0 breakage;
274+
# fixed upstream in FindFirstFunctions 3.2).
275+
test_tvals = collect(0.0:14.0)
276+
test_uvals = test_tvals .+ 1.0
277+
parameters = vcat(test_uvals, test_tvals)
278+
function f_all(parameters)
279+
uvals = parameters[1:15]
280+
tvals = parameters[16:30]
281+
return LinearInterpolation(uvals, tvals)(2.5)
282+
end
283+
expected_gradient = zeros(30)
284+
expected_gradient[3:4] .= 0.5
285+
expected_gradient[18:19] .= -0.5
286+
@test ForwardDiff.gradient(f_all, parameters) == expected_gradient
287+
271288
@testset "Sorted-batch evaluator" begin
272289
u_b = [0.0, 2.0, 1.0, 3.0, 2.0, 6.0, 5.5, 5.5, 2.7, 5.1, 3.0]
273290
t_b = collect(0.0:10.0)

0 commit comments

Comments
 (0)