[doc-only] Add developer guide for cuda.core
Summary
This PR adds a developer guide for Python and Cython code in cuda/core. The guide establishes conventions and best practices to maintain code quality and consistency across the codebase.
What's Included
The guide covers 10 major areas:
-
File Structure - Ordering of elements (SPDX headers, imports,
__all__, classes, functions) -
Package Layout - Organization of
.pyx,.pxd, and.pyfiles - Import Statements - Five-group organization with alphabetical sorting
- Class and Function Definitions - Ordering within classes (dunder methods, methods, properties)
-
Naming Conventions - Project-specific patterns (Cython
c_prefix, type suffixes) - Type Annotations and Declarations - Modern PEP 604 union syntax, Cython declarations
- Docstrings - NumPy docstring style with Sphinx cross-references
- Errors and Warnings - Custom CUDA exceptions, error handling patterns
- CUDA-Specific Patterns - GIL management for CUDA driver API calls
- Development Lifecycle - Two-phase development (Python first, then Cython optimization)
Key Principles
- PEP 8 and PEP 257 Base: References these as normative standards, documenting only project-specific extensions
- Guidelines, Not Rules: Emphasizes readability and maintainability over rigid enforcement
- Codebase-Aligned: Examples reflect actual patterns from the codebase
File Added
-
cuda_core/docs/source/developer-guide.rst
This pull request requires additional validation before any workflows can run on NVIDIA's runners.
Pull request vetters can view their responsibilities here.
Contributors can view more details about this message here.
Link to rendered document: style-guide.md
I'm interested in feedback on this idea. With a comprehensive style guide, aside from the other benefits listed in the description, we can use LLMs to help refactor, clean, and document the code. If the team is comfortable with this approach, I can begin to apply rules conservatively to the code base.
Will look more closely asap.
Drive-by comment: I was surprised to see the new file under cuda_core/cuda/core/. I'd expect it to be under cuda_core/, like other meta-kind-of files, e.g. LICENSE, README.md, etc.
Will look more closely asap.
Drive-by comment: I was surprised to see the new file under
cuda_core/cuda/core/. I'd expect it to be undercuda_core/, like other meta-kind-of files, e.g.LICENSE,README.md, etc.
I thought about that, too. I agree it belongs at the root.
Will look more closely asap. Drive-by comment: I was surprised to see the new file under
cuda_core/cuda/core/. I'd expect it to be undercuda_core/, like other meta-kind-of files, e.g.LICENSE,README.md, etc.I thought about that, too. I agree it belongs at the root.
Do we want this in the root? I'd expect it within a docs folder. That shouldn't impact an LLMs ability to discover and utilize it.
Merging my offline comment to here. My 2c:
- If possible I’d like to make part (or all) of this PR rendered as Sphinx docs, for both internal and external contributors to use as developer guide
- I’d also like all LLM to be able to read it when working on the codebase, including but not limited to: Cursor, CodeRabbit, Copilot, …
Moved to cuda_core/docs
/ok to test 98a0a648baf0ea27f34e09b155947218f51600b0
Doc Preview CI :---: |
:rocket: View preview athttps://nvidia.github.io/cuda-python/pr-preview/pr-1316/
|
https://nvidia.github.io/cuda-python/pr-preview/pr-1316/cuda-core/
|
https://nvidia.github.io/cuda-python/pr-preview/pr-1316/cuda-bindings/
|
https://nvidia.github.io/cuda-python/pr-preview/pr-1316/cuda-pathfinder/
|
Preview will be ready when the GitHub Pages deployment is complete.
/ok to test f50b64fc016214cac8ad56c95e84f94997166e4a
/ok to test f5dc2db684de438c56f04ba17c5a4a69a1c49bb3
The doc is now included with the Sphinx docs. Link above but also here . Click through CUDA Core Developer Guide.
/ok to test e72f8a0611b0749793094cfacc95b7a49ece21e1
/ok to test 56e92b98d92ffa950ee18be8b4eeff55abf5c1f5
/ok to test 3dc195932c215126bfe33751a2b017a538d739e0
/ok to test 804910f31a4fcd29d69edc69a3e9d76501ceb7e4
/ok to test 589b176dc2e2bc080e428e018f958fb41b4e35c4