Skip to content

Support differentiable regridding on CPU and CUDA - #209

Open
cuteNBD (bingdongni) wants to merge 1 commit into
microsoft:mainfrom
bingdongni:feat/device-native-regrid
Open

cuteNBD (bingdongni) wants to merge 1 commit into
microsoft:mainfrom
bingdongni:feat/device-native-regrid

Conversation

@bingdongni

Copy link
Copy Markdown

Batch.regrid() converts every field to NumPy for SciPy interpolation. That makes a GPU forecast take a round trip through host memory and breaks the gradient when a loss is evaluated on another grid.

Compute the latitude and longitude neighbors once per batch and apply their weights with PyTorch on each field's device. This preserves the existing target coordinates, longitude wrap, latitude extrapolation and float32 return type. The regression test checks irregular coordinates, missing values, pressure levels and the gradient with respect to the source field against the SciPy interpolator.

On an RTX 4060 Laptop GPU, all eleven fields from Microsoft's published 0.4° air-pollution static file matched the SciPy result at 0.25° (rtol=2e-6, atol=1e-7; 721 × 1440 values per field). With inputs and outputs on CUDA, the median for that batch was 13.5 ms, versus 1269 ms through SciPy on CPU. A randomly initialized small Aurora 1.5 forecast also backpropagated a regridded surface objective to its input. GPU tests and benchmark · Linux batch and forecast tests

@bingdongni
cuteNBD (bingdongni) requested a review from a team November 15, 2026 11:02
@bingdongni

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant