Extend pathfinding asv benchmarks to dask/cupy backends and multi_stop_search#3648
Open
brendancol wants to merge 1 commit into
Open
Extend pathfinding asv benchmarks to dask/cupy backends and multi_stop_search#3648brendancol wants to merge 1 commit into
brendancol wants to merge 1 commit into
Conversation
…3645) The pathfinding benchmark only ran a_star_search on numpy at nx<=300. Parameterize AStarSearch over numpy/cupy/dask and add nx=1000 (dask capped at 300: the sparse Python A* takes ~4s per call at 1000). Add a MultiStopSearch class timing ordered routing and optimize_order. Every combo was executed locally, including cupy on a GPU host. Benchmark-only change; no edits to xrspatial/pathfinding.py. Claude-Session: https://claude.ai/code/session_0155N4QGamQVxgpAAPbpQNq4
brendancol
commented
Jul 8, 2026
brendancol
left a comment
Contributor
Author
There was a problem hiding this comment.
Domain-aware review of the benchmark changes.
Blockers
None. The change is benchmark-only, xrspatial/pathfinding.py is untouched, and every runnable parameter combination was executed on a GPU host per the PR body.
Suggestions
None.
Nits
- Changing
AStarSearch.params(new sizes and backend axis) resets the asv history for this class, so old numpy timings won't line up with new ones in the dashboard. Unavoidable when adding a backend axis, just something to know when reading trends across this commit. MultiStopSearch.setupbuilds waypoints fromself.agg.y.data[...]numpy scalars whileAStarSearchusesself.agg.y[0]DataArray scalars. Both are accepted by the API (_get_pixel_idfloats them), so this is style only. The numpy-scalar form is arguably better in setup code since it skips xarray indexing overhead.
Details checked:
- The dask skip at nx=1000 uses
NotImplementedErrorinsetup, the same skip mechanismcommon.get_xr_dataarrayalready uses for missing cupy/rtxpy, and asv marks those combos n/a rather than failed. snap_start/snap_goalstay on for numpy/cupy, matching the old benchmark's call signature; they are off for dask where the API raisesValueErrorby design. Snap on a valid start pixel is O(1) (_find_nearest_pixelreturns immediately), so it doesn't distort timings.get_xr_dataarraydask chunks are(ny//2, nx//2), so the dask combos run 2x2 chunked and exercise_a_star_dask's chunk cache for real, not a single-chunk degenerate case.- With 4 waypoints,
optimize_order=Truetakes the Held-Karp branch (N <= 12) and issues 12 matrix A* calls plus 3 segment calls, which is the cost profile users of that flag actually hit. - Slowest single call is ~1.4 s (dask optimize_order at nx=300), so the added suite runtime is bounded.
This was referenced Jul 8, 2026
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 #3645
AStarSearchover numpy / cupy / dask and raise the size ladder to[100, 300, 1000](was numpy-only at[10, 100, 300]). The dask backend is a separate implementation (_a_star_dask, sparse Python A* with an LRU chunk cache) that previously had no benchmark at all.NotImplementedErrorin setup: a single call takes ~4 s and would dominate suite runtime. dask still runs chunked (2x2 chunks) at 100 and 300.MultiStopSearch: 4 waypoints across the grid, timing both ordered routing andoptimize_order=True(Held-Karp path), on numpy / cupy / dask at[100, 300].snap_start/snap_goalstay on for numpy/cupy (matching the old benchmark) and off for dask, where they raise by design.Benchmark-only change;
xrspatial/pathfinding.pyis untouched. dask+cupy is still not parameterized becausecommon.get_xr_dataarrayhas no such type anywhere in the suite; noted in #3645.Backend coverage: numpy, cupy, dask+numpy benchmarked; dask+cupy not (suite-wide gap).
Test plan:
optimize_orderat nx=300).benchmarks.pathfinding), flake8 and isort clean.https://claude.ai/code/session_0155N4QGamQVxgpAAPbpQNq4