Skip to content

Align convolution dask output dtype with numpy/cupy (#3618)#3622

Open
brendancol wants to merge 2 commits into
xarray-contrib:mainfrom
brendancol:deep-sweep-metadata-convolution-2026-07-02
Open

Align convolution dask output dtype with numpy/cupy (#3618)#3622
brendancol wants to merge 2 commits into
xarray-contrib:mainfrom
brendancol:deep-sweep-metadata-convolution-2026-07-02

Conversation

@brendancol

Copy link
Copy Markdown
Contributor

Closes #3618.

The dask backends of convolution_2d / convolve_2d declared float64
via meta=np.array(()) even when the eager numpy and cupy backends promote
an int or float32 raster to float32. So result.dtype changed depending on
the backend, and the declared dask dtype did not even match the float32
chunks dask computes.

Change

  • _convolve_2d_dask_numpy and _convolve_2d_dask_cupy now pass the
    promoted float dtype into the map_overlap meta, so the declared dtype
    matches 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)
  • New parametrized test asserts the dask declared dtype and the
    computed chunk dtype both equal the eager dtype for int32, float32,
    and float64 input.

)

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).
@github-actions github-actions Bot added the performance PR touches performance-sensitive code label Jul 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance PR touches performance-sensitive code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

convolution_2d dask backend reports float64 dtype while numpy/cupy return float32

1 participant