Skip to content

[DRAFT] Replace nvrtc Tempita templates with pre-generated Cython files#1900

Draft
leofang wants to merge 7 commits intoNVIDIA:mainfrom
leofang:leof/issue-173-nvrtc-generated-artifacts
Draft

[DRAFT] Replace nvrtc Tempita templates with pre-generated Cython files#1900
leofang wants to merge 7 commits intoNVIDIA:mainfrom
leofang:leof/issue-173-nvrtc-generated-artifacts

Conversation

@leofang
Copy link
Copy Markdown
Member

@leofang leofang commented Apr 13, 2026

Summary

Replace NVRTC's Tempita .pyx.in / .pxd.in templates with pre-generated plain Cython files, and update the build system to skip pyclibrary header parsing for NVRTC.

Generated artifacts (all Tempita-free):

  • Remove 6 old .pyx.in / .pxd.in template files
  • Add 7 pre-generated .pyx / .pxd files following cybind convention
  • Internal layer moved from _bindings/ to _internal/ with platform split (nvrtc_linux.pyx / nvrtc_windows.pyx)

Build system (build_hooks.py):

  • Remove nvrtc from _REQUIRED_HEADERS — no pyclibrary parsing needed
  • Update sources_list: cynvrtc.pyx source path changed from _bindings/ to bindings/
  • _rename_architecture_specific_files already handles _internal/nvrtc_linux.pyx_internal/nvrtc.pyx

This is a companion PR to cybind !369. When driver/runtime are also migrated, pyclibrary can be removed from pyproject.toml build-system.requires entirely.

Test plan

  • Review generated files match expected cybind convention
  • Verify zero Tempita in all generated files
  • Build with CUDA toolkit to verify Cython compilation succeeds
  • Run nvrtc tests

-- Leo's bot

🤖 Generated with Claude Code

Replace .pyx.in / .pxd.in Tempita templates with plain .pyx / .pxd files
generated by the refactored cython-gen (cybind leof/cybind\!369).

Changes:
- Remove 6 Tempita template files (.pyx.in / .pxd.in) for nvrtc
- Add 7 pre-generated Cython files with zero Tempita
- Move internal layer from _bindings/ to _internal/ following cybind convention
- Split platform-specific code into nvrtc_linux.pyx / nvrtc_windows.pyx
- Internal layer now uses cybind-style loading (RTLD_DEFAULT + fallback,
  FunctionNotFoundError, _init_nvrtc/_check_or_init_nvrtc naming)

This is a companion PR to cybind leof/cybind\!369. Build system changes
(build_hooks.py, pyproject.toml) to remove pyclibrary are not yet
included — this PR shows the generated output for review.

Part of https://gitlab-master.nvidia.com/leof/cybind/-/issues/173

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@copy-pr-bot
Copy link
Copy Markdown
Contributor

copy-pr-bot bot commented Apr 13, 2026

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.

leofang and others added 5 commits April 13, 2026 21:17
Update generated artifacts to use cybind-style templates:
- Fix excessive blank lines from Tempita stripping
- Internal layer files now generated from template files under
  cybind/assets/templates/ via string.Template.substitute()
- Proper license headers from templates

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- cynvrtc.pyx now uses "from ._internal cimport nvrtc as _nvrtc"
  instead of the legacy "cimport _bindings.cynvrtc as cynvrtc"
- Function wrappers reference _nvrtc._funcName() matching cybind style
- cynvrtc.pxd gets proper template header

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Remove nvrtc from _REQUIRED_HEADERS (no pyclibrary parsing needed;
  nvrtc .pyx/.pxd files are now pre-generated by cybind)
- Update sources_list: cynvrtc.pyx moved from _bindings/ to bindings/
- _rename_architecture_specific_files already handles
  _internal/nvrtc_linux.pyx -> _internal/nvrtc.pyx

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… entry

- Regenerate files with generator version in header comments
- Remove explicit cynvrtc.pyx from sources_list (already covered by
  cuda_bindings_files glob)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Regenerated from latest cybind which now cleans up trailing whitespace
and ensures files end with exactly one newline.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@leofang
Copy link
Copy Markdown
Member Author

leofang commented Apr 14, 2026

/ok to test 3317324

@leofang leofang self-assigned this Apr 14, 2026
@leofang leofang added enhancement Any code-related improvements cuda.bindings Everything related to the cuda.bindings module labels Apr 14, 2026
@github-actions
Copy link
Copy Markdown

@leofang
Copy link
Copy Markdown
Member Author

leofang commented Apr 14, 2026

/ok to test 8016408

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cuda.bindings Everything related to the cuda.bindings module enhancement Any code-related improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant