Skip to content

Fix #363: AttributeError: module 'cupy' has no attribute '_cupyx'#371

Open
JiwaniZakir wants to merge 1 commit intoKernelTuner:masterfrom
JiwaniZakir:fix/363-attributeerror-module-cupy-has-no-attri
Open

Fix #363: AttributeError: module 'cupy' has no attribute '_cupyx'#371
JiwaniZakir wants to merge 1 commit intoKernelTuner:masterfrom
JiwaniZakir:fix/363-attributeerror-module-cupy-has-no-attri

Conversation

@JiwaniZakir
Copy link
Copy Markdown

Closes #363

Motivation

cupy._cupyx is a private internal attribute that was removed in CuPy 14.x, causing an AttributeError on initialization when CupyFunctions.__init__ called cp._cupyx.get_runtime_info() at kernel_tuner/backends/cupy.py:71.

Changes

kernel_tuner/backends/cupy.py

  • Added import cupyx alongside import cupy as cp in the guarded try/except ImportError block (with cupyx = None as the fallback), making cupyx a proper top-level dependency rather than accessing it through CuPy's private namespace.
  • Replaced cp._cupyx.get_runtime_info() with cupyx.get_runtime_info() on line 71.

test/test_cupy_functions.py

  • Added test_cupy_init_uses_cupyx_not_private_attr: patches both kernel_tuner.backends.cupy.cp and kernel_tuner.backends.cupy.cupyx, constructs a CupyFunctions(device=0) instance, and asserts that cupyx.get_runtime_info() was called exactly once and that dev.name is correctly parsed from the mocked runtime info string. This serves as a regression test to prevent re-introduction of the _cupyx private attribute access.

Testing

The new unit test runs without a physical GPU by mocking both cp.cuda.Device and cupyx.get_runtime_info. Run it with:

pytest test/test_cupy_functions.py::test_cupy_init_uses_cupyx_not_private_attr -v

Manually verified on Google Colab with CuPy 14.0.1: CupyFunctions initializes without error and dev.env is populated correctly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@sonarqubecloud
Copy link
Copy Markdown

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.

AttributeError: module 'cupy' has no attribute '_cupyx'

1 participant