Skip to content

Replace ITPWrapper with array-based interp for GPU compatibility#163

Open
ctessum wants to merge 1 commit intomainfrom
param
Open

Replace ITPWrapper with array-based interp for GPU compatibility#163
ctessum wants to merge 1 commit intomainfrom
param

Conversation

@ctessum
Copy link
Copy Markdown
Member

@ctessum ctessum commented Feb 28, 2026

Summary

  • Replace complex DataSetInterpolator/ITPWrapper structs stored as MTK parameter defaults with plain arrays as @discretes, moving complex objects into system event callback context
  • New array-based interp_unsafe using fractional 1-based indices — pure arithmetic + array indexing, zero allocations, GPU-compatible
  • Updated all data source constructors (GEOS-FP, NEI, WRF, NCEP-NCAR) to use new create_interp_equation API returning (eq, discretes, constants, interp_info)
  • Workaround for SymbolicUtils promote_shape bug where ifelse returns true (Bool) instead of the shape
  • create_updater_sys_event uses ImperativeAffect with ctx for DataSetInterpolator objects (kept out of parameter buffer)

Status

  • Precompilation passes
  • Tests pass (WIP — canonicalize_eq! subtraction error in TearingState during coupled system mtkcompile needs investigation)
  • Numerical regression check

Test plan

  • Run full test suite (Pkg.test())
  • Verify interpolated values match pre-refactor values at test points
  • Test coupling with GEOS-FP (NEI + GEOS-FP coupled system)
  • Verify GPU compatibility with Reactant

🤖 Generated with Claude Code

…atibility

Replace complex DataSetInterpolator/ITPWrapper structs stored as MTK parameter
defaults with plain arrays as @discretes. These mutable structs contained BSpline
objects, file handles, locks, and async tasks that cannot transfer to GPU.

Key changes:
- New array-based interp_unsafe using fractional 1-based indices (GPU-compatible)
- @discretes with typed AbstractArray annotations for data arrays
- Scalar @discretes for time grid parameters (tstart, tstep)
- @constants for spatial grid parameters and extrapolation type
- create_interp_equation returns (eq, discretes, constants, interp_info)
- build_interp_expr helper for z_params pattern (geosfp, wrf, NCEP-NCAR)
- create_updater_sys_event uses ImperativeAffect with ctx for DSI objects
- promote_shape fixes for interp_unsafe and ifelse (SymbolicUtils bug workaround)
- Updated all data source constructors (geosfp, nei, wrf, NCEP-NCAR)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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