Skip to content

Migrate interp1d to FastInterpolations backend#99

Open
mgyoo86 wants to merge 2 commits into
masterfrom
feat/fast_interp
Open

Migrate interp1d to FastInterpolations backend#99
mgyoo86 wants to merge 2 commits into
masterfrom
feat/fast_interp

Conversation

@mgyoo86
Copy link
Copy Markdown
Member

@mgyoo86 mgyoo86 commented May 20, 2026

Summary

Move interp1d from DataInterpolations + in-house TypedInterp wrapper to the new FastInterpolations package. The zero-allocation / type-stability machinery from #85 now lives in a dedicated package, so IMASdd no longer maintains it directly.

Main Changes

  • Add FastInterpolations dependency
  • Migrate interp1d to use FastInterpolations API, except for :lagrange scheme

Performance Impact

1. Pure interpolation (linear, 51 grid × 1000 queries, in-place)

  • ~20× faster, zero allocations.
# master
julia> @btime $itp($out, $xq);
  20.041 μs (0 allocations: 0 bytes)

# This PR
julia> @btime $itp($out, $xq);
  1.004 μs (0 allocations: 0 bytes)

2. Upstream: IMAS.trace_surfaces

  • ~30% faster.
dd = IMAS.json2imas(joinpath(pkgdir(IMAS.IMASdd), "sample", "omas_sample.json"));

# master
julia> @btime IMAS.trace_surfaces(dd.equilibrium.time_slice[], IMAS.first_wall(dd.wall)...);
  535.500 μs (7769 allocations: 262.00 KiB)

# This PR
julia> @btime IMAS.trace_surfaces(dd.equilibrium.time_slice[], IMAS.first_wall(dd.wall)...);
  376.666 μs (7747 allocations: 261.58 KiB)

mgyoo86 added 2 commits May 19, 2026 17:07
Replace the in-house TypedInterp wrapper and DataInterpolations
constructors in interp1d with FastInterpolations' typed interpolation
functions (constant_interp, linear_interp, pchip_interp,
quadratic_interp, cubic_interp), using ExtendExtrap() for extrapolation.
Add FastInterpolations as a dependency and a Float32 return-type test
to lock in element-type stability.
…tions

Remove the explicit Integer/Rational guard and the length-based scheme
fallbacks (length==1/2/3/4) in interp1d. FastInterpolations 0.4.11
handles these cases natively, so the wrapper only needs to dispatch on
the requested scheme. Bump FastInterpolations compat to 0.4.11 and drop
the now-obsolete Integer/Rational type-stability tests.
@mgyoo86 mgyoo86 requested a review from jmcclena May 20, 2026 22:50
@codecov
Copy link
Copy Markdown

codecov Bot commented May 20, 2026

Codecov Report

❌ Patch coverage is 80.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 43.94%. Comparing base (fc5d748) to head (7f66a56).

Files with missing lines Patch % Lines
src/math.jl 80.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #99      +/-   ##
==========================================
- Coverage   43.95%   43.94%   -0.01%     
==========================================
  Files          15       15              
  Lines       31419    31407      -12     
==========================================
- Hits        13810    13803       -7     
+ Misses      17609    17604       -5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Successfully merging this pull request may close these issues.

1 participant