Title: Review and standardize all example code before cuda.core 1.0.0 release · Issue #1673 · NVIDIA/cuda-python · GitHub
Open Graph Title: Review and standardize all example code before cuda.core 1.0.0 release · Issue #1673 · NVIDIA/cuda-python
X Title: Review and standardize all example code before cuda.core 1.0.0 release · Issue #1673 · NVIDIA/cuda-python
Description: Motivation Our example code is the first thing users reach for. The current examples were written at different times by different authors and have accumulated inconsistencies in structure, style, naming, and resource management. We need ...
Open Graph Description: Motivation Our example code is the first thing users reach for. The current examples were written at different times by different authors and have accumulated inconsistencies in structure, style, n...
X Description: Motivation Our example code is the first thing users reach for. The current examples were written at different times by different authors and have accumulated inconsistencies in structure, style, n...
Opengraph URL: https://github.com/NVIDIA/cuda-python/issues/1673
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Review and standardize all example code before cuda.core 1.0.0 release","articleBody":"### Motivation\n\nOur example code is the first thing users reach for. The current examples were written at different times by different authors and have accumulated inconsistencies in structure, style, naming, and resource management. We need to review every example across both `cuda.core` and `cuda.bindings` to ensure they present a polished, consistent experience for 1.0.0.\n\nEach sub-issue below is a self-contained work item — claim one by assigning yourself to it.\n\n### Known inconsistencies to evaluate\n\nThe following cross-cutting concerns have been identified. Each should be discussed by the team and resolved consistently across all examples.\n\n#### 1. File headers and copyright years\n- Copyright years are split: 7 files use `2024-2025`, 4 files use `2025` only.\n- The team should decide on one approach (e.g., always `2024-2025`, or year-of-creation to present).\n\n#### 2. Description block style\n- Some files use a single-line description: `\"This demo illustrates how to...\"`\n- Others use numbered bullet-point lists describing multiple concepts.\n- Some include usage instructions (`## Usage:` with pip/python commands), others don't.\n\n#### 3. Import ordering\n- At least 5 different import ordering patterns exist across the 11 cuda.core examples alone.\n- Variations: some start with `sys`, some have no stdlib imports, some use try/except for optional deps inline.\n- No consistent grouping (stdlib → third-party → cuda).\n\n#### 4. `if __name__ == \"__main__\"` guard\n- Only 4 of 11 cuda.core examples use a `__main__` guard (`show_device_properties.py`, `jit_lto_fractal.py`, `strided_memory_view_gpu.py`, `strided_memory_view_cpu.py`).\n- The other 7 run all code at module level.\n\n#### 5. Resource cleanup\n- Most examples do NOT close streams or buffers explicitly.\n- Only `saxpy.py` and `memory_ops.py` demonstrate explicit `close()` calls.\n- `strided_memory_view_gpu.py` uses a `finally` block for cleanup, others don't.\n- No examples use context managers for resource management.\n\n#### 6. Naming conventions\n- Stream variables: `s` vs `stream` vs `stream0`/`stream1`.\n- Kernel variables: `ker` vs `add_kernel` vs `gpu_ker`.\n- Device variables: `dev` vs `dev0`/`dev1` vs inline `Device()`.\n- Config objects are mostly `config`, but multi-config uses `config0`/`config1`.\n\n#### 7. Error handling and early-exit patterns\n- Some files use `sys.exit(0)` for unsupported configurations; others silently skip.\n- NumPy version checking uses two different APIs (`np.__version__ \u003c \"2.1.0\"` vs `np.lib.NumpyVersion()`).\n- Validation is a mix of `assert` statements and `print` + `sys.exit`.\n\n#### 8. Output and success messages\n- Completion messages vary: `\"done!\"`, `\"done\"` (no exclamation), `\"Example completed successfully!\"`, `\"All tests passed successfully!\"`, `\"Memory management example completed!\"`, or no message at all.\n- Some examples print intermediate progress, others are silent until the end.\n- Some use `sys.stderr` for warnings/info, others use `stdout`.\n\n#### 9. External dependencies\n- CuPy is required by 7 of 11 cuda.core files — is this the right default, or should more examples be dependency-light?\n- Only `show_device_properties.py` has zero external dependencies.\n- Optional dependency handling (try/except) is inconsistent.\n\n#### 10. Documentation coverage\n- Neither `cuda_core/examples/` nor `cuda_bindings/examples/` has a README.\n- Some examples are referenced in docs (`getting-started.rst`), others are not.\n- Consider whether each example should be linked from the documentation.\n\n### Sub-issues\n\nEach sub-issue below is a self-contained work item that can be claimed and driven independently. Assign yourself to a sub-issue to own it. Each sub-issue should result in one or more PRs that update **all** affected example files across both packages.\n\n- [ ] #1674 — Standardize file structure conventions\n- [ ] #1675 — Standardize naming conventions\n- [ ] #1676 — Standardize resource cleanup\n- [ ] #1677 — Standardize imports and dependency policy\n- [ ] #1678 — Standardize error handling and output\n- [ ] #1679 — Standardize file headers and copyright years\n- [ ] #1680 — Audit example coverage in documentation\n\n### How to contribute\n\n1. **Claim a sub-issue**: Assign yourself to one of the sub-issues above.\n2. **Propose a convention**: Comment on your sub-issue with a proposed standard for team review.\n3. **Apply across all files**: Once the convention is agreed upon, update all affected examples in both `cuda_core/examples/` and `cuda_bindings/examples/`.\n4. **Submit a PR** referencing this issue and the sub-issue number.\n5. **Check off the file-level boxes** in the Scope section above as files are updated.","author":{"url":"https://github.com/rparolin","@type":"Person","name":"rparolin"},"datePublished":"2026-02-20T21:34:02Z","url":"https://github.com/NVIDIA/cuda-python/issues/1673"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:3250c536-347d-ba58-3be7-52f99030fcd4 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 871A:395510:15193A:1DB539:6AF8376E |
| html-safe-nonce | b2000692371acdc24e080bc099183fd613bce05488bd073edfc8e0a07c8c040e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NzFBOjM5NTUxMDoxNTE5M0E6MURCNTM5OjZBRjgzNzZFIiwidmlzaXRvcl9pZCI6IjI4MTU3MTI4OTgxMzc0NzA4MzAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 2af08b51e5b955477aaef845ff750f2f41e17a4b9145f4e9f3e354e0d568608b |
| hovercard-subject-tag | issue:3970467130 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/NVIDIA/cuda-python/1673/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b263f12341607c7c54ed056204a662255ec5088b5f1fa6c7097f10103fc7ed2b/NVIDIA/cuda-python/issues/1673 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b263f12341607c7c54ed056204a662255ec5088b5f1fa6c7097f10103fc7ed2b/NVIDIA/cuda-python/issues/1673 |
| og:image:alt | Motivation Our example code is the first thing users reach for. The current examples were written at different times by different authors and have accumulated inconsistencies in structure, style, n... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | rparolin |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5713ecd83001b2f55c3509fb7a292bf7d66d0f167c7ae87a9f7eaec5a52bf8db |
| turbo-cache-control | no-preview |
| go-import | github.com/NVIDIA/cuda-python git https://github.com/NVIDIA/cuda-python.git |
| octolytics-dimension-user_id | 1728152 |
| octolytics-dimension-user_login | NVIDIA |
| octolytics-dimension-repository_id | 381173759 |
| octolytics-dimension-repository_nwo | NVIDIA/cuda-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 381173759 |
| octolytics-dimension-repository_network_root_nwo | NVIDIA/cuda-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 653be32ff5c755082a4db662491bfbbcfc9112c1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width