-
Notifications
You must be signed in to change notification settings - Fork 196
Fix #789: Remove cyclical import between driver and _lib.utils #865
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
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. |
/ok to test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request removes a cyclical import between the driver and _lib.utils modules by consolidating the utils module content directly into the driver module. This simplifies the build process and Cython code generation while maintaining the same functionality.
- Moves helper classes and utilities from
_lib.utils
into the driver module - Updates all references from
utils.HelperX
todriver.HelperX
across runtime and nvrtc modules - Modifies the setup.py to handle the new module structure during compilation
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.
Show a summary per file
File | Description |
---|---|
cuda_bindings/setup.py | Adjusts build configuration to handle param_packer.cpp dependency for driver.pyx only |
cuda_bindings/cuda/bindings/runtime.pyx.in | Updates all utils references to use driver module instead |
cuda_bindings/cuda/bindings/runtime.pxd.in | Removes utils import and updates helper class references |
cuda_bindings/cuda/bindings/nvrtc.pyx.in | Updates utils references to use driver module and adds driver import |
cuda_bindings/cuda/bindings/nvrtc.pxd.in | Removes unused utils import |
cuda_bindings/cuda/bindings/driver.pyx.in | Adds complete utils functionality including helper classes and imports param_packer |
cuda_bindings/cuda/bindings/driver.pxd.in | Includes helper class declarations from utils and adds necessary imports |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
cimport cuda.bindings._lib.param_packer as param_packer | ||
|
||
|
||
#### From utils.pyx.in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The comment indicates this code is 'From utils.pyx.in' but the section ends with '#### <- From utils.pyx.in' at line 672, creating inconsistent comment formatting. Consider using consistent markers like '#### Begin utils.pyx.in content' and '#### End utils.pyx.in content'.
Copilot uses AI. Check for mistakes.
cdef char* _charstar | ||
{{endif}} | ||
|
||
#### <-- from utils.pxd.in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Inconsistent comment formatting with the opening marker at line 10. The opening uses '#### from utils.pyd.in' (with incorrect extension) while closing uses '#### <-- from utils.pxd.in'. Consider standardizing both markers.
Copilot uses AI. Check for mistakes.
@mdboom another avenue that could possibly work here is to drop the This would allow us to effectively textually inline all of the functionality of The other thing is that I think we still need to keep the |
This turns the `utils` module into something that is intended to be textually included from a `.pxd` and `.pyx` file, rather than imported.
Good suggestion. I was afraid of the "multiple copies of the same class" problem, where
I think we still need to declare these classes in the
Strictly speaking, yes. If we need it, we should add some testing since it would no longer be imported in the normal course of things and our test suite would no longer exercise it. (I ask this as a n00b) -- does ABI matter for strictly private modules like this? |
/ok to test |
I would not concern with private modules' API/ABI. They should neither be
This seems weird to me. If we have cdef classes using these members, we should just do literal include of the |
I believe |
Yeah, that makes sense. This will definitely change the ABI then. Particularly, all of |
The problem is that the types in utils are exposed as members of the types in |
/ok to test |
|
/ok to test |
I have (1) made the util classes "private" ( So that does leave the ABI issue. I'm a little unclear about what this means in a Cython context and what we should be guaranteeing. I ran the changes through the C-level |
Auto-sync is disabled for ready for review pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
I'm unclear on the implementation details of |
Got it. I think at this point I don't know -- probably the only way to find out is to try it. |
For an experiment, I built I do think we should remove the |
/ok to test |
/ok to test |
Thanks for looking into it @mdboom!
two notes here:
|
Great. I couldn't get
|
Opening as a draft PR because I'm not sure this is the only option we have, but I'd like to get some feedback and CI anyway.
This basically just moves _lib.utils into driver, which isn't so bad. It does greatly simplify the generated Cython code.This turns
_lib.utils
into something that is textually included from.pxd
and.pyx
files, rather than imported.closes
Checklist