Skip to content

Test: cover write_geotiff_gpu CPU-fallback codecs (lzw/packbits/lz4/lerc/jpeg2000) #1706

@brendancol

Description

@brendancol

Coverage gap

The GPU writer write_geotiff_gpu documents nine compression= modes (none, deflate, lzw, jpeg, packbits, zstd, lz4, jpeg2000/j2k, lerc). Only four (none, deflate, zstd, jpeg) have direct round-trip tests in test_gpu_writer_compression_modes_2026_05_11.py.

The remaining five codecs route through dedicated branches in gpu_compress_tiles (xrspatial/geotiff/_gpu_decode.py:2974-3019) that fall back to the CPU compressor when no GPU accelerator exists:

  • compression='jpeg2000'/'j2k' -> _nvjpeg2k_batch_encode with jpeg2000_compress fallback
  • compression='lerc' -> lerc_compress (CPU only, no GPU library)
  • compression='lzw' -> cpu_compress via the trailing fallback branch
  • compression='packbits' -> cpu_compress via the trailing fallback branch
  • compression='lz4' -> cpu_compress via the trailing fallback branch

The trailing fallback branch is the same one nvCOMP-failures land in. A regression in any of these wiring points (eg. dropping a codec from the dispatch, swapping the routed compression tag, or returning the wrong-sized tile buffer) would ship undetected because:

  1. The internal reader uses the same compression-tag lookup so it would decode a wrong-tagged file correctly.
  2. No external interop check (GDAL / rasterio / libtiff) currently exercises these codecs from the GPU writer.
  3. The implicit smoke tests in the suite only exercise none/deflate/zstd/jpeg.

Severity: HIGH

Cat 4 (parameter coverage) HIGH. The untested modes are documented and shipped; users picking the GPU writer for an integer raster have a reasonable case for lzw or lerc over zstd.

Fix

Add test_gpu_writer_cpu_fallback_codecs_2026_05_12.py covering:

  • Round-trip pixel equality for lzw, packbits, lz4, lerc, jpeg2000 through write_geotiff_gpu.
  • TIFF Compression tag verification for each codec (catches wrong-tag-emission bugs not visible to the internal reader).
  • Cross-backend parity vs the matching CPU to_geotiff codec output (decoded array equality).
  • Availability-guarded skips on LERC_AVAILABLE / LZ4_AVAILABLE / JPEG2000_AVAILABLE.

Filed by the test-coverage sweep on 2026-05-12 (pass 11). Source unchanged; this is a test-only fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions