Make SearchProperties probes robust to non-primitive Real eltypes (AD)#100
Merged
ChrisRackauckas merged 2 commits intoJul 13, 2026
Merged
Conversation
`SearchProperties(v::AbstractVector{<:Real})` runs sampled linearity /
uniformity / log-linearity probes that coerced intermediate values with
`Float64(...)`. `ForwardDiff.Dual <: Real`, but `Float64(::Dual)` is
deliberately undefined, so constructing `SearchProperties` on a Dual-valued
knot vector — as happens when an interpolation is reconstructed inside
`ForwardDiff` and the knots are promoted to Duals — threw a `MethodError`.
The `Float64(...)` coercions are redundant for the primitive eltypes: for
`Int`/`Float32`/`Float64` the probe expressions are already `Float64`. Drop
them and compute in native arithmetic, so the probes work for any ordered
`Real` (the classification is taken from the primal and partials are kept
intact), while the primitive hot path is byte-for-byte unchanged.
Adds a ForwardDiff regression testset differentiating through both values
and Dual-valued knots, and wires ForwardDiff into the test targets.
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
ChrisRackauckas-Claude
pushed a commit
to ChrisRackauckas-Claude/DataInterpolations.jl
that referenced
this pull request
Jul 13, 2026
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
ChrisRackauckas-Claude
pushed a commit
to ChrisRackauckas-Claude/DataInterpolations.jl
that referenced
this pull request
Jul 13, 2026
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Constructing
SearchPropertieson aForwardDiff.Dual-valued knot vector throws aMethodError:ForwardDiff.Dual <: Real, so it dispatches toSearchProperties(v::AbstractVector{<:Real}), whose sampled linearity / uniformity / log-linearity probes coerce intermediates withFloat64(...).Float64(::Dual)is deliberately undefined. This surfaces downstream when an interpolation is reconstructed insideForwardDiffand both values and knots are promoted to Duals (e.g. SciML/DataInterpolations.jl#557).Fix
The
Float64(...)coercions are redundant for the primitive eltypes — forInt/Float32/Float64the probe expressions are alreadyFloat64. Removing them and computing in native arithmetic:Real(classification is taken from the primal, partials are preserved), andInt/Float64hot path byte-for-byte unchanged.I verified ForwardDiff defines
unsafe_trunc(Int, ::Dual), so once the probe stops callingFloat64, the closed-formUniformStepsearch path also works end-to-end and derivatives propagate correctly.Tests
Adds a regression testset differentiating through both values and Dual-valued knots (uniform + non-uniform), plus a full
Autosearch over uniform Dual knots checked againstBaseon the primal. WiresForwardDiffinto the test targets.GROUP=Coresuite: 171,933 pass locally.Relation to other work
This unblocks SciML/DataInterpolations.jl#557 — with this merged, that PR can drop its
_default_search_properties/_search_propertiesopt-out helpers and just bump the FindFirstFunctions compat bound. A separate PR handles a distinct pre-existingRationalcrash in the UniformStep kernel found while testing eltype robustness.