Skip to content

Ignore CuPy NumPy shape deprecation warning#1105

Closed
bdice wants to merge 1 commit into
rapidsai:mainfrom
bdice:codex/ignore-cupy-numpy-shape-warning
Closed

Ignore CuPy NumPy shape deprecation warning#1105
bdice wants to merge 1 commit into
rapidsai:mainfrom
bdice:codex/ignore-cupy-numpy-shape-warning

Conversation

@bdice

@bdice bdice commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes NumPy 2.5 DeprecationWarning failures triggered when pytest promotes deprecations to errors.

This PR:

  • updates cucim's vendored pad helper to use reshape instead of assigning to ndarray.shape
  • filters the same NumPy 2.5 warning when it originates from upstream CuPy
  • filters the same NumPy 2.5 warning when it originates from upstream scikit-image marching-cubes lookup-table setup

Root Cause

The failing CI job used Python 3.12, NumPy 2.5.0, and CuPy 14.1.1. NumPy 2.5 warns when code assigns directly to ndarray.shape; cucim's pytest config treats DeprecationWarning as an error.

The extracted failures came from three locations:

  • cucim/skimage/_vendored/pad.py::_as_pairs
  • cupy/_padding/pad.py::_as_pairs
  • skimage/measure/_marching_cubes_lewiner.py

The cucim-owned vendored helper is fixed directly. The CuPy and scikit-image occurrences are upstream dependency warnings, so they are filtered narrowly by module.

Validation

Created an isolated conda environment at .conda-cucim-cupy-np25 with Python 3.12.13, NumPy 2.5.0, CuPy 14.1.1, and the cucim test dependencies.

Extracted the failing node IDs from the CI log for actions/runs/28078321887/job/83129420085:

1062 unique failing node IDs

Ran the exact extracted subset locally with GPU access outside the sandbox:

PYTHONPATH=src /home/bdice/code/cucim/.conda-cucim-cupy-np25/bin/python -m pytest -s -q -c pyproject.toml --tb=short -x <extracted-node-ids>

Result:

1062 passed, 8 warnings in 133.77s (0:02:13)

Also ran:

git diff --check

@copy-pr-bot

copy-pr-bot Bot commented Jun 24, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@bdice bdice added bug Something isn't working non-breaking Introduces a non-breaking change labels Jun 24, 2026
@bdice bdice marked this pull request as ready for review June 24, 2026 16:11
@bdice bdice requested a review from a team as a code owner June 24, 2026 16:11
@bdice bdice requested a review from jameslamb June 24, 2026 16:11

@gforsyth gforsyth left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

:shipit:

This will be fixed upstream in cupy

@seberg

seberg commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Hmmmm, seems there is a copy inside cucim, which needs fixing. Maybe one could even avoid cupy.pad as well then by using that throughout, although to me ignoring seems totally fine as well.

diff --git a/python/cucim/src/cucim/skimage/_vendored/pad.py b/python/cucim/src/cucim/skimage/_vendored/pad.py
index 28bf916..dfd3be4 100644
--- a/python/cucim/src/cucim/skimage/_vendored/pad.py
+++ b/python/cucim/src/cucim/skimage/_vendored/pad.py
@@ -408,8 +408,7 @@ def _as_pairs(x, ndim, as_index=False):
 
     # Converting the array with `tolist` seems to improve performance
     # when iterating and indexing the result (see usage in `pad`)
-    x_view = x.view()
-    x_view.shape = (ndim, 2)
+    x_view = x.reshape(ndim, 2)
     return x_view.tolist()

@jakirkham

Copy link
Copy Markdown
Member

Thanks Bradley! 🙏

@grlee77 could you please take a look?

@grlee77

grlee77 commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

@seberg, I need to check if we still need this vendored pad version. There are some enhancements in some of the vendored ndimage code so we definitely need to keep those, but for pad I am not sure until I take a closer look.

@grlee77

grlee77 commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Thanks @bdice, please also make the fix suggested by @seberg for the vendored copy of pad.

The vendored version was based on the CuPy one, but has a specialized element-wise kernel path for a subset of the boundary modes that is automatically selected for performance depending on the internal _use_elementwise_kernel helper function.

@jakirkham

Copy link
Copy Markdown
Member

Thanks Greg! 🙏

...a specialized element-wise kernel path for a subset of the boundary modes that is automatically selected for performance depending on the internal _use_elementwise_kernel helper function.

Independent of this PR, but do we see a path to upstreaming some (or all) of this logic to CuPy?

Admittedly this may be complicated if logic higher up in an particular image operation is influencing how the padding is done

@jakirkham

Copy link
Copy Markdown
Member

Looked through the cases where we are doing shape assignment and agree with Sebastian we should be able to just use reshape

Have done this in PR: #1106

Would appreciate if all of you took a look 🙂

@grlee77 grlee77 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks, this warning ignore looks good to me

It looks like @jakirkham is addressing other shape assignment issues in #1106

@bdice bdice force-pushed the codex/ignore-cupy-numpy-shape-warning branch from f9ddcec to 8cb4254 Compare June 24, 2026 19:38
@bdice bdice requested a review from a team as a code owner June 24, 2026 19:38
@bdice bdice marked this pull request as draft June 24, 2026 19:39
jakirkham added a commit to jakirkham/cucim that referenced this pull request Jun 24, 2026
@jakirkham

Copy link
Copy Markdown
Member

Think we need both fixes in the same PR. Have seen some issues with CI if both are not present

Went ahead and merged this PR into PR: #1106

Hope that is ok

@bdice

bdice commented Jun 25, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @jakirkham! Closing this in favor of #1106.

@bdice bdice closed this Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working non-breaking Introduces a non-breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants