NVIDIA / NVIDIA/cuda-python

Relative imports from Cython files in cuda_core cause duplicate imports

Open
#2,023 5 comments 0 reactions 1 assignee View on GitHub

@acosmicflamingo is already working on this.

Since Jul 23, 2026.

bug cuda.core
Dominant language
Cython
Stars
3.4k
Forks
329
Avg merge
1d 23h
Merged PRs (30d)
116

Description

If you have code like

from . import typing

in a .pyx file, and another part of the system does:

from cuda.core.system import typing

it causes the typing module to be imported twice.

The first import places the module in sys.modules as cuda.core.cu13.system.typing, and the second import places the module in cuda.core.system.typing. It means that any isinstance checks on classes in this module will fail.

This is clearly a side effect of the "megapackage" approach handled by _import_versioned_module. It is not clear whether we can address it at that level.

At a minimum, maybe we can write a lint or an AGENT.md rule that relative imports should be avoided from Cython modules.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.