Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Lazy load the testing module#9336

Merged
kmaehashi merged 2 commits into
cupy:mainfrom
vyasr:feat/cupy_testing_lazy_load
Sep 6, 2025
Merged

Lazy load the testing module#9336
kmaehashi merged 2 commits into
cupy:mainfrom
vyasr:feat/cupy_testing_lazy_load

Conversation

@vyasr

@vyasr vyasr commented Aug 29, 2025

Copy link
Copy Markdown
Contributor

As part of the import time investigations I have been doing regarding #9324 and #9325 I also noticed that cupy.testing adds significant testing overhead in environments where pytest is installed. I considered making the pytest import lazy or trying to hide its cost in other ways, but ultimately I decided that since most users of cupy do not need the testing module directly the best option would be to make the testing module import in cupy's __init__.py lazy and hide all of the overhead. The module load is fast enough that for users actually accessing the testing module the first attribute access (which triggers the load, and is therefore made slower by making this module load lazy) is still less than 0.1 s so it doesn't degrade that experience much (in exchange for making the majority use case of importing cupy without using testing faster).

@vyasr vyasr marked this pull request as ready for review August 29, 2025 23:50
Comment thread cupy/__init__.py
@kmaehashi kmaehashi self-assigned this Aug 30, 2025
@kmaehashi kmaehashi added cat:performance Performance in terms of speed or memory consumption prio:medium labels Aug 30, 2025
@leofang

leofang commented Sep 3, 2025

Copy link
Copy Markdown
Member

/test mini

@kmaehashi kmaehashi added this to the v14.0.0a2 milestone Sep 6, 2025
@kmaehashi

Copy link
Copy Markdown
Member

Thanks @vyasr! I've pushed minor tweaks to avoid exposing extra attributes under cupy.* namespace (c1feacb).

@kmaehashi kmaehashi merged commit de4fb5b into cupy:main Sep 6, 2025
6 of 7 checks passed
@vyasr vyasr deleted the feat/cupy_testing_lazy_load branch September 6, 2025 05:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cat:performance Performance in terms of speed or memory consumption prio:medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants