Skip to content

Add CuPy and Dask+CuPy backends for kriging (#951)#960

Merged
brendancol merged 5 commits into
masterfrom
issue-951
Mar 4, 2026
Merged

Add CuPy and Dask+CuPy backends for kriging (#951)#960
brendancol merged 5 commits into
masterfrom
issue-951

Conversation

@brendancol
Copy link
Copy Markdown
Contributor

Summary

  • Replaces the _kriging_gpu_not_impl stubs with working CuPy and Dask+CuPy backends. Kriging was the only interpolation method without GPU support.
  • Variogram fitting and matrix inversion stay on CPU (the matrices are small). The expensive part, predicting at each grid pixel, runs on GPU with vectorized CuPy operations.
  • Variogram model functions (_spherical, _exponential, _gaussian) now pick numpy or cupy based on the input array via _get_xp(), so the same closure works for all backends without duplication.
  • No custom CUDA kernels. The prediction bottleneck is a matrix multiply (k0 @ K_inv), which CuPy dispatches to cuBLAS.
  • 5 new GPU tests: prediction accuracy, all three variogram models, and variance output for both CuPy and Dask+CuPy.
  • README feature matrix updated to mark all four backends supported.
  • New user guide notebook (17_Kriging.ipynb) walks through interpolation, variance, variogram model comparison, and a soil pH mapping example.

Test plan

  • All 30 interpolation tests pass (25 existing + 5 new)
  • Verify GPU tests on multi-GPU setup
  • Run notebook cells to confirm plots render

Closes #951

Replace the GPU stubs with working implementations. Variogram fitting
and matrix inversion stay on CPU (small matrices). The per-pixel
prediction runs on GPU via vectorized CuPy operations, matching the
existing numpy algorithm. Variogram model functions now auto-detect
the array module so they work with both numpy and cupy inputs.
Tests for CuPy and Dask+CuPy kriging backends covering prediction
accuracy, all three variogram models, and variance output. Adds
_to_numpy() helper and cupy/dask_cupy backends to _make_template().
Covers basic interpolation, variance output, variogram model
comparison, and a soil pH mapping example.
@brendancol brendancol added enhancement New feature or request backend-coverage Adding missing dask/cupy/dask+cupy backend support gpu CuPy / CUDA GPU support labels Mar 4, 2026
@github-actions github-actions Bot added the performance PR touches performance-sensitive code label Mar 4, 2026
@brendancol brendancol merged commit f4c9fcc into master Mar 4, 2026
11 checks passed
@brendancol brendancol deleted the issue-951 branch May 4, 2026 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend-coverage Adding missing dask/cupy/dask+cupy backend support enhancement New feature or request gpu CuPy / CUDA GPU support performance PR touches performance-sensitive code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add CuPy and Dask+CuPy backends for Kriging interpolation

1 participant