pydata / pydata/xarray

`coords.update()` converts CuPy arrays to NumPy for dimension coordinates

Open
#11,251 10 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs triage
Dominant language
Python
Stars
4.2k
Forks
1.4k
Avg merge
2d 15h
Merged PRs (30d)
14

Description

What is your issue?

When assigning CuPy arrays as coordinates to a dataset using DataSet.coords.update(), the resulting coordinate data is converted to a NumPy array.

As a result, GPU-native workflows that are dependent on coordinates (e.g. grid interpolation) become CPU-bound or require additional data transfers to the GPU.

Minimal example:

data_cp = cp.arange(6)

ds = xr.Dataset({
    "var": (("x"), data_cp)
})

x_cp = cp.array([0,1,2,3,4,5])

print(type(x_cp)) # <class 'cupy.ndarray'>

ds.coords.update({"x": x_cp.copy()})

print(type(ds.coords["x"].data)) # <class 'numpy.ndarray'>

xarray: 2026.2.0

Question

Is this conversion intended, or should CuPy-backed coordinates be supported?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the minimal example at the DataSet.coords.update() entry point and inspect how the assigned coordinate data is handled. Trace where the CuPy array becomes a NumPy array, then determine the intended behavior and add a regression test showing the resulting coordinate type.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python
Domain
data
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.