binary(): type the dask+cupy meta so the lazy dtype matches float32 (#3508)#3513
Conversation
Self-review (domain-aware)I ran the review-pr checks over this branch and found one real gap, now fixed in 2db65f8. Fixed during reviewThe eager dtype fix was correct, but it left the dask+cupy path half done. Probe before the fix: This is the same advertised-vs-computed mismatch class as aspect #2682 and focal #3217. Fix: pass The dask+numpy path was already fine because What looks good
Out of scope (follow-up)The sibling classifiers' dask+cupy helpers ( Note on the duplicatePR #3514 (accuracy sweep) fixes the same |
…array-contrib#3508) The _cpu_binary float32 fix and the verify_dtype=True backend tests landed on main via the duplicate accuracy-sweep PR xarray-contrib#3514. This change is the remaining piece: _run_dask_cupy_binary passed meta=cupy.array(()), which defaults to float64, so the lazy dask+cupy array advertised float64 while _run_cupy_binary computes float32. The merged tests only check the computed dtype (general_output_checks computes before asserting), so the mismatch went unnoticed. Pass meta=cupy.array((), dtype='f4') and assert the lazy dtype in test_binary_dask_cupy. Same advertised-vs-computed class as aspect xarray-contrib#2682 and focal xarray-contrib#3217. Also records the classify metadata-propagation sweep state.
2db65f8 to
1faa5c6
Compare
|
Rebased onto current main now that the duplicate accuracy-sweep PR #3514 has merged. Main already carries the This PR is now scoped to the only piece that wasn't in #3514: typing the dask+cupy New head: 1faa5c6 |
Part of #3508. Rebased onto current main after the duplicate accuracy-sweep PR #3514 merged.
The
_cpu_binaryfloat32 fix and theverify_dtype=Truebackend tests are already on main via #3514, so this PR is now scoped to the one piece that didn't land there: the dask+cupy lazy dtype.What this fixes
_run_dask_cupy_binarypassedmeta=cupy.array(()), which defaults to float64. So the lazy dask+cupy array advertised float64 while_run_cupy_binarycomputes float32. The merged tests only check the computed dtype becausegeneral_output_checkscomputes the array before asserting, so nothing caught the lazy mismatch.Probe before the fix:
This is the same advertised-vs-computed mismatch class as aspect #2682 and focal #3217.
Change
_run_dask_cupy_binarynow passesmeta=cupy.array((), dtype='f4').test_binary_dask_cupyasserts the lazy dtype is float32 so it stays pinned (the existing dtype checks all compute first).After the fix, dask+cupy reports float32 both lazy and computed. Full
test_classify.pysuite passes on a CUDA host with the GPU backends running live.Follow-up (out of scope)
The sibling classifiers' dask+cupy helpers (
_run_dask_cupy_binand friends) use the same untypedmeta=cupy.array(())and likely share the same latent lazy-dtype mismatch. Left for a separate change to keep this PR focused onbinary.