Skip to content

rasterize: fail fast on GPU scanline edge cap (#2067)#2072

Merged
brendancol merged 3 commits into
mainfrom
issue-2067
May 19, 2026
Merged

rasterize: fail fast on GPU scanline edge cap (#2067)#2072
brendancol merged 3 commits into
mainfrom
issue-2067

Conversation

@brendancol
Copy link
Copy Markdown
Contributor

Summary

The CUDA polygon scanline kernel allocates a fixed-size cuda.local.array(2048) for active edges per raster row. Rows exceeding that cap silently truncated and produced wrong output.

  • Eager CuPy used to emit a RuntimeWarning but still return the corrupted raster.
  • The Dask+CuPy tile path had no check at all, so per-tile truncation was silent.

Both paths now call a shared _check_gpu_edge_cap(row_ptr) that raises a ValueError pointing the caller at the numpy/dask+numpy backend.

The validator runs host-side, so the regression test does not need a GPU.

Closes #2067

Test plan

  • test_gpu_edge_cap_check_raises constructs a row_ptr exceeding the cap and asserts ValueError.
  • test_gpu_edge_cap_check_passes_at_limit confirms exactly-at-cap is permitted.
  • Full rasterize suite (CPU paths): 158 passed, 2 skipped.
  • GPU-end-to-end check pending CI runner with CUDA.

@github-actions github-actions Bot added the performance PR touches performance-sensitive code label May 18, 2026
The CUDA scanline kernel allocates a fixed-size cuda.local.array(2048)
for active edges per row.  Rows exceeding that cap silently truncated
and produced wrong output.

The eager CuPy path issued a RuntimeWarning but still returned the
corrupted raster.  The Dask+CuPy tile path had no check at all, so
per-tile truncation was silent.

Both paths now share _check_gpu_edge_cap(row_ptr) which raises a
ValueError pointing the caller at the numpy backend.

Closes #2067
# Conflicts:
#	xrspatial/tests/test_rasterize.py
@brendancol brendancol merged commit 06ff820 into main May 19, 2026
5 checks passed
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.

rasterize: GPU polygon scanline silently truncates at 2048 active edges

1 participant