Skip to content

Cover GPU writer overview_resampling='mode' and compression_level= (#1740)#1743

Merged
brendancol merged 1 commit into
mainfrom
deep-sweep-test-coverage-geotiff-2026-05-12-1778615608
May 12, 2026
Merged

Cover GPU writer overview_resampling='mode' and compression_level= (#1740)#1743
brendancol merged 1 commit into
mainfrom
deep-sweep-test-coverage-geotiff-2026-05-12-1778615608

Conversation

@brendancol
Copy link
Copy Markdown
Contributor

Closes #1740.

Summary

Six of the seven overview_resampling modes have end-to-end coverage on the GPU writer; mode was the odd one out. The dedicated branch in _block_reduce_2d_gpu (_gpu_decode.py:3051-3056) and the matching write_geotiff_gpu(cog=True, overview_resampling='mode') / to_geotiff(gpu=True, ..., overview_resampling='mode') paths had no targeted tests. test_mode_overview_perf.py exercises only the CPU _block_reduce_2d helper.

write_geotiff_gpu(compression_level=) is documented as accepted-but-ignored (nvCOMP has no level control). The CPU writer rejects out-of-range levels with ValueError; the GPU writer is documented not to. No test pinned the asymmetry.

Source unchanged; test-only addition.

Tests added

xrspatial/geotiff/tests/test_gpu_writer_overview_mode_and_compression_level_1740.py -- 19 tests, all passing on a GPU host:

  • _block_reduce_2d_gpu(method='mode') CPU-parity on 4x4 deterministic input + random 8x8 with many ties + dtype-preserved across u8/u16/i16/i32.
  • write_geotiff_gpu(cog=True, overview_resampling='mode') end-to-end round trip with overview matching the closed-form 2x2 mode reduction.
  • to_geotiff(gpu=True, cog=True, overview_resampling='mode') dispatcher thread-through.
  • GPU-vs-CPU writer pixel parity for mode on 8x8 random integer input.
  • write_geotiff_gpu(compression_level=N) in-range (zstd=1/22, deflate=1/9) and out-of-range (zstd=999/-5, deflate=50/0) accepted without raising, file still round-trips.
  • to_geotiff(gpu=True, compression_level=999) dispatcher thread-through.
  • Companion CPU to_geotiff(compression_level=999) raises ValueError to lock the documented asymmetry.

Test plan

  • All 19 new tests pass locally on a CUDA host
  • Existing test_overview_resampling_min_max_median_2026_05_11.py, test_mode_overview_perf.py, and test_signature_parity_1631.py still pass alongside (99 combined tests green)
  • Mutation: dropping the mode branch from _block_reduce_2d_gpu flips 9 mode tests red
  • CI runs the new tests on a GPU host

Sweep metadata

Filed via the deep-sweep test-coverage workflow (pass 12). State CSV updated to reflect the new coverage.

@github-actions github-actions Bot added the performance PR touches performance-sensitive code label May 12, 2026
@brendancol brendancol requested a review from Copilot May 12, 2026 20:05
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds missing GPU test coverage for GeoTIFF writing when overview_resampling='mode' and for the documented GPU-writer behavior that compression_level= is accepted but ignored (including out-of-range values), aligning with issue #1740 and strengthening regression protection around these public APIs.

Changes:

  • Added a new GPU-gated test module covering _block_reduce_2d_gpu(method='mode'), end-to-end COG overview generation using mode, and CPU↔GPU pixel parity for mode overviews.
  • Added GPU-gated tests pinning the “accepted-but-ignored” compression_level= contract on the GPU writer (both in-range and out-of-range), plus a companion CPU-side ValueError assertion to lock the intended asymmetry.
  • Updated the sweep coverage state CSV to record the new coverage work (pass 12 / issue #1740).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
xrspatial/geotiff/tests/test_gpu_writer_overview_mode_and_compression_level_1740.py New GPU-gated end-to-end + unit tests for overview_resampling='mode' and GPU compression_level= acceptance contract.
.claude/sweep-test-coverage-state.csv Records sweep metadata/state update reflecting the added coverage for issue #1740.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…el= (#1740)

Closes #1740.

Six of the seven overview_resampling modes had end-to-end coverage on
the GPU writer path; mode was the odd one out. The dedicated branch
in _block_reduce_2d_gpu (_gpu_decode.py:3051-3056) and the matching
write_geotiff_gpu(cog=True, overview_resampling='mode') /
to_geotiff(gpu=True, ..., overview_resampling='mode') paths had no
targeted tests. test_mode_overview_perf.py exercises only the CPU
_block_reduce_2d helper.

write_geotiff_gpu(compression_level=) is documented as accepted-but-
ignored (nvCOMP has no level control). The CPU writer rejects out-of-
range levels with ValueError; the GPU writer is documented not to.
No test pinned the asymmetry.

Source unchanged; test-only addition.

19 tests, all passing on a GPU host:

- _block_reduce_2d_gpu(method='mode') matches CPU output on 4x4
  deterministic input, on a random 8x8 with many ties, and preserves
  dtype across u8/u16/i16/i32.
- write_geotiff_gpu(cog=True, overview_resampling='mode') round-trips
  and the level-1 overview matches the closed-form 2x2 mode reduction.
- to_geotiff(gpu=True, cog=True, overview_resampling='mode')
  dispatcher thread-through.
- GPU-vs-CPU writer pixel parity on 8x8 random integer input.
- write_geotiff_gpu(compression_level=N) accepted for in-range
  (zstd=1/22, deflate=1/9) and out-of-range (zstd=999/-5, deflate=50/0)
  with the file still round-tripping in every case.
- to_geotiff(gpu=True, compression_level=999) dispatcher thread-through.
- Companion CPU rejects-OOR pin to lock the documented asymmetry.

Mutation testing: removing the mode branch from _block_reduce_2d_gpu
flips 9 of the new tests red.

Filed via the deep-sweep test-coverage workflow (pass 12).
@brendancol brendancol force-pushed the deep-sweep-test-coverage-geotiff-2026-05-12-1778615608 branch from f226de1 to 0059bf3 Compare May 12, 2026 20:22
@brendancol brendancol merged commit 99b1817 into main May 12, 2026
10 of 11 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.

Test: cover GPU writer overview_resampling='mode' and compression_level=

2 participants