Skip to content

Gate remote sources in read_geotiff_gpu under stable_only (#2867)#2878

Merged
brendancol merged 2 commits into
mainfrom
issue-2867
Jun 3, 2026
Merged

Gate remote sources in read_geotiff_gpu under stable_only (#2867)#2878
brendancol merged 2 commits into
mainfrom
issue-2867

Conversation

@brendancol
Copy link
Copy Markdown
Contributor

Closes #2867

read_geotiff_gpu(..., stable_only=True) accepted the kwarg but never enforced it. For HTTP / fsspec sources the GPU path routes through the CPU fallback, so a direct GPU call could read an advanced-tier remote source that open_geotiff and read_geotiff_dask reject. The GPU docstring also called stable_only a no-op, which was wrong for remote sources.

  • Call _validate_stable_only_remote(...) in read_geotiff_gpu before the cupy import, the CUDA preflight, and the remote CPU fallback, the same way open_geotiff and read_geotiff_dask call it. Running it ahead of the import means the rejection is independent of GPU availability.
  • Fix the GPU docstring so stable_only is described as an enforced gate, not a no-op.

Backend coverage: the gate lives in the shared read_geotiff_gpu entry point, which serves the eager GPU (numpy/cupy) and chunked GPU (dask+cupy) reads. The other backends already had the gate.

Test plan:

  • Added GPU coverage to test_stable_only_remote_2821.py: fsspec and http sources rejected under stable_only=True, plus an experimental-optin unlock test gated behind cupy + CUDA.
  • Rejection tests pass on a CPU-only host (the gate fires before the cupy import).
  • pytest xrspatial/geotiff/tests/test_stable_only_remote_2821.py passes (12 passed locally with a GPU present).

read_geotiff_gpu accepted stable_only=True but never enforced it, so a
direct GPU call could read an advanced-tier HTTP / fsspec source that
open_geotiff and read_geotiff_dask reject. Call _validate_stable_only_remote
before the cupy import, the CUDA preflight, and the remote CPU fallback,
matching the other two readers, and fix the docstring that wrongly called
stable_only a no-op on the GPU path.

Extend test_stable_only_remote_2821 with GPU coverage: the rejection tests
run on CPU-only hosts because the gate fires before the cupy import; the
experimental-optin unlock test is gated behind cupy + CUDA.
@github-actions github-actions Bot added the performance PR touches performance-sensitive code label Jun 2, 2026
Copy link
Copy Markdown
Contributor Author

@brendancol brendancol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Review: Gate remote sources in read_geotiff_gpu under stable_only (#2867)

Blockers (must fix before merge)

None.

Suggestions (should fix, not blocking)

None.

Nits (optional improvements)

  • The unlock test (test_gpu_direct_fsspec_source_allowed_with_experimental_optin) re-declares the _gpu_available / _HAS_GPU helper that a few other geotiff test modules already define locally (read/test_basic.py, unit/test_predictor.py). There is no shared fixture for it, so the local copy matches the existing pattern in this package. Fine to leave as is.

What looks good

  • The gate runs before the cupy import, the CUDA preflight, and the remote CPU fallback, so the rejection does not depend on GPU availability. That is what lets the two rejection tests run on CPU-only CI, which is the right call.
  • The call signature matches how open_geotiff and read_geotiff_dask invoke _validate_stable_only_remote (same kwargs, same local-import style).
  • The gate sits ahead of the chunks is not None branch, so it covers both the eager and chunked GPU paths, not just one.
  • The docstring no longer claims stable_only is a no-op. The wording now matches actual behavior and the geotiff.rst note that already said all three paths run the check.
  • Tests cover fsspec and http rejection plus the experimental-codecs unlock, mirroring the existing eager/dask cases.

Checklist

  • Behavior matches the sibling readers (open_geotiff, read_geotiff_dask)
  • Gate fires before any GPU/network work
  • Covers eager and chunked GPU paths
  • Edge cases covered by tests (fsspec, http, unlock)
  • No premature materialization or unnecessary copies
  • Benchmark not needed (validation-only change)
  • README feature matrix not affected (no new function, no backend change)
  • Docstring present and accurate

@brendancol brendancol merged commit 81ac50a into main Jun 3, 2026
7 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.

read_geotiff_gpu(..., stable_only=True) does not gate remote sources

1 participant