Add GPU (CuPy) backend for cost_distance#910
Merged
brendancol merged 1 commit intomasterfrom Feb 26, 2026
Merged
Conversation
Replace CPU fallback with native CUDA iterative parallel relaxation (parallel Bellman-Ford). Each thread processes one pixel per iteration, checking all neighbours for shorter paths. The wavefront advances at least one pixel per iteration; convergence takes O(height + width) iterations with early termination when no changes occur. CuPy path: seeds source pixels at cost 0, runs relaxation kernel until convergence, converts inf/over-budget to NaN. Dask+CuPy: bounded max_cost uses da.map_overlap with per-chunk GPU relaxation; unbounded falls back to CPU iterative tile Dijkstra (O(N log N) Dijkstra beats O(N * diameter) relaxation for global paths). Tests extended with cupy and dask+cupy backends across 8 parametrized test functions. New tests for unbounded dask+cupy and cupy chunk type.
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.
Summary
max_costusesda.map_overlapwith per-chunk GPU relaxation (out-of-core, no OOM); unbounded falls back to CPU iterative tile Dijkstracupyanddask+cupyacross 8 parametrized test functions + 2 new GPU-specific testsFixes #905
Test plan