Skip to content

GPU tiled fallback drops critical read kwargs (allow_rotated/window/band/max_pixels) #2238

@brendancol

Description

@brendancol

Describe the bug

In xrspatial/geotiff/_backends/gpu.py, three CPU-fallback call sites to _read_to_array drop caller-supplied kwargs (allow_rotated, window, band, max_pixels):

  • line 684 (planar=2 per-band GPU decode fallback)
  • line 697 (sparse-tile fallback)
  • line 771 (post GPU-decode-failure fallback)

Each call is currently:

arr_cpu, _cpu_fallback_geo = _read_to_array(
    source, overview_level=overview_level)

The later _gpu_apply_window_band(...) call repairs shape for window/band after the fact, but it cannot repair allow_rotated=False. By the time control returns to GPU code the CPU parser has already raised NotImplementedError on the rotated ModelTransformation. Callers who pass a raised max_pixels can also still trip the default 1B-pixel cap inside the fallback.

The stripped-layout branch at gpu.py:491 already forwards window, band, and max_pixels correctly (see comment referencing #1732). The three tiled-fallback sites missed the same fix, plus allow_rotated.

Expected behavior

The three CPU-fallback call sites should forward all four caller-supplied kwargs:

arr_cpu, _cpu_fallback_geo = _read_to_array(
    source,
    overview_level=overview_level,
    window=window,
    band=band,
    max_pixels=max_pixels,
    allow_rotated=allow_rotated,
)

Regression coverage:

  • rotated-file fallback succeeds when allow_rotated=True. This currently xfails in test_allow_rotated_no_crs_2122.py::test_cupy_rotated_read_drops_crs.
  • caller-supplied max_pixels raise is honored on the fallback path.
  • caller-supplied window/band reach the fallback. The assertion can sit at the _read_to_array boundary so it does not rely on _gpu_apply_window_band masking the bug.

Affected paths

  • Sparse tiled files (has_sparse_tile=True)
  • PlanarConfiguration=2 multi-band tiled files when the per-band stage-2 GPU decode fails
  • Any tiled file when both gpu_decode_tiles_from_file and gpu_decode_tiles raise under on_gpu_failure='auto'

Additional context

Surfaced by a code review sweep of the geotiff module. Sibling finding to #2122, which fixed the eager numpy / dask / dask+cupy paths for allow_rotated. The test_cupy_rotated_read_drops_crs xfail in test_allow_rotated_no_crs_2122.py was filed against this same defect and will flip to a pass once the kwargs are forwarded.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggpuCuPy / CUDA GPU support

    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