Align convolution dask output dtype with numpy/cupy (#3618)#3622
Open
brendancol wants to merge 2 commits into
Open
Align convolution dask output dtype with numpy/cupy (#3618)#3622brendancol wants to merge 2 commits into
brendancol wants to merge 2 commits into
Conversation
) The dask backends declared float64 via meta=np.array(()) even when the eager numpy/cupy backends promote an int or float32 raster to float32, so result.dtype disagreed across backends and did not match the float32 chunks dask actually computes. Pass the promoted float dtype into the map_overlap meta so the declared dtype matches both the eager backends and the computed chunks. Adds a parametrized regression test. Also records the convolution metadata sweep state (2026-07-02).
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 #3618.
The dask backends of
convolution_2d/convolve_2ddeclaredfloat64via
meta=np.array(())even when the eager numpy and cupy backends promotean int or float32 raster to float32. So
result.dtypechanged depending onthe backend, and the declared dask dtype did not even match the float32
chunks dask computes.
Change
_convolve_2d_dask_numpyand_convolve_2d_dask_cupynow pass thepromoted float dtype into the
map_overlapmeta, so the declared dtypematches both the eager backends and the computed chunks.
Backends
numpy, cupy, dask+numpy, dask+cupy all verified on a CUDA host: for a
float32 input every backend now reports float32 (was float64 on the two
dask paths). float64 input is unchanged.
Test plan
pytest xrspatial/tests/test_convolution.py(9 passed)computed chunk dtype both equal the eager dtype for int32, float32,
and float64 input.