Skip to content

Deprecate cupy array backend (#843)#881

Merged
kennethshsu merged 3 commits into
casact:mainfrom
priyam0k:feature/843-deprecate-cupy
Jun 3, 2026
Merged

Deprecate cupy array backend (#843)#881
kennethshsu merged 3 commits into
casact:mainfrom
priyam0k:feature/843-deprecate-cupy

Conversation

@priyam0k
Copy link
Copy Markdown
Contributor

@priyam0k priyam0k commented May 29, 2026

Summary of Changes

Emits a DeprecationWarning when the cupy array backend is selected, without removing any functionality. cupy is elective and not well maintained, so it's slated for removal in a future release (#601). This warns users now so they can migrate before it's gone.

Three entry points warn:

  • set_option("ARRAY_BACKEND", "cupy") warns
  • set_option("ARRAY_PRIORITY", ...) warns only when cupy is ranked ahead of numpy or sparse, so valid priority lists don't get noisy
  • Triangle.set_backend("cupy") warns once at the user's call site, even with deep=True. Internal recursive calls are suppressed via a private _warn flag.

Also documented the _warn and deep params on set_backend.

Added tests in chainladder/utils/tests/test_utilities.py covering each warning path plus the no-warn cases (non-cupy backends, and cupy ranked last in priority).

Related GitHub Issue(s)

Closes #843.

Per @henrydingliu's call on the issue, this only deprecates (warns) and does not remove cupy. Removal can follow later under #601.

Additional Context for Reviewers

The current default priority ["dask", "sparse", "cupy", "numpy"] has cupy ahead of numpy, so explicitly re-setting that default would warn. Happy to switch the check to only fire when cupy leads both numpy and sparse if you'd prefer the default never warns.

  • uv run --extra dev pytest -k "deprecat or cupy" passed, 6 tests

  • uv run jb build docs --builder=custom --custom-builder=doctest clean

  • I passed tests locally for both code (uv run pytest) and documentation changes (uv run jb build docs --builder=custom --custom-builder=doctest)

Emit DeprecationWarning when the cupy backend is selected, without removing functionality:

- Options.set_option warns for ARRAY_BACKEND='cupy' and for 'cupy' in ARRAY_PRIORITY.

- Common.set_backend warns when backend='cupy'.

Adds tests asserting the warnings fire and that non-cupy backends do not warn.
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 69ab9b0. Configure here.

Comment thread chainladder/core/common.py Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented May 29, 2026

Codecov Report

❌ Patch coverage is 91.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 86.99%. Comparing base (449b5c1) to head (f84f94f).
⚠️ Report is 36 commits behind head on main.

Files with missing lines Patch % Lines
chainladder/core/common.py 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #881      +/-   ##
==========================================
- Coverage   87.04%   86.99%   -0.05%     
==========================================
  Files          86       87       +1     
  Lines        4986     4952      -34     
  Branches      646      629      -17     
==========================================
- Hits         4340     4308      -32     
+ Misses        456      454       -2     
  Partials      190      190              
Flag Coverage Δ
unittests 86.99% <91.66%> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Move the DeprecationWarning to set_backend's public entry point and add a private _warn guard so internal recursive (inplace) and deep-child calls do not re-warn. This makes stacklevel=2 point at the user's call site and ensures exactly one warning fires. Strengthens the test to assert a single warning at the caller's file.
@henrydingliu
Copy link
Copy Markdown
Collaborator

@genedan I'd like to defer this review to you.

@priyam0k
Copy link
Copy Markdown
Contributor Author

priyam0k commented Jun 1, 2026

gentle bump on this one whenever you get a chance @genedan — it follows the three hookpoints you outlined on #843 (the two set_option paths + set_backend), warning-only per @henrydingliu's note, with a small test confirming the warnings fire. ci's green. if it looks good i'm happy to do the matching dask deprecation (#842) next so they stay consistent.

@genedan
Copy link
Copy Markdown
Collaborator

genedan commented Jun 3, 2026

I've added my review notes, could you address them?

Copy link
Copy Markdown
Contributor Author

@priyam0k priyam0k left a comment

Choose a reason for hiding this comment

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

Thanks @genedan! On my end I only see this comment, not the review notes yet. Might still be pending...

Comment thread chainladder/core/common.py
Comment thread chainladder/__init__.py
@priyam0k priyam0k changed the title Deprecate cupy array backend Deprecate cupy array backend (#843) Jun 3, 2026
Copy link
Copy Markdown
Collaborator

@genedan genedan left a comment

Choose a reason for hiding this comment

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

You'll find that some of the tests will fail once you get around to deprecating dask. Approving this because we can get around to adjusting the tests as #842 is addressed.

@kennethshsu kennethshsu merged commit 25e1192 into casact:main Jun 3, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deprecate Cupy

4 participants