Keep template backend and variance name in kriging singular-matrix fallback#3294
Open
brendancol wants to merge 2 commits into
Open
Keep template backend and variance name in kriging singular-matrix fallback#3294brendancol wants to merge 2 commits into
brendancol wants to merge 2 commits into
Conversation
brendancol
commented
Jun 12, 2026
brendancol
left a comment
Contributor
Author
There was a problem hiding this comment.
PR Review: Keep template backend and variance name in kriging singular-matrix fallback
Blockers (must fix before merge)
None.
Suggestions (should fix, not blocking)
None.
Nits (optional improvements)
-
xrspatial/interpolate/_kriging.py(newmap_blockscall in theK_inv is Nonebranch): the lambda gives the dask task alambda-<hash>name instead of anxrspatial.kriging-style name per the #3255 convention. Every othermap_blockscall in this module has the same gap, and #3256 already tracks the module-wide naming sweep, so fixing only this one call here would leave the module inconsistent either way. Fine to leave for #3256.
What looks good
- The fix dispatches on the actual backend:
map_blocks+np.full_likekeeps dask templates lazy with their original chunks, andnp.full_likedispatches to cupy for GPU templates. Verified in the new tests, including the dask+cupy meta check (result.data._metaiscupy.ndarray). - The fallback was eager before this change even for chunked dask templates; now it never materialises the grid, which matches the memory-guard reasoning that skips the grid-sized term for dask (
_check_kriging_memory(is_dask=True)). variancenow carries<name>_variancelike the normal path (line 523), and the test asserts it on all four backends.- The monkeypatch in the tests targets the module global
_build_kriging_matrix, whichkriging()resolves at call time, so the forcing mechanism is sound. - Coords, dims, attrs, and dtype assertions are explicit in
test_singular_fallback_metadatarather than inferred.
Checklist
- Algorithm matches reference/paper (n/a, metadata-only fix)
- All implemented backends produce consistent results
- NaN handling is correct (all-NaN fallback by design)
- Edge cases are covered by tests (fallback forced per backend)
- Dask chunk boundaries handled correctly (no overlap needed; chunks preserved)
- No premature materialization (fallback is now lazy on dask; was eager before)
- Benchmark exists or is not needed (degenerate path, not performance-relevant)
- README feature matrix updated (n/a, no API or backend-support change)
- Docstrings present and accurate (no public signature change)
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.
Closes #3288
K_inv is Nonefallback inkriging()now builds its all-NaN result on the template's backend:map_blocks+np.full_likefor dask templates (stays lazy, keeps chunks and the cupy meta on dask+cupy) andnp.full_likeotherwise (dispatches to cupy for GPU templates). Previously the fallback always returned an eager numpy array, and for a large chunked dask template it materialised the whole grid in host memory.return_variance=Truethe fallback's variance raster is now named<name>_variance, matching the normal path. It used to inherit the prediction's name.Backend coverage: numpy, cupy, dask+numpy, dask+cupy. All four verified locally on a GPU host.
Test plan:
TestKrigingforce the fallback via monkeypatch and check name, backend type, chunks, dtype, attrs, and NaN content per backendpytest xrspatial/tests/test_interpolation.py: 70 passed (GPU tests included)